How do I remove old kernel versions to clean up the boot menu

When running a Ubuntu instance with limited disc space, the /boot can get filled with old (obsolete) kernels. If you run out of disk space on /boot, this is hou to clean up space.

First make sure there is still about 20 percent of disk space left on /boot by removing old kernel files (pick the large ones, but don’t delete the files with the highest kernel version !!)

If needed, fix any pending updates :
sudo apt-get install -f

Now run this command to “cleanup” old kernel versions :
dpkg –list|grep linux-image|awk ‘{print $2}’|sort -V|sed -n ‘/’`uname -r`’/q;p’|xargs sudo apt-get -y purge

Only uname -r is between quotes on ~ key, rest are regular single quotes

greetz, M.

Fix date time missing in the menu bar in Ubuntu 14.04

Open a terminal and use the command given below. This is optional and just to make sure that you have the indicator installed already.

sudo apt-get install indicator-datetime

Once we have made sure that the indicator is installed, next step is to reconfigure it:

sudo dpkg-reconfigure --frontend noninteractive tzdata

And the last step is to restart Unity:

sudo killall unity-panel-service

That should be it. Now the date time should be appearing in the top panel.

Greetz, M.

Move or migrate user accounts from old Linux server to a new Linux server

in BASH Shell, CentOS, Debian / Ubuntu

Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.

A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.

Following files/dirs are required for traditional Linux user management:
* /etc/passwd – contains various pieces of information for each user account
* /etc/shadow – contains the encrypted password information for user’s accounts and optional the password aging information.
* /etc/group – defines the groups to which users belong
* /etc/gshadow – group shadow file (contains the encrypted password for group)
* /var/spool/mail – Generally user emails are stored here.
* /home – All Users data is stored here.

You need to backup all of the above files and directories from old server to new Linux server.
Commands to type on old Linux system

First create a tar ball of old uses (old Linux system). Create a directory:
# mkdir /root/move/

Setup UID filter limit:
# export UGIDLIMIT=1000

Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > /root/move/passwd.mig

Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/group > /root/move/group.mig

Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534) {print $1}’ /etc/passwd | tee – |egrep -f – /etc/shadow > /root/move/shadow.mig

Copy /etc/gshadow (rarely used):
# cp /etc/gshadow /root/move/gshadow.mig

Make a backup of /home and /var/spool/mail dirs:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail


  • Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:

RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).

Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).

  • You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.
  • export UGIDLIMIT=500 – setup UID start limit for normal user account. Set this value as per your Linux distro.
  • awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > /root/move/passwd.mig – You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.
  • tar -zcvpf /root/move/home.tar.gz /home – Make a backup of users /home dir
  • tar -zcvpf /root/move/mail.tar.gz /var/spool/mail – Make a backup of users mail dir

Use scp or usb pen or tape to copy /root/move to a new Linux system.
# scp -r /root/move/*

Commands to type on new Linux system

First, make a backup of current users and passwords:
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

Now restore passwd and other files in /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow

Please note that you must use >> (append) and not > (create) shell redirection.

Now copy and extract home.tar.gz to new server /home
# cd /
# tar -zxvf /path/to/location/home.tar.gz

Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
# cd /
# tar -zxvf /path/to/location/mail.tar.gz

Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:
# reboot

Please note that if you are new to Linux perform above commands in a sandbox environment. Above technique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of changes but overall the concept remains the same.

Greetz, M.

Linux Commands In Structured Order with Detailed Reference

Linux command shelf is a quick reference guide for all linux user who wish to learn linux commands. Commands are divided into 15 categories , which would be more easier to understand what commands to be used in specific requirement. – See more at: LinOxide (you can also download Linux command shelf and Linux cheat sheet as a PDF).
Greetz, M.

Ping with timestamp

When running a ping command for a longer time to trace timeouts, it is hard to determine the actual date and time the timeout occurred.

Using a simple Bash script will solve this issue.

while :
	ping -c 10

This will ping the localhost address ten times and then print date and time. After that the script starts over (infinite loop).

Greetz, M.

Update Samba 3.6 in Ubuntu 12.04

