20201111

#EXTRACT4 ubuntu server

server

202011

#EXTRACT4:

enable the “partner” repository:
https://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository
sudo add-apt-repository "deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner"
 
 ===
 
apt install -y linux-headers-$(uname -r) build-essential dkms
 
apt install -y coreutils mc htop traceroute netdiag screen tmux openssh-server ncdu p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract lbzip2 lm-sensors acpi gpm jnettop iftop atop

====
How To Find Best Ubuntu APT Repository Mirror

https://ostechnix.com/how-to-find-best-ubuntu-apt-repository-mirror/

sudo cp /etc/apt/sources.list{,.backup}
sudo apt install python3-pip
pip3 install apt-select
apt-select --choose -t 5 --country UA 
sudo mv sources.list /etc/apt/


=====

rc.local IN systemD

https://askubuntu.com/a/919598

printf '%s\n' '#!/bin/sh' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local
sudo reboot

++
https://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local

sudo -iu username /usr/bin/screen -dmS script bash -c '/var/www/path/to/script/script.sh; exec bash'


20190415

#EXTRACT3

#v20190415:

sudo apt update && sudo apt -y upgrade && sudo apt install -y linux-headers-$(uname -r) build-essential dkms && sudo apt install -y coreutils mc htop traceroute netdiag screen tmux openssh-server ncdu p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 lm-sensors acpi gpm inxi gparted

LINUX_MINT:
sudo apt update && sudo apt upgrade -y && sudo apt install -y linux-headers-$(uname -r) build-essential dkms && sudo apt install -y coreutils mc htop traceroute netdiag screen tmux openssh-server ncdu p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 lm-sensors acpi gpm inxi gparted


ifconfig vs ip
https://p5r.uk/blog/2010/ifconfig-ip-comparison.html

Show network devices and configuration
ifconfig
ip addr show
ip link show

Enable a network interface
ifconfig eth0 up
ip link set eth0 up

Set IP address
ifconfig eth0 192.168.0.77
ip address add 192.168.0.77 dev eth0

ifconfig eth0 192.168.0.77 netmask 255.255.255.0 broadcast 192.168.0.255
ip addr add 192.168.0.77/24 broadcast 192.168.0.255 dev eth0

Show the routing table
route
ip route show

 

#20191207
Ubuntu18:


Starting with 17.10 release, Netplan is the default network management tool on Ubuntu, replacing the configuration file /etc/network/interfaces that had previously been used to configure the network on Ubuntu.

Netplan uses configuration files with YAML syntax


mcedit /etc/netplan/01-netcfg.yaml
mcedit /etc/netplan/50-cloud-init.yaml

netplan apply 

====
How to Automatically Record the Terminal Session Activity of All Users on Linux

mcedit /etc/profile
//and add the code below:

#Script to Record the User's Terminal Session
if [ "x$session_record" = "x" ]
then
timestamp=`date "+%m%d%Y%H%M"`
output=/var/log/session/session.$USER.$$.$timestamp
session_record=started
export session_record
script -t -f -q 2>${output}.timing $output
exit
fi


mkdir /var/log/session
chmod 777 /var/log/session


https://www.2daygeek.com/automatically-record-all-users-terminal-sessions-activity-linux-script-command/ 

#20180829

vagrant@ubuntu-xenial:~$ mc
Failed to run:
Cannot create /home/vagrant/.config/mc directory

sudo chown -R vagrant:vagrant /home/vagrant/.config/

sudo chown -R vagrant:vagrant /home/vagrant/.local/





#201808**
on  clean install (ubuntu SERVER!!!!!)
https://www.wikihow.com/Add-or-Change-the-Default-Gateway-in-Linux

sudo route delete default

sudo route add default gw 192.168.1.254



#20180825
in linux mint LAST!!
https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd

sudo systemctl status rc-local

Active: failed

sudo nano /etc/systemd/system/rc-local.service

Then add the following content to it.

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target


sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
Output:

Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /etc/systemd/system/rc-local.service.

Now start the service and check its status:

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service


!!!!!!!!!!!

Don’t forget the hashpling or `#!/bin/bash` in your rc.local !!
Missing this will cause an exec / format error.

!!!!!!!!!!

++

Force rc.local to wait for network

https://discourse.osmc.tv/t/force-rc-local-to-wait-for-network/11593/7

!!
if I add back sleep 10 to rc.local, everythink works correctly again on reboot.
!!
// via:   sudo systemctl status rc-local
--- error
"сер 25 20:55:28 hostname rc.local[694]: SIOCADDRT: Network is unreachable"



20190415
VINO: disable encryption:

https://askubuntu.com/questions/4474/enable-remote-vnc-from-the-commandline

On Ubuntu 14.04, I found the following variation worked for me:

export DISPLAY=:0
gsettings set org.gnome.Vino enabled true
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
/usr/lib/vino/vino-server


check:
gsettings get org.gnome.Vino require-encryption



===================
===================
===================

vagrant@ubuntu-xenial:~$ nmcli dev show | grep 'DNS'
The program 'nmcli' is currently not installed. To run 'nmcli' please ask your administrator to install the package 'network-manager'

sudo apt install network-manager

====

4 vagrant
FORCE RESOLEON GOOGLE DNS

vagrant@ubuntu-xenial:~$ sudo mcedit /etc/dhcp/dhclient.conf

#add!
supersede domain-name-servers 8.8.8.8, 8.8.4.4;

RESTART NET:
vagrant@ubuntu-xenial:~$ sudo invoke-rc.d networking restart

CHECK:
vagrant@ubuntu-xenial:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
search  co.loc

vagrant@ubuntu-xenial:~$ nslookup go.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   go.com
Address: 23.236.60.174

vagrant@ubuntu-xenial:~$


===
HugePages

https://paolozaino.wordpress.com/2016/10/02/how-to-force-any-linux-application-to-use-hugepages-without-modifying-the-source-code/

quickly set:

sudo sysctl -w vm.nr_hugepages=128
grep Huge /proc/meminfo


Configure hugepages in kernel
https://kerneltalks.com/services/what-is-huge-pages-in-linux/

sudo mcedit /etc/sysctl.conf

Add
vm.nr_hugepages=128

and reload configuration by issuing
sudo sysctl -p

Use below command to check current state of hugepages
root@kerneltalks # cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

[always] flag in output shows that hugepages are enabled on system.

how do I enable transparent huge pages by default on ubuntu ?
https://stackoverflow.com/questions/16072389/how-do-i-enable-transparent-huge-pages-by-default-on-ubuntu

Adding the following:

transparent_hugepage=always
to GRUB_CMDLINE_LINUX_DEFAULT in your:

/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet nopti transparent_hugepage=always"

and doing a:
update-grub

===
https://www.massmux.com/optimal-configuration-xmrig-linux-monero-mining/
If your cpu supports hugepages, it’s better to enable them. The commands to do that are:

echo 128 > /proc/sys/vm/nr_hugepages

sysctl -w vm.nr_hugepages=128


====

determining my public IP?

https://askubuntu.com/questions/95910/command-for-determining-my-public-ip

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

curl ipinfo.io/ip

wget -qO- http://ipecho.net/plain ; echo

curl icanhazip.com

curl ipecho.net


====
WINDOWS:

http://www.itprotoday.com/windows-8/cool-things-do-netsh
netsh interface ip show config

netsh interface ip set dns "Ethernet" static 8.8.8.8

netsh interface ip set dns "Ethernet" source=dhcp



====
#4vnc

sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal


#addit packets^

sudo apt-get install indicator-applet-appmenu

sudo apt-get install autocutsel

sudo apt install xfonts-base xfonts-75dpi xfonts-100dpi


m@3:~$ ll /usr/share/fonts/X11/
total 80
drwxr-xr-x 8 root root  4096 Apr  9 13:35 ./
drwxr-xr-x 7 root root  4096 Aug  1  2017 ../
drwxr-xr-x 2 root root 20480 Apr  9 13:35 100dpi/
drwxr-xr-x 2 root root 20480 Apr  9 13:35 75dpi/
drwxr-xr-x 3 root root  4096 Aug  1  2017 encodings/
drwxr-xr-x 2 root root 20480 Aug  1  2017 misc/
drwxr-xr-x 2 root root  4096 Aug  1  2017 Type1/
drwxr-xr-x 2 root root  4096 Aug  1  2017 util/
m @ 3:~$


Step 4 — Creating a VNC Service File
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04

sudo nano /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=sammy
PAMName=login
PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target


sudo systemctl daemon-reload

sudo systemctl enable vncserver@1.service

vncserver -kill :1

sudo systemctl start vncserver@1

sudo systemctl status vncserver@1


=============
============
============
=============


ntp.time.in.ua - основной сервер точного времени (stratum 1);
ntp2.time.in.ua - резервный сервер точного времени (stratum 1);
ntp3.time.in.ua - резервный сервер точного времени (stratum 2).

sudo ip route add default via 10.2.*.*



14^04^:
sudo route delete default

sudo route add default gw 10.2.*.*
(!!! without "ip" !!!! &&delete before !!!)
+  nmcli dev list | grep 'DNS'

======
DNS:
https://unix.stackexchange.com/questions/136117/ignore-dns-from-dhcp-server-in-ubuntu

s @ 22:~$ nmcli dev show | grep 'DNS'
IP4.DNS[1]:                             10.3
IP4.DNS[2]:                             10.3
IP4.DNS[3]:                             10.3
IP4.DNS[4]:                             10.3 2
su @ 2:~$


sudo mcedit /etc/dhcp/dhclient.conf

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

+++
How do I renew my DHCP lease?
https://askubuntu.com/questions/4014/how-do-i-renew-my-dhcp-lease
In the network drop-down selector from the system tray you can press the network you are already connected to,
- this will make network-manager ask for a new lease from a DHCP server.


====
LID CLOSE:
https://askubuntu.com/questions/15520/how-can-i-tell-ubuntu-to-do-nothing-when-i-close-my-laptop-lid

For 13.10 - 16.04:
To make Ubuntu do nothing when laptop lid is closed:

sudo mcedit /etc/systemd/logind.conf

HandleLidSwitch=ignore

sudo service systemd-logind restart


For 14.04:
sudo restart systemd-logind



====
DEFAULT_BOOT_WINDOWS

https://askubuntu.com/questions/52963/how-do-i-set-windows-to-boot-as-the-default-in-the-boot-loader

grep menuentry /boot/grub/grub.cfg

##!!! menuentry 'Windows 10 (loader) (on /dev/sda2)' -- - change to "Windows 10 (loader) (on /dev/sda2)"

sudo mcedit /etc/default/grub

sudo update-grub

///
m @ 3:~$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

#GRUB_DEFAULT=0
GRUB_DEFAULT="Windows 10 (loader) (on /dev/sda2)"
#GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet nopti"
#GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX="3"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
m @ 3:~$


!!!!!
in ubuntu 14.04
GRUB_CMDLINE_LINUX="text"

start GUI
service lightdgm start

sudo systemctl start lightdgm.service

====
VBOX ADDITIONS

https://www.vagrantup.com/docs/virtualbox/boxes.html


sudo apt-get install linux-headers-$(uname -r) build-essential dkms

# by using the GUI and clicking on "Devices" followed by "Install Guest Additions".

sudo mount /dev/cdrom /media/cdrom

sudo sh /media/cdrom/VBoxLinuxAdditions.run



=====

NTP

timedatectl

systemctl status systemd-timesyncd

sudo systemctl restart systemd-timesyncd

timedatectl status

https://help.ubuntu.com/lts/serverguide/NTP.html#timedatectl

sudo apt install ntp

https://www.digitalocean.com/community/tutorials/how-to-configure-ntp-for-use-in-the-ntp-pool-project-on-ubuntu-16-04

sudo mcedit /etc/ntp.conf

#comment
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

#add

server ntp.time.in.ua iburst
server ntp2.time.in.ua iburst
server ntp3.time.in.ua iburst

# http://time.in.ua/setup.html

# systemctl reload ntp.service

sudo systemctl restart ntp.service

systemctl status ntp.service

sudo ntpq -p


OR!!!

https://help.ubuntu.com/community/UbuntuTime

sudo dpkg-reconfigure tzdata


!!!
How to tell Ubuntu that hardware clock is local time?

https://askubuntu.com/questions/946516/how-to-tell-ubuntu-that-hardware-clock-is-local-time

In Ubuntu releases that use systemd the command to change time to local and update the clock right away is

timedatectl set-local-rtc 1 --adjust-system-clock

If you run timedatectl, it will show a warning

Warning: The system is configured to read the RTC time in the local time zone.
         This mode can not be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
This warning doesn't mean that it is set to 0, it suggests a command to switch it back to RTC.


RES:
m @ 2:~$ timedatectl
      Local time: Thu 2018-02-01 19:52:46 EET
  Universal time: Thu 2018-02-01 17:52:46 UTC
        RTC time: Thu 2018-02-01 19:52:46
       Time zone:  ****
 Network time on: yes
NTP synchronized: no
 RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode can not be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
user@_012:~$



====
BASH COMPLETION
https://askubuntu.com/questions/86375/apt-get-autocomplete-package-name-is-broken


sudo apt-get install bash-completion command-not-found

apt-get -y install coreutils mc htop nethogs traceroute netdiag ncdu \
p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 \
android-tools-adb android-tools-fastboot


