• Run a process detached to the current terminal and monitor its output:
$ nohup my_command &
$ tail -F ./nohup.out
  • Same as above but with multiple commands, the last cloning a disk to another:
$ nohup zsh -c "my_command && cat /dev/da1 > /dev/da0" &
$ tail -F ./nohup.out
  • Run a process with a shell for a system user which has none (i.e. its default shell is set to /bin/false in /etc/passwd):
$ su sys_user -s /bin/bash -c "my_command"


  • Get the exit code of the latest runned command:
$ echo $?
  • Run the last command as root (source):
$ sudo !!
  • Show the user under which I’m currently logged in:
$ whoami
  • List of most used commands:
$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
  • List cron jobs of the current user:
$ crontab -l
  • If you have the following error:
$ -bash: ./ /bin/bash^M: bad interpreter: No such file or directory

Then the fix consist of removing the bad characters:

$ sed -i 's/\r//' ./
  • Extract strings from a binary file:
$ strings ./firmware.bin | less


  • Free up some memory by clearing RAM caches (source):
$ sync ; echo 3 > /proc/sys/vm/drop_caches


  • Display which distro is running the system (source):
$ lsb_release -a


$ cat /etc/lsb-release


  • Disable a service on Debian/Ubuntu, then re-enable it:
$ update-rc.d my-service-name remove
$ update-rc.d my-service-name defaults
  • Same thing as above but on a RedHat-like system:
$ chkconfig sshd --del
$ chkconfig sshd --add


  • Speed-up Grub boot, but always show the boot menu:
$ sudo sed -i 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=1/g' /etc/default/grub
$ sudo sed -i 's/GRUB_HIDDEN_TIMEOUT/#GRUB_HIDDEN_TIMEOUT/g' /etc/default/grub
$ sudo update-grub


  • List fonts available on the system:
$ fc-list | cut -d ':' -f 2 | sort | uniq

Other Resources