Useful For: Managing packages
Apt — Advanced Packaging Tool — is the single most important command on this list because it’s the one you use to manage packages. It doesn’t matter if your run a GUI or not: if you use Ubuntu, you use apt.
Apt-get has been replaced by the simpler ‘apt’ in Ubuntu 16.04 (though both work). At the time of our poll this wasn’t promoted, or indeed enabled in 15.10. Forgive its omission here.
Some example apt commands:
sudo apt install application-name
sudo apt-get remove application-name
sudo apt-get autoclean
See the apt man page for further information on its usage.
Useful For: Finding out which files are where
When you want to find a file, or get a quick overview of what files exist in the current directory, you can use the ls command (ls is short for ‘list’).
Using ls on its own, with no flag, will list the names of files and folders within the current directory. This omits information like name file, format, size, date modified, etc.
To see directory contents with some of its data in a human readable format use the ‘-lh’ flag, like so:
You can sort files based on size (largest file size to smallest) by passing the ‘-lS’ flag (that’s a lowercase l and a capital S):
See the ls man page for more things you can do with this command.
Useful For: Moving around your filesystem
The cd command, also known as chdir (change directory), is a command used to change and navigate through directories.
Cd will assume you’re in your Home folder (unless otherwise listed).
Its use is straightforward. To ‘change directory’ from Home to the Pictures folder you would run:
Then you could run a subsequent command in this folder – e.g, ‘mkdir’ to create folder, ‘ls’ to list files, and so on.
Now let’s go into another folder within Pictures:
To go back to your previous directory add a hyphen suffix, like so:
To move back one directory add ‘..’, like so:
To go back to your root/home directory simply run:
See the manpage for this command to learn more about its uses.
Useful For: Doing ninja stuff
Sudo… Super Do… Super User… Whatever you call it, you can’t do anything too dramatic to your system without it. That makes it possibly the single most important command on this list.
sudo lets you run commands, install software, edit protected files, as the superuser. It requires authentication using your user or root user password.
sudo edit /usr/share/applications/application.desktop
sudo apt-get install application-name
The related command sudo !! was also suggested a number of times. This is one of my own personal favourites as it lets you (quickly) run the previous command entered as root when/if you forget to add it in.
apt install corebird sudo !!
See the man page for sudo to learn more.
Useful For: Seeing what a file contains
cat stands for “catenate” (no, I’ve no idea what this word means, either).
The cat command read data from files and outputs its content in the terminal. Using cat is the simplest way to display file contents at the command line.
To see the same file but with number lines on display pass the -n argument:
cat -n examplefile.txt
See the cat manpage for more details overview of this command.