=====
SHUTDOWN AT TIME

sudo shutdown -h 06:00
#- will work fine, no need to run it in the background.
#Add the command at the end of /etc/rc.local (or /etc/rc.d/rc.local depending on your system) for execution in the last startup script.

# The advantage of not using cron is that in this way the shutdown remains scheduled during the day, and you can cancel it at any time by typing

#shutdown -c

user@_014:~$ sudo shutdown -h 21:40
Shutdown scheduled for пн 2018-01-29 21:40:00 EET, use 'shutdown -c' to cancel.
user@_014:~$
 
=====
WINDOWS SET IP DNS CLI

netsh interface ip set dns "Ethernet" source=dhcp

netsh interface ip set dns "Ethernet" static 10.3*.*
netsh interface ip set dns "Ethernet" static 8.8.8.8

netsh interface ip show config "Ethernet"




C:\Users\Admin>

 
====
GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"

https://gist.github.com/LeahCim/9332432

https://askubuntu.com/questions/633175/grub-wait-time-10-seconds-after-editing-to-0-in-etc-default-grub/635960#635960


add the files /etc/grub.d/25_pre-os-prober and /etc/grub.d/35_post-os-prober.

25_pre-os-prober:
#! /bin/sh
# file: /etc/grub.d/25_pre-os-prober
set -e

# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.

cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF
35_post-os-prober
#! /bin/sh
# file: /etc/grub.d/35_post-os-prober
set -e

# Reset $timeout and $timeout_style to their original values
# set by /etc/grub.d/00_header before /etc/grub.d/30_os-prober messed them up.

cat << EOF
set timeout=\${timeout_bak}
set timeout_style=\${timeout_style_bak}
EOF

+++


GRUB_TIMEOUT_STYLE=hidden

https://askubuntu.com/questions/111085/how-do-i-hide-the-grub-menu-showing-up-at-the-beginning-of-boot

 
====

HIDE MEMTEST
https://askubuntu.com/questions/608632/how-can-i-remove-memtest-from-boot-menu


sudo chmod -x /etc/grub.d/20_memtest86+
sudo update-grub



==========

1. Run a bash script at system startup

http://www.upubuntu.com/2015/08/how-to-executerun-bash-script-at-system.html


Open the terminal and edit /etc/rc.local:

Add now your commands just before exit 0, then save your file and exit.


++
https://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local

sudo -iu username /usr/bin/screen -dmS test bash -c '/var/www/path/to/script/script.sh; exec bash'

mcedit /etc/rc.local

===
AES
CPUID
sudo apt install cpuid

https://www.cyberciti.biz/faq/how-to-find-out-aes-ni-advanced-encryption-enabled-on-linux-system/


h_@h_user-s002:  cpuid | grep -i aes | sort | uniq
      AES instruction                         = false
h_@h_user-s002: $

user@_014:~$ cpuid | more

   ====
  
TEMP

https://askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperature


sudo apt-get install lm-sensors

sudo sensors-detect
  
watch -n 1 sensors

sudo apt-get install acpi


use@_ ~$ acpi -V


====
BACKUP /RESTORE

https://wiki.archlinux.org/index.php/Partclone

Without compression
To backup without compression:

$ partclone.ext4 -c -s /dev/sda1 -o ~/image_sda1.pcl
To restore it:

$ partclone.ext4 -r -s ~/image_sda1.pcl -o /dev/sda1
With compression
To backup with compression:

$ partclone.ext4 -c -s /dev/sda1 | gzip -c > ~/image_sda1.pcl.gz
Note: For maximum compression use "gzip -c9"
To restore it:

zcat ~/image_sda1.pcl.gz | partclone.ext4 -r -o /dev/sda1


=====

===
VNC remote GUI

https://ubuntuforums.org/showthread.php?t=2329154
Don't expect Unity or any DE that requred 3D video card accel to work through VNC. Use xfce or lxde or a straight window-manager solution instead.

so

!!!
https://help.ubuntu.com/community/VNC/Servers

tightvncserver
Whereas most VNC servers share your desktop, tightvnc creates a completely new desktop,
not attached to any actual screen. This makes it much less useful for some things (like remote help),
but much more useful for others (like creating a public area for collaboration).

https://support.snel.com/902085-Install-VNC-on-Ubuntu-1604


#gui:

https://linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-16-04/

sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

#The text of your-preferred-session will depend on what desktop packages you have installed - which you can check by looking in the /usr/share/xsessions directory i.e.

#$ ls /usr/share/xsessions/
#awesome.desktop        gnome-classic.desktop  gnome-fallback.desktop
#gnome.desktop          gnome-shell.desktop     ubuntu-2d.desktop     xfce.desktop
#The xstartup file can also be used to start non-gnome desktop sessions, for example

if which startxfce4 > /dev/null; then
    exec startxfce4
fi

user@h_user-hh32:~$ ls /usr/share/xsessions/
gnome-classic.desktop  gnome.desktop  gnome-flashback-compiz.desktop  gnome-flashback-metacity.desktop  ubuntu.desktop
user@h_user-hh32:~$


#alter gui
https://community.time4vps.eu/discussion/31/install-gnome-desktop-environment-vnc-server

apt-get install gnome-core xfonts-100dpi xfonts-100dpi-transcoded xfonts-75dpi xfonts-75dpi-transcoded xfonts-base

#copy-paste
https://unix.stackexchange.com/questions/35030/how-can-i-copy-paste-data-to-and-from-the-windows-clipboard-to-an-opensuse-clipb
sudo apt install autocutsel

#server
apt-get install tightvncserver

vncserver

#set pass

vncserver -kill :1

#backup
mv ~/.vnc/xstartup ~/.vnc/xstartup.old; touch ~/.vnc/xstartup

#ex
mcedit ~/.vnc/xstartup

user@h_user-hh32:~$ cat ~/.vnc/xstartup
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
#x-window-manager --replace &
#gnome-session &
#vncconfig -iconic &
autocutsel -fork
gnome-session --session=gnome-classic &
gnome-panel &
#gnome-settings-daemon &
metacity &
nautilus &
x-terminal-emulator &
user@h_user-hh32:~$



# resolution
https://support.snel.com/902085-Install-VNC-on-Ubuntu-1604

mcedit ~/.vnc/tightvncserver.conf

$geometry = "1280x720";
$depth = 24;

#Replace 1280x720 with the resolution you would like to have like 1920x1080 for instance.


#set exec!

chmod +x /home/user/.vnc/xstartup
#or:
chmod u+x ~/.vnc/xstartup

#check

ll /home/user/.vnc/xstartup




#restart
vncserver

# showlog If errors
cat /home/user/.vnc/h_user-hh32:1.log



