Whether you’re a new Linux user or you’ve been using Linux for a while, we’ll help you get started with the terminal. The terminal isn’t something you should be scared of – it’s a powerful tool with lots of uses.
You can’t learn everything you need to know about the terminal by reading a single article. It takes experience playing with the terminal firsthand. We hope this introduction helps you get to grips with the basics so you can continue learning more.
Launch a terminal from your desktop’s application menu and you will see the bash shell. There are other shells, but most Linux distributions use bash by default.
You can launch a program by typing its name at the prompt. Everything you launch here – from graphical applications like Firefox to command-line utilities – is a program. (Bash actually has a few built-in commands for basic file management and such, but those function like programs, too.) Unlike on Windows, you don’t have to type the full path to a program to launch it. For example, let’s say you wanted to open Firefox. On Windows, you’d need to type the full path to Firefox’s .exe file. On Linux, you can just type:
Press Enter after typing a command to run it. Note that you don’t need to add an .exe or anything like that – programs don’t have file extensions on Linux.
Terminal commands can also accept arguments. The types of arguments you can use depends on the program. For example, Firefox accepts web addresses as arguments. To launch Firefox and open How-to Geek, you could run the following command:
Other commands you would run in the terminal function just like Firefox, except many run only in the terminal and don’t open any sort of graphical application window.
One of the most efficient things to do from the terminal is install software. Software management applications like the Ubuntu Software Center are fancy frontends to the few terminal commands they use in the background. Instead of clicking around and selecting applications one-by-one, you can install them with a terminal command. You even even install multiple applications with a single command.
On Ubuntu (other distributions have their own package management systems), the command to install a new software package is:
sudo apt-get install packagename
This may seem a bit complicated, but it’s working just like the Firefox command above. The above line launches sudo, which asks for your password before launching apt-get with root (administrator) privileges. The apt-get program reads the arguments install packagename and installs a package named packagename.
However, you can also specify multiple packages as arguments. For example, to install the Chromium web browser and Pidgin instant messenger, you could execute this command:
sudo apt-get install chromium-browser pidgin
If you just installed Ubuntu and wanted to install all your favorite software, you could do it with a single command like the above one. You would just need to know the package names of your favorite programs, and you can guess them fairly easily. You can also refine your guesses with the aid of the tab completion trick below.
For more in-depth instructions, read How to Install Programs in Ubuntu in the Command-Line.
The shell looks in the current directory unless you specify another directory. For example, nano is an easy-to-use terminal text editor. The command nano document1 tells nano to launch and open the file named document1 from the current directory. If you wanted to open a document located in another directory, you’d need to specify the full path to the file – for example, nano /home/chris/Documents/document1 .
If you specify a path to a file that does not exist, nano (and many other programs) will create a new, blank file at that location and open it.
To work with files and directories, you will need to know a few basic commands:
This may be a bit overwhelming at first, but these are the basic commands you need to master to effectively work with files in the terminal. Move around your file system with cd, view files in the current directory with ls, create directories with mkdir, and manage files with the rm, cp, and mv commands.
Tab completion is a very useful trick. While typing something – a command, file name, or some other types of arguments – you can press Tab to autocomplete what you’re typing. For example, if you type firef at the terminal and press Tab, firefox automatically appears. This saves you from having to type things exactly – you can press Tab and the shell will finish typing for you. This also works with folders, file names, and package names. For example, you can type sudo apt-get install pidg and press Tab to automatically complete pidgin.
In many cases, the shell won’t know what you’re trying to type because there are multiple matches. Press the Tab key a second time and you’ll see a list of possible matches. Continue typing a few more letters to narrow things down and press Tab again to continue.
For more tricks like this one, read Become a Linux Terminal Power User With These 8 Tricks.
At this point, you should hopefully feel a little bit more comfortable in the terminal and have a better understanding of how it works. To learn more about the terminal – and eventually master it – continue your journey with these articles: