Ubuntu

This is a repository for a set of useful commands that can use with your Ubuntu distro. I hope that can be helpful for you in extreme situation.

Find the UUID of a filesystem

blkid

How to display free space with colors!

 dfc -Tsi

ls*: a series of list command util

  • lsblk - list block devices
  • lscpu - display information on CPU architecture
  • lshw - list hardware
  • lspci - list all PCI devices

Show a list of all autostart services.

initctl show-config

Howto list all dependencies of a package

apt-cache depends package_name

How can I see all versions of a package that are available in the archive?

apt-cache madison <package_name>

Howto export/import package list

To dump the list of currently installed applications:

dpkg --get-selections > output-file

And to import:

dpkg --set-selections < output-file
sudo apt-get dselect-upgrade

Howto remove a package and ignore dependencies

sudo dpkg -r --force-depends "package"

List processes by mem usage

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

How can I find the hardware model in Linux?

dmidecode | grep -A3 '^System Information'

How to enabling / disabling a service?

To toggle a service from starting or stopping permanently you would need to:

echo manual | sudo tee /etc/init/SERVICE.override

If you do not want this, afterwards you can simply do:

rm /etc/init/SERVICE.override

Force a clock update using ntp

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

or

ntpdate -u 1.2.3.4
    

Update current timezone

echo "Europe/Rome" | sudo tee /etc/timezone > /dev/null
sudo dpkg-reconfigure -f noninteractive tzdata