Introduction
When using Linux, sooner or later, there's a good chance you'll end finding yourself in front of a terminal and having to paste in or type in things that recommended to you by people on the internet. What you are doing when this happens is running a command. This is telling a program or utility to behave in a certain way or to perform some sort of action. Some common commands include echo
, mv
, cat
, etc.
When running commands, You may have to rely on functions reserved to privileged users. When this happens you will likely start your command with sudo
followed with your original command. sudo tells your computer to do something as a super user which will allow you to bypass restrictions. It should be important to note that sudo is a separate package and may not be pre-installed with certain distributions. If this is the case, you will need to use something like su
to log in as root and then run your command as root or install sudo as root.
Useful Commands
Furthermore, with commands you will likely need to include options that specify to the program how you want it to behave. One of the most common options is --help
, which will usually tell program to list all of its options. An example would be as follows:
cat --help
In this case, the 'cat' utility would respond to this command with the following:
Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s) to standard output.
With no FILE, or when FILE is -, read standard input.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
...
These options can either mildly or even wildly change the behavior of programs. Unfortunately, options are specific to each program and the options for one program will behave totally different between different programs. Thankfully, --help
is always there and ready. If not, you can always run man
before a program similarly to how you would run sudo
, and it will tell you how these programs behave, usually in a slightly different way.
Very often, Commands will also request a file to run its commands on. For example, nano requires you to choose a file for it to create or edit, and you would provide it in the same line that you run nano on like the following;
nano example.txt
When providing files you can either choose to provide one from the working directory (Like shown) or you can provide a file from anywhere in the filesystem that your user has access to. Here is an example of a command on a file that you want to edit in your documents folder.
nano ~/Documents/example.txt
The tilda sign ~
, in Linux and some other operating systems, expands to the full directory path of the current user's home folder. Here is what it would look like to type out the whole path:
nano /home/user/Documents/example.txt
These two locations are the exact same except one of them is much simpler to type, otherwise they are the same.