How to Start Using the Linux Terminal

You don’t have to fear the command line

Pixabay

 

The Linux terminal gets a bad rap. For so many it’s a nebulous zone, relegated to hackers, programmers, and hard-core geeks. The truth is that the Linux terminal is just another tool that can empower users to unheard-of efficiency.

However, it is that very tool that tends to keep users away from Linux. Not only do they not understand what the terminal is (and how it’s used), they are convinced using Linux means using the terminal. Let’s first dispel some myths, and then take our firsts steps toward using the Linux terminal.

But why is it called the "command line"? This term is used because it is where users run commands in the Linux operating system. Official, the terminology is either "command line interpreter" or "command line interface", (both shortened as CLI). Over time, however, that was shortened to "command line" (which is the common parlance used today).

Screenshot of a complicated Linux terminal.

Myth Number 1: In order to use Linux, you must use the terminal. At one point in time (late 90s and early 2000s), this was very true. During those early days of Linux, the GUI tools weren’t nearly enough, so users had to depend upon the terminal to do tasks that other operating systems could handle with a simple point-and-click GUI. That is no longer the case. With modern Linux distributions, users can work on a desktop and never touch the terminal window.

Myth Number 2: The Linux terminal is for programmers and hackers only. If you can remember commands like cd, mkdir, or pwd, you can use the terminal. So many people believe using the terminal means issuing such complicated commands as tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'. Believe it or not, that is an actual command you can run on Linux. However, that is not even remotely common. Commands like that are typically run by administrators looking to do very specific tasks.

Myth Number 3: The command line is for admins and programmers only. True, IT admins and programmers get the most out of the Linux command line. That doesn’t mean, however, average users do not benefit from the command line. In fact, knowing a few commands can really give your Linux experience a boost (on top of which, it’s a great way to learn how to troubleshoot, should the need arise).

At this point, you may be asking, “If I can go without the terminal, why should I learn how to use it?” There are a few very good reasons why you might want to learn the terminal:

  • It’s a great way to troubleshoot issues (if they arise).
  • You’ll enjoy much more power and flexibility.
  • Should something go wrong with the GUI, the terminal is your best bet to fix the problem.
  • Remote access to servers.
  • There are some advanced tasks that are better left to the terminal.
  • Some applications are more easily installed via the terminal.

Although the terminal does greatly extend the power of the GUI, there are reasons why you might not want to use the terminal:

  • One wrong command (such as sudo rm -rf /) and your operating system is toast.
  • Thousands of available commands, each of which includes multiple switches and options.
  • The Linux desktop GUIs are all so much easier to use.
Screenshot of a Linux terminal emulator.

The next step, in your journey to understanding the Linux Terminal, is to actually know what it is. Simply put, the Linux terminal is a means for users to run commands that can then be interpreted by the operating system. There is one misunderstanding to clear up. With Linux there is the terminal and the terminal emulator. The terminal is what you log into on a GUI-less Linux server and the terminal emulator is the app on a Linux desktop that emulates the terminal. They both serve the same function, only do so in a different environment. There are different types of terminal emulators available. Most desktop environments ship with their own emulator. For example:

  • GNOME and Cinnamon desktops both use the GNOME Terminal
  • KDE uses Konsole
  • Elementary uses Pantheon Terminal
  • Xfce uses Xfce Terminal
  • Mate uses Mate Terminal
  • Bodhi Linux uses Eterm

The next clarification is a bit more complicated. Although it was said the Linux terminal is a means for the user to interact with the operating system, it’s actually a means to communicate to the operating system, by way of an interpreter … the shell. To make things even more complicated, there are different types of shells available, such as:

  • Bash
  • Korn
  • Tcsh
  • Ksh
  • Fish

The most common shell used on Linux is Bash. Chances are good you will never have a reason to switch shells. In fact, the likelihood of the average user even being concerned with the shell is miniscule.

With all that said, let’s learn learn how to use the terminal. Let’s assume you are on a desktop, so you’ll be using a terminal emulator.

  1. When you open the terminal emulator, you will see a shell prompt (so, probably Bash). From that prompt, you issue commands.

    Screenshot of a Linux terminal command.

    Say, for instance, you want to move from the /home/jack directory to the /home/jack/Downloads directory? To do that, you would type cd /home/jack/Downloads and hit Enter on your keyboard.

  2. Congratulations, you just ran your first Linux command.

Now, let’s create a new directory (called TEST) in /home/jack/Downloads. To do that, first issue the command mkdir TEST

Screenshot of creating a new directory with the mkdir command.
  1. Change into the newly created directory with the command cd TEST (cd stands for change directory).

    Screenshot of using the pwd command.

    See the complete path of your newly created directory with the command pwd (which stands for Path of Working Directory).

  2. Enjoy your new directory.

To learn even more commands, check out 15 Linux Terminal Commands That Will Rock Your World.

And that’s the very basics of using the Linux terminal. It’s not nearly as daunting a task as you might have thought.

Bash History

Here’s a neat trick. The Bash shell retains a history of your commands. If you don’t remember the last few commands you typed, you can hit the up arrow on your keyboard to see each command, as you original typed it. By default, Bash retains the last 500 commands you ran, so chances are good, if you keep hitting that up arrow, you’ll see the command you’re looking for. Once the command appears, stop hitting the up arrow, and hit Enter on your keyboard to execute that command.

Man Pages

Another very handy trick to have in your pocket is man pages. Man stands for manual and nearly every command on the Linux operating system has a manual page. If you want to learn more about a specific command, you simply open the man page for a command. Say, for instance, you want to know more about the pwd command. To do that, issue the command man pwd and, as many are prone to say, RTFM (Read the Fine Manual).