#check:

http://itautsors.ru/ubuntu-nastroyka-tightvncserver

ps aux | grep vnc


https://knowledgelayer.softlayer.com/learning/tightvnc-server-ubuntu-1604

user@user-M52LT-D3:~$ netstat -plan| grep Xtightvnc
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      1720/Xtightvnc
unix  2      [ ACC ]     STREAM     LISTENING     24327    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24402    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24357    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23280    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23301    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24338    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24367    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23265    1720/Xtightvnc      /tmp/.X11-unix/X1
user@user-M52LT-D3:~$


#add firewall rule
https://tqdev.com/2016-install-vnc-on-your-ubuntu-16-04

sudo apt-get install ufw
sudo ufw allow 22
sudo ufw allow 5901
sudo ufw enable


#tightvncpasswd
http://itautsors.ru/ubuntu-nastroyka-tightvncserver
пароль записывается в файл

/home/NameUser/.vnc/passwd
удалив этот файл, сбрасывается пароль

#!!!
https://askubuntu.com/questions/201263/shutdown-and-user-button-missing-in-panel

BTW, mouse over on an item, press Alt+RightClick, popup menu Move or Remove From Panel will be displayed



Adding Tightvnc to systemd startup
http://www.penguintutor.com/linux/tightvnc

sudo mcedit /etc/systemd/system/tightvncserver.service

[Unit]
Description=TightVNC remote desktop server
After=sshd.service

[Service]
Type=dbus
ExecStart=/usr/bin/tightvncserver :1
User=user
Type=forking

[Install]
WantedBy=multi-user.target


sudo chown root:root /etc/systemd/system/tightvncserver.service

sudo chmod 755 /etc/systemd/system/tightvncserver.service


====

Enable mouse in terminal
https://ubuntuforums.org/showthread.php?t=1002805

sudo apt-get install gpm

 
=====

on ubuntu 14.04
AMD

https://askubuntu.com/questions/815591/ubuntu-14-04-5-16-04-and-newer-on-amd-graphics

5. Downgrade Xorg
It may work, it may break your system until you reinstall the correct version.

However, if it does work, then you have fglrx back.

https://askubuntu.com/questions/676216/downgrade-xorg-server


downgrade your xserver-xorg to 1.16 in Ubuntu 14.04 by running

sudo apt-get install xserver-xorg-lts-utopic libqt5gui5 libgles1-mesa-lts-utopic libglehh-mesa-lts-utopic libgl1-mesa-glx-lts-utopic libgl1-mesa-glx-lts-utopic:i386 libglapi-mesa-lts-utopic:i386 libegl1-mesa-drivers-lts-utopic

check the version by dpkg -l | grep "ii  xserver-xorg-core"


====
FreeBSD
adduser 2 sshd

https://www.cyberciti.biz/tips/openssh-deny-or-restrict-access-to-users-and-groups.html


AllowUsers h_ useR

sudo mcedit /etc/ssh/sshd_config

https://envotechie.com/2010/10/28/password-login-ss-freebsd/

/etc/rc.d/sshd restart

+ sudo

https://www.cyberciti.biz/faq/how-to-add-delete-grant-sudo-privileges-to-users-on-freebsd-unix-server/

 alice All=(ALL) ALL
This will allow the user alice to issue sudo command and be root. It will first ask for her password. To skip asking for password when sudo command is issued, change the line to:

    alice ALL=(ALL) NOPASSWD: ALL
   
!!!as visudo = vi editor? prefer :

https://www.digitalocean.com/community/tutorials/how-to-add-and-remove-users-on-freebsd

sudo mcedit usr/local/etc/sudoers

20180228

#EXTRACT2

#v20190415:

sudo apt update && sudo apt -y upgrade && sudo apt install -y linux-headers-$(uname -r) build-essential dkms && sudo apt install -y coreutils mc htop traceroute netdiag screen tmux openssh-server ncdu p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 lm-sensors acpi gpm inxi gparted

LINUX_MINT:
sudo apt update && sudo apt upgrade -y && sudo apt install -y linux-headers-$(uname -r) build-essential dkms && sudo apt install -y coreutils mc htop traceroute netdiag screen tmux openssh-server ncdu p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 lm-sensors acpi gpm inxi gparted


ifconfig vs ip
https://p5r.uk/blog/2010/ifconfig-ip-comparison.html

Show network devices and configuration
ifconfig
ip addr show
ip link show

Enable a network interface
ifconfig eth0 up
ip link set eth0 up

Set IP address
ifconfig eth0 192.168.0.77
ip address add 192.168.0.77 dev eth0

ifconfig eth0 192.168.0.77 netmask 255.255.255.0 broadcast 192.168.0.255
ip addr add 192.168.0.77/24 broadcast 192.168.0.255 dev eth0

Show the routing table
route
ip route show



#20180829

vagrant@ubuntu-xenial:~$ mc
Failed to run:
Cannot create /home/vagrant/.config/mc directory

sudo chown -R vagrant:vagrant /home/vagrant/.config/

sudo chown -R vagrant:vagrant /home/vagrant/.local/





#201808**
on  clean install (ubuntu SERVER!!!!!)
https://www.wikihow.com/Add-or-Change-the-Default-Gateway-in-Linux

sudo route delete default

sudo route add default gw 192.168.1.254



#20180825
in linux mint LAST!!
https://www.linuxbabe.com/linux-server/how-to-enable-etcrc-local-with-systemd

sudo systemctl status rc-local

Active: failed

sudo nano /etc/systemd/system/rc-local.service

Then add the following content to it.

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target


sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
Output:

Created symlink from /etc/systemd/system/multi-user.target.wants/rc-local.service to /etc/systemd/system/rc-local.service.

Now start the service and check its status:

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service


!!!!!!!!!!!

Don’t forget the hashpling or `#!/bin/bash` in your rc.local !!
Missing this will cause an exec / format error.

!!!!!!!!!!

++

Force rc.local to wait for network

https://discourse.osmc.tv/t/force-rc-local-to-wait-for-network/11593/7

!!
if I add back sleep 10 to rc.local, everythink works correctly again on reboot.
!!
// via:   sudo systemctl status rc-local
--- error
"сер 25 20:55:28 hostname rc.local[694]: SIOCADDRT: Network is unreachable"



20190415
VINO: disable encryption:

https://askubuntu.com/questions/4474/enable-remote-vnc-from-the-commandline

On Ubuntu 14.04, I found the following variation worked for me:

export DISPLAY=:0
gsettings set org.gnome.Vino enabled true
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false
/usr/lib/vino/vino-server


check:
gsettings get org.gnome.Vino require-encryption



===================
===================
===================

