Ubuntu Cheatsheet

Official Linux Documentation

Linux commands and an enormous amount of information on the operation system can be found at a Linux Documentation site. This also includes the ebook Dive Into Python and other material.

For my desktop, the Ubuntu distro has its own help.

Upgrade system packages with “apt”

“apt” is primarily designed for user interaction on the command line. “apt-get” and “apt-cache” still exist for low level system work.

Download updated catalogs from all configured apt sources.

$ sudo apt update

List all available package from local apt catalogs. Variations include listing installed packages and those you can upgrade.

$ apt list
$ apt list --installed
$ apt list --upgradeable

Upgrade all packages. New packages may be installed but old packages will not be removed. If desired, you can upgrade specific packages only.

$ sudo apt upgrade                  # All packages.
$ sudo apt upgrade {package_name}   # Just one package.

After an upgrade, you can remove old packages and free up space. A list will be displayed and you will be asked if you want to remove them.

$ sudo apt autoremove

Search local apt catalog for packages. The first one searches by package name (even partial name). The second method just lists everything and uses grep to filter the list.

$ apt list search cur*     # Searches by package name.
$ apt list | grep cur*     # Searches by any part of package identifier.

Display information about one or more packages – just list them on the command line. This includes description, dependency, size, etc.

$ apt show {package_name1} {package_name2}

Remove a package. Include as many package names as desired.

$ sudo apt remove {package_name1} {package_name2}

You can install Debian files also.

$ sudo apt install /pathto/file.deb

Other Commands

Display user name.

$ whoami
adminbob

Display machine name.

$ hostname
Lenny

Display Linux version information. This is the breakdown of the command line information printed below.

  • Kernel name: Linux
  • Hostname: Lenny
  • Kernel release: 5.19.0-32-generic
  • Kernel version: 33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2
  • Machine hardware name: x86_64
  • Processor type: x86_64
  • Hardware platform: x86_64
  • Operating system: GNU/Linux
$ uname -a
Linux Lenny 5.19.0-32-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

There is a utility that can be installed that can provide more human readable information about the system. This includes machine type (“laptop”), OS, Kernel, hardware vendor (“Lenovo”), hardware model (“Lenovo G550), etc.

$ hostnamectl

Disk space usage and availability. Using the -h command line option presents the disk size in the more human readable form of G or M instead of number of bytes (“386G” or “2.0M” instead of “394912” or “1980” 1-K blocks). The -T command line option displays the file system type (“ext4”, “tmpfs”, etc.).

$ df -h
$ df -hT

Display the $PATH environment variable.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin