Salt Bootstrap is a shell script that detects the target platform and selects the best installation method. (Supported Platforms)


Run these commands on the system that you want to use as the central management point.

curl -L -o
sudo sh -P -M

Your Salt master can manage itself, so a Salt minion is installed along with the Salt master. If you do not want to install the minion, also pass the -N option.


Run these commands on each system that you want to manage using Salt.

curl -L -o
sudo sh -P

OEM installation and image Ubuntu 18.04

You can boot the Ubuntu installer in OEM mode to achieve the result you are after.

When you boot the installation media, hit SHIFT to get to the installation menu, then hit F4 and select ‘OEM Install’.
When Ubuntu has finished booting install the system as usual, you will be prompted for a temporary username and password.

When installation has finished, boot the system and log on with the temporary username and password you created earlier, you can now make any other alterations to the system that you want, for example installing extra software. When you’re all done just double-click on the ‘Prepare for shipping to end user’ icon on the desktop and then shut down the machine, it’s now time to take your image of the drive.

Next time the machine is booted the user will be asked to set up their account.

Enable remote desktop on ubuntu 16.04

This article explains how to enable remote desktop on ubuntu 16.04 server and cloud versions. Maybe it can be used for desktop versions.
We are going to use VNC package to enable remote desktop connection. So here we can see about installing and configuring VNC service on ubuntu 16.04.

Package installation

First of all we have to install ubuntu desktop and supported packages in order to enable remote desktop on ubuntu server.
So we are going to install ubuntu desktop environment with minimal packages to keeps your server lightweight.
Step 1 » Let’s start. Update the repositories and start installing packages with minimal option. It would take some time to complete.
krizna@leela:~$ sudo apt update
–no-install-recommends key is used to ignore most of all default softwares. So therefore below command only install base packages which is really needed for GUI.
krizna@leela:~$ sudo apt install --no-install-recommends ubuntu-desktop
Step 2 » Now install some additional gnome packages. Most probably these packages will give you best ubuntu look.
krizna@leela:~$ sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
Step 3 » And finally install vnc4server package.
krizna@leela:~$ sudo apt install vnc4server

Enable remote desktop on ubuntu 16.04

Step 4 » Create a backup of the original vncserver file so that you can restore in case of any issues.
krizna@leela:~$sudo cp /usr/bin/vncserver /usr/bin/vncserver.bkp
Step 5 » And now edit /usr/bin/vncserver file as below.
Find this line
"# exec /etc/X11/xinit/xinitrc\n\n".And add these lines below.
"gnome-session &\n".
"gnome-panel &\n".
"gnome-settings-daemon &\n".
"metacity &\n".
"nautilus &\n".
"gnome-terminal &\n".

Step 5 » Now login as the user and type “vncserver” command to create vnc password and as well as it enables VNC session.
harry@leela:~$ vncserver
You will require a password to access your desktops.
xauth: file /home/harry/.Xauthority does not exist
New 'leela:1 (harry)' desktop is leela:1
Creating default startup script /home/harry/.vnc/xstartup
Starting applications specified in /home/harry/.vnc/xstartup
Log file is /home/harry/.vnc/leela:1.log

Step 6 » So now VNC session is started with session number 1.
Enable remote desktop on ubuntu

You can access using VNC client ( TightVNC ) with ServerIP:sessionnumber ( Ex: ) .

Probably you can have multiple sessions by issuing “vncserver” command multiple times and Also you can access using session numbers, :3 and so on.
Enable remote desktop on ubuntu 16.04

Remote desktop as service

In addition we can configure VNC session as services so that it would start sessions automatically while rebooting the server.
Step 7 » Create service file vncharry@1.service under /etc/systemd/system/ and add below lines.
Replace user name with yours.
So if you want multiple sessions, you need to create another file with same content and have another session number vncharry@2.service.