vagrant@ubuntu-xenial:~$ nmcli dev show | grep 'DNS'
The program 'nmcli' is currently not installed. To run 'nmcli' please ask your administrator to install the package 'network-manager'

sudo apt install network-manager

====

4 vagrant
FORCE RESOLEON GOOGLE DNS

vagrant@ubuntu-xenial:~$ sudo mcedit /etc/dhcp/dhclient.conf

#add!
supersede domain-name-servers 8.8.8.8, 8.8.4.4;

RESTART NET:
vagrant@ubuntu-xenial:~$ sudo invoke-rc.d networking restart

CHECK:
vagrant@ubuntu-xenial:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
search  co.loc

vagrant@ubuntu-xenial:~$ nslookup go.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   go.com
Address: 23.236.60.174

vagrant@ubuntu-xenial:~$


===
HugePages

https://paolozaino.wordpress.com/2016/10/02/how-to-force-any-linux-application-to-use-hugepages-without-modifying-the-source-code/

quickly set:

sudo sysctl -w vm.nr_hugepages=128
grep Huge /proc/meminfo


Configure hugepages in kernel
https://kerneltalks.com/services/what-is-huge-pages-in-linux/

sudo mcedit /etc/sysctl.conf

Add
vm.nr_hugepages=128

and reload configuration by issuing
sudo sysctl -p

Use below command to check current state of hugepages
root@kerneltalks # cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

[always] flag in output shows that hugepages are enabled on system.

how do I enable transparent huge pages by default on ubuntu ?
https://stackoverflow.com/questions/16072389/how-do-i-enable-transparent-huge-pages-by-default-on-ubuntu

Adding the following:

transparent_hugepage=always
to GRUB_CMDLINE_LINUX_DEFAULT in your:

/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet nopti transparent_hugepage=always"

and doing a:
update-grub

===
https://www.massmux.com/optimal-configuration-xmrig-linux-monero-mining/
If your cpu supports hugepages, it’s better to enable them. The commands to do that are:

echo 128 > /proc/sys/vm/nr_hugepages

sysctl -w vm.nr_hugepages=128


====

determining my public IP?

https://askubuntu.com/questions/95910/command-for-determining-my-public-ip

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

curl ipinfo.io/ip

wget -qO- http://ipecho.net/plain ; echo

curl icanhazip.com

curl ipecho.net


====
WINDOWS:

http://www.itprotoday.com/windows-8/cool-things-do-netsh
netsh interface ip show config

netsh interface ip set dns "Ethernet" static 8.8.8.8

netsh interface ip set dns "Ethernet" source=dhcp



====
#4vnc

sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal


#addit packets^

sudo apt-get install indicator-applet-appmenu

sudo apt-get install autocutsel

sudo apt install xfonts-base xfonts-75dpi xfonts-100dpi


m@3:~$ ll /usr/share/fonts/X11/
total 80
drwxr-xr-x 8 root root  4096 Apr  9 13:35 ./
drwxr-xr-x 7 root root  4096 Aug  1  2017 ../
drwxr-xr-x 2 root root 20480 Apr  9 13:35 100dpi/
drwxr-xr-x 2 root root 20480 Apr  9 13:35 75dpi/
drwxr-xr-x 3 root root  4096 Aug  1  2017 encodings/
drwxr-xr-x 2 root root 20480 Aug  1  2017 misc/
drwxr-xr-x 2 root root  4096 Aug  1  2017 Type1/
drwxr-xr-x 2 root root  4096 Aug  1  2017 util/
m @ 3:~$


Step 4 — Creating a VNC Service File
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04

sudo nano /etc/systemd/system/vncserver@.service

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=sammy
PAMName=login
PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target


sudo systemctl daemon-reload

sudo systemctl enable vncserver@1.service

vncserver -kill :1

sudo systemctl start vncserver@1

sudo systemctl status vncserver@1


=============
============
============
=============


ntp.time.in.ua - основной сервер точного времени (stratum 1);
ntp2.time.in.ua - резервный сервер точного времени (stratum 1);
ntp3.time.in.ua - резервный сервер точного времени (stratum 2).

sudo ip route add default via 10.2.*.*



14^04^:
sudo route delete default

sudo route add default gw 10.2.*.*
(!!! without "ip" !!!! &&delete before !!!)
+  nmcli dev list | grep 'DNS'

======
DNS:
https://unix.stackexchange.com/questions/136117/ignore-dns-from-dhcp-server-in-ubuntu

s @ 22:~$ nmcli dev show | grep 'DNS'
IP4.DNS[1]:                             10.3
IP4.DNS[2]:                             10.3
IP4.DNS[3]:                             10.3
IP4.DNS[4]:                             10.3 2
su @ 2:~$


sudo mcedit /etc/dhcp/dhclient.conf

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

+++
How do I renew my DHCP lease?
https://askubuntu.com/questions/4014/how-do-i-renew-my-dhcp-lease
In the network drop-down selector from the system tray you can press the network you are already connected to,
- this will make network-manager ask for a new lease from a DHCP server.


====
LID CLOSE:
https://askubuntu.com/questions/15520/how-can-i-tell-ubuntu-to-do-nothing-when-i-close-my-laptop-lid

For 13.10 - 16.04:
To make Ubuntu do nothing when laptop lid is closed:

sudo mcedit /etc/systemd/logind.conf

HandleLidSwitch=ignore

sudo service systemd-logind restart


For 14.04:
sudo restart systemd-logind



====
DEFAULT_BOOT_WINDOWS

https://askubuntu.com/questions/52963/how-do-i-set-windows-to-boot-as-the-default-in-the-boot-loader

grep menuentry /boot/grub/grub.cfg

##!!! menuentry 'Windows 10 (loader) (on /dev/sda2)' -- - change to "Windows 10 (loader) (on /dev/sda2)"

sudo mcedit /etc/default/grub

sudo update-grub

///
m @ 3:~$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

#GRUB_DEFAULT=0
GRUB_DEFAULT="Windows 10 (loader) (on /dev/sda2)"
#GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet nopti"
#GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX="3"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
m @ 3:~$


!!!!!
in ubuntu 14.04
GRUB_CMDLINE_LINUX="text"

start GUI
service lightdgm start

sudo systemctl start lightdgm.service

====
VBOX ADDITIONS

https://www.vagrantup.com/docs/virtualbox/boxes.html


sudo apt-get install linux-headers-$(uname -r) build-essential dkms

# by using the GUI and clicking on "Devices" followed by "Install Guest Additions".

sudo mount /dev/cdrom /media/cdrom

sudo sh /media/cdrom/VBoxLinuxAdditions.run



=====

NTP

timedatectl

systemctl status systemd-timesyncd

sudo systemctl restart systemd-timesyncd

timedatectl status

https://help.ubuntu.com/lts/serverguide/NTP.html#timedatectl

sudo apt install ntp

https://www.digitalocean.com/community/tutorials/how-to-configure-ntp-for-use-in-the-ntp-pool-project-on-ubuntu-16-04

sudo mcedit /etc/ntp.conf

#comment
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

#add

server ntp.time.in.ua iburst
server ntp2.time.in.ua iburst
server ntp3.time.in.ua iburst

# http://time.in.ua/setup.html

# systemctl reload ntp.service

sudo systemctl restart ntp.service

systemctl status ntp.service

sudo ntpq -p


OR!!!

https://help.ubuntu.com/community/UbuntuTime

sudo dpkg-reconfigure tzdata


!!!
How to tell Ubuntu that hardware clock is local time?

https://askubuntu.com/questions/946516/how-to-tell-ubuntu-that-hardware-clock-is-local-time

In Ubuntu releases that use systemd the command to change time to local and update the clock right away is

timedatectl set-local-rtc 1 --adjust-system-clock

If you run timedatectl, it will show a warning

Warning: The system is configured to read the RTC time in the local time zone.
         This mode can not be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
This warning doesn't mean that it is set to 0, it suggests a command to switch it back to RTC.


RES:
m @ 2:~$ timedatectl
      Local time: Thu 2018-02-01 19:52:46 EET
  Universal time: Thu 2018-02-01 17:52:46 UTC
        RTC time: Thu 2018-02-01 19:52:46
       Time zone:  ****
 Network time on: yes
NTP synchronized: no
 RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode can not be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.
user@_012:~$



====
BASH COMPLETION
https://askubuntu.com/questions/86375/apt-get-autocomplete-package-name-is-broken


sudo apt-get install bash-completion command-not-found

apt-get -y install coreutils mc htop nethogs traceroute netdiag ncdu \
p7zip-rar p7zip-full unace unrar zip unzip sharutils uudeview mpack arj cabextract file-roller lbzip2 \
android-tools-adb android-tools-fastboot


=====
SHUTDOWN AT TIME

sudo shutdown -h 06:00
#- will work fine, no need to run it in the background.
#Add the command at the end of /etc/rc.local (or /etc/rc.d/rc.local depending on your system) for execution in the last startup script.

# The advantage of not using cron is that in this way the shutdown remains scheduled during the day, and you can cancel it at any time by typing

#shutdown -c

user@_014:~$ sudo shutdown -h 21:40
Shutdown scheduled for пн 2018-01-29 21:40:00 EET, use 'shutdown -c' to cancel.
user@_014:~$
 
=====
WINDOWS SET IP DNS CLI

netsh interface ip set dns "Ethernet" source=dhcp

netsh interface ip set dns "Ethernet" static 10.3*.*
netsh interface ip set dns "Ethernet" static 8.8.8.8

netsh interface ip show config "Ethernet"




C:\Users\Admin>

 
====
GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"

https://gist.github.com/LeahCim/9332432

https://askubuntu.com/questions/633175/grub-wait-time-10-seconds-after-editing-to-0-in-etc-default-grub/635960#635960


add the files /etc/grub.d/25_pre-os-prober and /etc/grub.d/35_post-os-prober.

25_pre-os-prober:
#! /bin/sh
# file: /etc/grub.d/25_pre-os-prober
set -e

# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.

cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF
35_post-os-prober
#! /bin/sh
# file: /etc/grub.d/35_post-os-prober
set -e

# Reset $timeout and $timeout_style to their original values
# set by /etc/grub.d/00_header before /etc/grub.d/30_os-prober messed them up.

cat << EOF
set timeout=\${timeout_bak}
set timeout_style=\${timeout_style_bak}
EOF

+++


GRUB_TIMEOUT_STYLE=hidden

https://askubuntu.com/questions/111085/how-do-i-hide-the-grub-menu-showing-up-at-the-beginning-of-boot

 
====

HIDE MEMTEST
https://askubuntu.com/questions/608632/how-can-i-remove-memtest-from-boot-menu


sudo chmod -x /etc/grub.d/20_memtest86+
sudo update-grub



==========

1. Run a bash script at system startup

http://www.upubuntu.com/2015/08/how-to-executerun-bash-script-at-system.html


Open the terminal and edit /etc/rc.local:

Add now your commands just before exit 0, then save your file and exit.


++
https://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local

sudo -iu username /usr/bin/screen -dmS test bash -c '/var/www/path/to/script/script.sh; exec bash'

mcedit /etc/rc.local

===
AES
CPUID
sudo apt install cpuid

https://www.cyberciti.biz/faq/how-to-find-out-aes-ni-advanced-encryption-enabled-on-linux-system/


h_@h_user-s002:  cpuid | grep -i aes | sort | uniq
      AES instruction                         = false
h_@h_user-s002: $

user@_014:~$ cpuid | more

   ====
  
TEMP

https://askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperature


sudo apt-get install lm-sensors

sudo sensors-detect
  
watch -n 1 sensors

sudo apt-get install acpi


use@_ ~$ acpi -V


====
BACKUP /RESTORE

https://wiki.archlinux.org/index.php/Partclone

Without compression
To backup without compression:

$ partclone.ext4 -c -s /dev/sda1 -o ~/image_sda1.pcl
To restore it:

$ partclone.ext4 -r -s ~/image_sda1.pcl -o /dev/sda1
With compression
To backup with compression:

$ partclone.ext4 -c -s /dev/sda1 | gzip -c > ~/image_sda1.pcl.gz
Note: For maximum compression use "gzip -c9"
To restore it:

zcat ~/image_sda1.pcl.gz | partclone.ext4 -r -o /dev/sda1


=====

===
VNC remote GUI

https://ubuntuforums.org/showthread.php?t=2329154
Don't expect Unity or any DE that requred 3D video card accel to work through VNC. Use xfce or lxde or a straight window-manager solution instead.

so

!!!
https://help.ubuntu.com/community/VNC/Servers

tightvncserver
Whereas most VNC servers share your desktop, tightvnc creates a completely new desktop,
not attached to any actual screen. This makes it much less useful for some things (like remote help),
but much more useful for others (like creating a public area for collaboration).

https://support.snel.com/902085-Install-VNC-on-Ubuntu-1604


#gui:

https://linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-16-04/

sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

#The text of your-preferred-session will depend on what desktop packages you have installed - which you can check by looking in the /usr/share/xsessions directory i.e.

#$ ls /usr/share/xsessions/
#awesome.desktop        gnome-classic.desktop  gnome-fallback.desktop
#gnome.desktop          gnome-shell.desktop     ubuntu-2d.desktop     xfce.desktop
#The xstartup file can also be used to start non-gnome desktop sessions, for example

if which startxfce4 > /dev/null; then
    exec startxfce4
fi