Ubuntu 12.04 LTS is stuck on Samba 3.6.3 which has a lot of bugs. A lot of these have already been solved by the Samba development team, but the new releases are not available in the Ubuntu 12.04 LTS repository.

To update Samba, add the nathan-renniewaldock PPA to your system by entering these commands :

sudo add-apt-repository ppa:nathan-renniewaldock/ppa
sudo apt-get update

Now you can update Samba to version 3.6.7 (especially Windows XP winbind issues which cause Samba crashes)

Greetz, M.

Install latest stable Linux kernel in Ubuntu 12.04

Ubuntu 12.04 LTS is running a kernel from the 3.2 branch.

Newer stable kernel branches are 3.4, 3.5, 3.6 and the newest 3.7. Check the Linux Kernel Archives and the Linux kernel Wiki for the latest information about supported versions / branches.

When installing the latest kernel for Ubuntu, download it from the Ubuntu kernel-ppa/mainline. I used the v3.7.6-raring kernel (latest stable at the time).

Download 32-bit or 64-bit version of headers, image and image-extra plus headers-all file.

Open a terminal and execute : sudo dpkg -i linux-headers-3*.deb linux-image-3*.deb linux-image-extra-3*.deb


To uninstall as well as to remove un-use kernel, do following steps:

Boot up Ubuntu, launch Synaptic Package Manager (install it from Ubuntu Software Center) from the dash. Search for and remove following packages:


linux-header-x.x.x.x-generic (possibly generic-pae or i686)


x.x.x.x stands for the kernel version you want to remove or uninstall.

After that, run this in terminal (Ctrl+Alt+T):

sudo update-grub

Easy and without any pain !

Greetz, M.

Transparent menus in Ubuntu 12.04

There is a way to do this using the CompizConfig Settings Manager (CCSM).

You can install CCSM by looking for it in the Ubuntu Software Center or by entering in a terminal:

sudo apt-get install compizconfig-settings-manager 

Once installed, start it up and go into the options for the Opacity, Brightness and Saturation plugin. Click the checkbox to the left of it to enable the plugin first, then add a new rule under the Window specific settings section of the Opacity tab. The “Windows” textbox should contain:


…and the “Window values” slider should be set to 90 (recommended). This value can be tweaked to your taste (set mine to 80).

Greetz, M.

Install FreeNX server on Ubuntu 12.04

Installing FreeNX server on Ubuntu 12.04 needs a little tweaking.

1- Add the repository :

sudo add-apt-repository ppa:freenx-team

2- Install FreeNX server

sudo apt-get update && sudo apt-get install freenx

3- Next, as noted in the community documentation for installing FreeNX – download the missing nxsetup script, untar it, then copy it to /usr/lib/nx (the command below is one entire line that runs 3 commands and ends with /usr/lib/nx)

wget && tar xvf nxsetup.tar.gz && sudo cp nxsetup /usr/lib/nx

4- Run the NX server setup script

sudo /usr/lib/nx/nxsetup –install

5- Configure the FreeNX server to configure clients to use ubuntu-2d session

echo -e “\n#Use unity 2d for client sessions\nCOMMAND_START_GNOME=’gnome-session –session=ubuntu-2d'”|sudo tee -a /etc/nxserver/node.conf

6- Restart the NX server

sudo /etc/init.d/freenx-server restart

That’s all. Now access the installed FreeNX server with the FreeNX client (from a OS of your choice).

Greetz, M.

Hide Users List from Login Screen Ubuntu

To hide the user list from the login screen perform following steps (as root user or with sudo)

1) First of all Please take backup of original file, execute following command :-

cp -p /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.orig

2) Open /etc/lightdm/lightdm.conf, Execute Following command :-

vi /etc/lightdm/lightdm.conf

3) Add following line to [SeatDefaults] Selection:-


For Example your /etc/lightdm/lightdm.conf should look like below :-

Now Save and Exit from file. ( ESC and :wq! )

4) Finally reboot Ubuntu , You will not able to see any user on Login screen/Window

I hope this will helps you all.

greetz, M.