Way back in February ago we asked you to list the top Terminal commands you thought every Linux user should know.
You, awesome folks that you are, replied in your droves.
More than one thousand of you sent in a list of command line should-knows.
I had initially planned to write this follow-up article a week after asking for suggestions. Evidently I didn’t.
Too Many Replies, Too Few Joeys
When I launched the poll I was expecting to receive a modest batch of entries. The preceding fortnight’s poll on Cinnamon themes had netted only a couple of hundred replies.
Because of the huge response it has taken me a veritable age to sift through, collate, cut-down and create some semblance of a follow-up post. I fully admit that this article is not as good (nor as thorough) as it could (or should) be.
But if I don’t publish it now I’m never going to get around to it.
Your Responses Were Varied
The Terminal is often seen as boring. Foolishly I didn’t give too much thought to things I should’ve, for example, specifying what counts as ‘a command’ — did I mean command of a single word (I did), or a complete command linked by &&’s and a stream of arguments (I didn’t).
That lackadaisical lapse on my part meant there was confusion over what exactly I had asked. This task was made much harder by just how diverse some of your replies are! A few lists resembled an instruction manual to the Mars Curiosity rover!
Interestingly though, the overall response varies little from the terminal suggestions readers gave five years ago, save for one command (uname).
ls was one of the most suggested command, but if I divide replies listing it into those which use ‘ls‘ alone and those which pass an argument to it – e.g., ‘ls -n’, etc. – then it falls further down the list than something like ‘top’ or ‘grep’.
For this list I’m going to focus on the core commands you suggested. I will touch on some of the available arguments that are commonly used in conjunction with them in the brief blurb accompanying them.
Please note that what follows below is a brief overview of the command and not a comprehensive instruction manual.
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.
A Polite Reminder: This Is YOUR List, Not Mine
I can already hear some of you itching to go off the rails in the comment section over the commands listed above. But before you do roll off the rails please remember that this list is made up of the top terminal commands suggested by you, the reader.