user@h_user-hh32:~$ ls /usr/share/xsessions/
gnome-classic.desktop  gnome.desktop  gnome-flashback-compiz.desktop  gnome-flashback-metacity.desktop  ubuntu.desktop
user@h_user-hh32:~$


#alter gui
https://community.time4vps.eu/discussion/31/install-gnome-desktop-environment-vnc-server

apt-get install gnome-core xfonts-100dpi xfonts-100dpi-transcoded xfonts-75dpi xfonts-75dpi-transcoded xfonts-base

#copy-paste
https://unix.stackexchange.com/questions/35030/how-can-i-copy-paste-data-to-and-from-the-windows-clipboard-to-an-opensuse-clipb
sudo apt install autocutsel

#server
apt-get install tightvncserver

vncserver

#set pass

vncserver -kill :1

#backup
mv ~/.vnc/xstartup ~/.vnc/xstartup.old; touch ~/.vnc/xstartup

#ex
mcedit ~/.vnc/xstartup

user@h_user-hh32:~$ cat ~/.vnc/xstartup
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
#x-window-manager --replace &
#gnome-session &
#vncconfig -iconic &
autocutsel -fork
gnome-session --session=gnome-classic &
gnome-panel &
#gnome-settings-daemon &
metacity &
nautilus &
x-terminal-emulator &
user@h_user-hh32:~$



# resolution
https://support.snel.com/902085-Install-VNC-on-Ubuntu-1604

mcedit ~/.vnc/tightvncserver.conf

$geometry = "1280x720";
$depth = 24;

#Replace 1280x720 with the resolution you would like to have like 1920x1080 for instance.


#set exec!

chmod +x /home/user/.vnc/xstartup
#or:
chmod u+x ~/.vnc/xstartup

#check

ll /home/user/.vnc/xstartup




#restart
vncserver

# showlog If errors
cat /home/user/.vnc/h_user-hh32:1.log



#check:

http://itautsors.ru/ubuntu-nastroyka-tightvncserver

ps aux | grep vnc


https://knowledgelayer.softlayer.com/learning/tightvnc-server-ubuntu-1604

user@user-M52LT-D3:~$ netstat -plan| grep Xtightvnc
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      1720/Xtightvnc
unix  2      [ ACC ]     STREAM     LISTENING     24327    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24402    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24357    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23280    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23301    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24338    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     24367    1720/Xtightvnc      /tmp/.X11-unix/X1
unix  3      [ ]         STREAM     CONNECTED     23265    1720/Xtightvnc      /tmp/.X11-unix/X1
user@user-M52LT-D3:~$


#add firewall rule
https://tqdev.com/2016-install-vnc-on-your-ubuntu-16-04

sudo apt-get install ufw
sudo ufw allow 22
sudo ufw allow 5901
sudo ufw enable


#tightvncpasswd
http://itautsors.ru/ubuntu-nastroyka-tightvncserver
пароль записывается в файл

/home/NameUser/.vnc/passwd
удалив этот файл, сбрасывается пароль

#!!!
https://askubuntu.com/questions/201263/shutdown-and-user-button-missing-in-panel

BTW, mouse over on an item, press Alt+RightClick, popup menu Move or Remove From Panel will be displayed



Adding Tightvnc to systemd startup
http://www.penguintutor.com/linux/tightvnc

sudo mcedit /etc/systemd/system/tightvncserver.service

[Unit]
Description=TightVNC remote desktop server
After=sshd.service

[Service]
Type=dbus
ExecStart=/usr/bin/tightvncserver :1
User=user
Type=forking

[Install]
WantedBy=multi-user.target


sudo chown root:root /etc/systemd/system/tightvncserver.service

sudo chmod 755 /etc/systemd/system/tightvncserver.service


====

Enable mouse in terminal
https://ubuntuforums.org/showthread.php?t=1002805

sudo apt-get install gpm

 
=====

on ubuntu 14.04
AMD

https://askubuntu.com/questions/815591/ubuntu-14-04-5-16-04-and-newer-on-amd-graphics

5. Downgrade Xorg
It may work, it may break your system until you reinstall the correct version.

However, if it does work, then you have fglrx back.

https://askubuntu.com/questions/676216/downgrade-xorg-server


downgrade your xserver-xorg to 1.16 in Ubuntu 14.04 by running

sudo apt-get install xserver-xorg-lts-utopic libqt5gui5 libgles1-mesa-lts-utopic libglehh-mesa-lts-utopic libgl1-mesa-glx-lts-utopic libgl1-mesa-glx-lts-utopic:i386 libglapi-mesa-lts-utopic:i386 libegl1-mesa-drivers-lts-utopic

check the version by dpkg -l | grep "ii  xserver-xorg-core"


====
FreeBSD
adduser 2 sshd

https://www.cyberciti.biz/tips/openssh-deny-or-restrict-access-to-users-and-groups.html


AllowUsers h_ useR

sudo mcedit /etc/ssh/sshd_config

https://envotechie.com/2010/10/28/password-login-ss-freebsd/

/etc/rc.d/sshd restart

+ sudo

https://www.cyberciti.biz/faq/how-to-add-delete-grant-sudo-privileges-to-users-on-freebsd-unix-server/

 alice All=(ALL) ALL
This will allow the user alice to issue sudo command and be root. It will first ask for her password. To skip asking for password when sudo command is issued, change the line to:

    alice ALL=(ALL) NOPASSWD: ALL
   
!!!as visudo = vi editor? prefer :

https://www.digitalocean.com/community/tutorials/how-to-add-and-remove-users-on-freebsd

sudo mcedit usr/local/etc/sudoers

20160628

NAS for ESXI Backup Solutions free

1. Backup Solutions for Free ESXi
http://www.virten.net/2016/04/backup-solutions-for-free-esxi/
http://blog.erben.sk/2014/05/30/vmware-backup-script/

2. http://www.vladan.fr/how-to-configure-freenas-8-for-iscsi-and-connect-to-esxi/

(2a!!)
http://www.vladan.fr/how-to-backup-esxi-4-1-configuration/
http://www.vladan.fr/free-esxi-configuration-backup-tool/

3. choose NAS:: nas4free vs freeNAS vs Openfiler

http://www.freenas.org/freenas-vs-openfiler/
http://www.freenas.org/freenas-vs-nas4free/

NAS4Free vs FreeNAS
http://www.nas4free.org/forums/viewtopic.php?t=5702
http://arstechnica.com/information-technology/2014/06/the-ars-nas-distribution-shootout-freenas-vs-nas4free/
=====
concl:
Openfiler - linux (so NO!)
nas4free vs freeNAS - freeBSD - OK!
but freeNAS - min.reqRAM=8G!
-- so nas4free (min 512M! :) - without ZFS - not req!