Step 8 » Start the service and check the status. Before starting the service you must create VNC session password by using “vncserver” or “vncpasswd” command as the user( Refer step 5 ).
krizna@leela:~$ sudo systemctl daemon-reloadkrizna@leela:~$ sudo systemctl start vncharry@1.service
Now check the status . It Should be active and running.
krizna@leela:~# sudo systemctl status vncharry@1.service
● vncharry@1.service - Start TightVNC server at startup
Loaded: loaded (/etc/systemd/system/vncharry@1.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2017-03-29 12:23:18 IST; 3min 47s ago
Process: 2205 ExecStart=/usr/bin/vncserver -depth 24 :%i (code=exited, status=0/SUCCESS)
Process: 2189 ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1 (code=exited, status=2)
Main PID: 2228 (Xvnc4)
CGroup: /system.slice/system-vncharry.slice/vncharry@1.service
‣ 2228 Xvnc4 :1 -desktop leela:1 (harry) -auth /home/harry/.Xauthority -geometry 1024x768 -depth 24 -rfbwait 30000 -rfbauth /home/harry/.vnc/passwd -rfbport 5901 -pn -fp /usr/X
Mar 29 12:23:15 leela systemd[1]: Starting Start TightVNC server at startup...
Mar 29 12:23:15 leela systemd[2189]: pam_unix(login:session): session opened for user harry by (uid=0)

Step 9 » Finally issue below command to make it auto start while reboot.
krizna@leela:~$ sudo systemctl enable vncharry@1.service
Created symlink from /etc/systemd/system/ to /etc/systemd/system/vncharry@1.service.

Now the session will be started automatically after the reboot.

Few additional commands

» Restart session using service. You can issue stop and start with the same command.
krizna@leela:~$ sudo systemctl restart vncharry@1.service
» In order to kill particular session manually
harry@leela:~$ vncserver -kill :1
Killing Xvnc4 process ID 1137

» You can set custom screen resolution using -geometry 1280×1024
harry@leela:~$ vncserver -geometry 1280x1024[or]
In the service file edit Execstart line as below
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x1024 :%I
As a result remote desktop window is viewed in 1280×1024 resolution.
» You can reset vnc password using vncpasswd command
harry@leela:~$ vncpasswd

That’s it
Have a good day.


Quickly copy a GPT partition scheme from one hard drive to another?

On a non GPT partition table I can do

sfdisk -d /dev/sda | sfdisk /dev/sdb.

But sfdisk doesn’t support GPT partition tables. What can I use instead?

Solution for GPT:

Install gdisk which is available in the Ubuntu Universe repositories.

Then use the sgdisk command (man page here) to replicate the partition table:

sgdisk /dev/sdX -R /dev/sdY 
sgdisk -G /dev/sdY

The first command copies the partition table of sdX to sdY (be careful not to mix these up). The second command randomizes the GUID on the disk and all the partitions. This is only necessary if the disks are to be used in the same machine, otherwise it’s unnecessary.



Create RAID with LVM

Many Linux users have created RAID arrays using mdadm and do not realize that you can also create a RAID array without it by using LVM.

Installing LVM

You may need to install the LVM packages in order to build these arrays.

sudo apt-get install lvm2  

Creating RAID 0

sudo vgcreate [vg name] /dev/sd[x]1 /dev/sd[x2]1 ...
lvcreate -i[num drives] -I[strip size] -l100%FREE -n[lv name] [vg name]
sudo mkfs.[ext4/xfs] /dev/[vg name]/[lv name]
  • Stripe size needs to be a number of the power 2, starting with 4. E.g. 4, 8, 16, 32, 64. If your data is mostly small text files, then use 4. If you are mostly dealing with media then you may want something larger.
  • If you want to use the xfs filesystem, you may need to install xfprogs with sudo apt-get install xfsprogs -y

Creating this RAID array will remove the ability to remove a drive from the VOLUME group later.

Creating RAID 1 (Mirror)


sudo vgcreate vg1 /dev/sd[x]1 /dev/sd[x]1

sudo lvcreate \
--mirrors 1 \
--type raid1 \
-l 100%FREE \
--nosync \

sudo mkfs.[ext4/xfs] /dev/$VG_NAME/$LV_NAME

Creating RAID 5 (Parity)


sudo vgcreate vg1 /dev/sd[x]1 /dev/sd[x]1 /dev/sd[x]1

sudo lvcreate \
--type raid5 \
-l 100%FREE \
--nosync \

sudo mkfs.[ext4/xfs] /dev/$VG_NAME/$LV_NAME

How to Enable /etc/rc.local with Systemd

f you are running a Linux distro that use Systemd, then you may find that your command in /etc/rc.local file would not run on system boot. This guide explains how to enable /etc/rc.local script to run on system start.

The problem

If you type the following command in terminal:

sudo systemctl status rc-local

You may get this output:


● rc-local.service - /etc/rc.local Compatibility
 Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
 Active: failed (Result: exit-code) since Thu 2015-11-26 23:54:58 CST; 59s ago
 Process: 1001 ExecStart=/etc/rc.local start (code=exited, status=1/FAILURE)
Nov 26 23:54:57 vivid rc.local[1001]: File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 920, in require
Nov 26 23:54:57 vivid rc.local[1001]: needed = self.resolve(parse_requirements(requirements))
Nov 26 23:54:57 vivid rc.local[1001]: File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 807, in resolve
Nov 26 23:54:57 vivid rc.local[1001]: raise DistributionNotFound(req)
Nov 26 23:54:57 vivid rc.local[1001]: pkg_resources.DistributionNotFound: shadowsocks==2.8.2
Nov 26 23:54:58 vivid sudo[1008]: pam_unix(sudo:session): session closed for user root
Nov 26 23:54:58 vivid systemd[1]: rc-local.service: control process exited, code=exited status=1
Nov 26 23:54:58 vivid systemd[1]: Failed to start /etc/rc.local Compatibility.
Nov 26 23:54:58 vivid systemd[1]: Unit rc-local.service entered failed state.
Nov 26 23:54:58 vivid systemd[1]: rc-local.service failed.

And if you try to enable /etc/rc.local to run on system boot with the command:

sudo systemctl enable rc-local

You may get:

The unit files have no [Install] section. They are not meant to be enabled
 using systemctl.
 Possible reasons for having this kind of units are:
 1) A unit may be statically enabled by being symlinked from another unit's
 .wants/ or .requires/ directory.
 2) A unit's purpose may be to act as a helper for some other unit which has
 a requirement dependency on it.
 3) A unit may be started when needed via activation (socket, path, timer,
 D-Bus, udev, scripted systemctl call, ...).

The solution

As you can see from above, The unit file have no [Install] section. As such Systemd can not enable it. First we need to create a file:

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

Then add the following content to it.

 Description=/etc/rc.local Compatibility

 ExecStart=/etc/rc.local start


Save and close the file. Make sure /etc/rc.local file is executable.

sudo chmod +x /etc/rc.local

After that, enable the service on system boot:

sudo systemctl enable rc-local


Created symlink from /etc/systemd/system/ 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


● rc-local.service - /etc/rc.local Compatibility
 Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
 Active: active (running) since Fri 2015-11-27 00:32:56 CST; 14min ago
 Process: 879 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
 Main PID: 880 (watch)
 CGroup: /system.slice/rc-local.service

Cron @reboot

If the above method does not work for you, or you just want some simple commands to be executed on system boot, then you can also use the @reboot feature in cron to automatically execute command on system boot. For example, I want my shadowsocks client to auto start, so I open the root user’s cron file:

sudo crontab -e

And put the following line at the end of it.

@reboot /usr/bin/sslocal -c /etc/shadowsocks.json -d start

Save and close the file.

In some Linux distributions such as archlinux, the cron daemon is not enabled by default. So you have to manually enable it. To enable it on archlinux, enter the following command in the terminal.

sudo systemctl enable cronie

Shadowsocks is a socks5 proxy that can be used to bypass Internet firewalls, If you are interested, click the link below to learn how to setup your own shadowsocks server.

Setup your own shadowsocks server on Debian, Ubuntu and Centos