4. :)
http://wiki.nas4free.org/doku.php?id=documentation:howto:create_iscsi_target_from_zfs_volume

20160503

open putty from CMD

C:\Users\Admin>putty -ssh android@192.168.42.129 -pw changeme

#EXTRACT

.v20160503
http://source.android.com/source/initializing.html


sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y install linux-headers-$(uname -r) build-essential dkms && sudo apt-get -y install open-vm-tool* 

gsettings set com.canonical.desktop.interface scrollbar-mode normal 


#minimal CLI / Debian / LD: 
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y install linux-headers-$(uname -r) build-essential dkms

sudo apt-get -y install coreutils mc indicator-multiload htop \
nethogs traceroute netdiag meld gparted synaptic \
p7zip-rar p7zip-full unace unrar zip unzip sharutils rar \
uudeview mpack arj cabextract file-roller lbzip2 \
gnome-disk-utility ncdu default-jre inxi \
android-tools-adb android-tools-fastboot

#minimal CLI / Debian / LD:
sudo apt-get -y install coreutils mc htop \nethogs traceroute netdiag meld gparted synaptic \
p7zip-rar p7zip-full unace unrar zip unzip sharutils \
uudeview mpack arj cabextract file-roller lbzip2 \
gnome-disk-utility ncdu default-jre inxi

wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules

sudo apt-get -y install openjdk-6-jdk && sudo apt-get -y install openjdk-7-jdk && sudo apt-get -y install openjdk-8-jdk

sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java6-installer 

#manual YES&YES 

sudo apt-get -y install oracle-java7-installer && sudo apt-get -y install oracle-java8-installer

sudo apt-get -y autoremove && sudo apt-get -y autoclean

# cleanUP disk for VMs (Ubuntu):

sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY


#Build essentials:

sudo apt-get -y install bison build-essential curl flex g++-multilib gcc-multilib \
git-core gnupg gperf lib32ncurses5-dev libreadline-gplv2-dev \
lib32z1-dev libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev \
libxml2 libxml2-utils lzop make pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev \
libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libswitch-perl clang

#set CCACHE 

ccache -M 20G

#check

ccache -s

sudo update-java-alternatives -l
ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar

#manual set: 

sudo update-alternatives --config java
sudo update-alternatives --config javac


#============
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo
echo "export PATH=~/bin:$PATH" >> ~/.bashrc
echo "export USE_CCACHE=1" >> ~/.bashrc

git config --global user.email ubuntu.devma@gmail.com
git config --global user.name ubuntu-devma

#check
git config --global -l

#=================
#INITS:

#4.3:
repo init -u git://codeaurora.org/platform/manifest.git -b release -m LNX.LA.3.2.1.3-12000-8x10.0.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable 2>&1 >> sync.log
#----------------------------------------------------
repo init -u git://codeaurora.org/platform/manifest.git -b release -m  LNX.LA.3.5.1-09810-8x10.0.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable 2>&1 >> sync.log
------------------------------------------------------

#=======

repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r2.0.1 | tee -a sync.log
#----------------------------

#CM: https://github.com/CyanogenMod/android

repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0 2>&1 | tee -a sync.log 

#----------------------------
#OMNI: https://github.com/omnirom/android

repo init -u https://github.com/omnirom/android.git -b android-6.0 2>&1 | tee -a sync.log

#-----
#a minimal tree for building TWRP

https://github.com/marduk191/recovery_manifest/tree/android-5.0
#----------------------------

#miui: https://github.com/MiCode/patchrom
 
repo init -u git://github.com/MiCode/patchrom.git -b miui-7 -m android-4.4.4.xml

#check
repo list
repo info -o
git --git-dir .repo/manifests/.git/ branch -a

#SYNC:
date && date >> sync.log && ifconfig >> sync.log && /usr/bin/time -f "Total time: %E" repo sync -j8 2>&1 | tee -a sync.log && date >> sync.log && ifconfig >> sync.log && date#
#==========
#ARCHIVING:
##RAW: -m0=LZMA2 -mmt=4(move .repo in another place before!):
CURR=`basename "$PWD"`;DATE=`date +%Y%m%d`;/usr/bin/time -f "Total time: %E" 7z a -t7z -m0=LZMA2 -mmt=4 $CURR.LZMA2.mmt4.raw.$DATE.7z * 2>&1 | tee -a $CURR.LZMA2.mmt4.raw.$DATE.7z.arch.log && 7z a -t7z $CURR.LZMA2.mmt4.raw.$DATE.7z.arch.log.7z $CURR.LZMA2.mmt4.raw.$DATE.7z.arch.log sync.log && rm $CURR.LZMA2.mmt4.raw.$DATE.7z.arch.log sync.log

##4DOT.REPO only:

CURR=`basename "$PWD"`;DATE=`date +%Y%m%d`;/usr/bin/time -f "Total time: %E" 7z a -t7z -m0=Copy -mx=0 $CURR.mx0.dot.repo.$DATE.7z .repo 2>&1 | tee -a $CURR.mx0.dot.repo.$DATE.arch.log

#++++++++++++++++++++

fc -ln -1 > command.txt

#======
#EXTRACT (.repo arhive expmple):

7z x -o/home/tusty/cm-11.0 cm11.mx0.dot.repo.7z

#======
#MAKE inztallable zip (on base of stock zip):

7z a c230wCWM6051RecoveryFlasher.zip -mx=0 ./*

#================================
#RUN compiling:

source ./build/envsetup.sh

lunch

#CAF: choosecombo

#lunch omni_C230w-eng

#bootimage
RUN=`date +%m%d%H%M%S` && date && date >> make.$RUN.log && /usr/bin/time -f "Total time: %E" make -j4 bootimage 2>&1 | tee -a make.$RUN.log && date >> make.$RUN.log && date

#recoveryimage  
RUN=`date +%H%M%S` && date && date >> make.$RUN.log && /usr/bin/time -f "Total time: %E" make -j4 recoveryimage 2>&1 | tee -a make.$RUN.log && date >> make.$RUN.log && date

#with DAY date +%m%d
RUN=`date +%m%d%H%M%S` && date && date >> make.$RUN.log && /usr/bin/time -f "Total time: %E" make -j4 recoveryimage 2>&1 | tee -a make.$RUN.log && date >> make.$RUN.log && date

###--------

make clean

# =======
#EXAMPLE: vendorsetup.sh

for i in eng userdebug user; do
add_lunch_combo cm_goldfish-${i}
done
--
for i in eng userdebug user; do
add_lunch_combo full_C230w-${i}
done

=====
#EXTRACT.v20160503

#EXTRACT4 ubuntu server

server 202011 #EXTRACT4: enable the “partner” repository: https://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository sud...