The Essential Primer For the Linux Terminal

Look at that hideous thing!  Surely we want to avoid the terminal right?  WRONG!  While the terminal is intimidating for the uninitiated, it is an immensely powerful tool with several advantages over GUIs and desktop environments.

Getting past your initial misgivings is important.  Once you learn and embrace the terminal, it will simplify your life and open up new worlds to explore.

 

Optional? Maybe. Recommended? Absolutely!

With each new distribution and version of Linux, the terminal becomes less and less necessary.  A few years ago, there was no graphical tool to install software, or even install Linux for that matter.  At some point every Linux user had to enter the terminal.

But many modern Linux distributions have handy graphical interfaces for most tasks, and the average Linux user could likely avoid the terminal.

 

There are a lot of excellent attributes that GUIs bring to the table.  I love my GUI, and if you want to take it from me, you’ll need to pry it from my cold, dead fingers!  However, they are not perfect.  There are several tasks that the terminal handles more elegantly, and, if used properly, the terminal is often much quicker to interact with.

 

GUI Problem #1: Inefficiency

Terminal commands are fast to execute.  I can install the Chromium web browser in Linux Mint (pictured above) with a single command and a password.

 

 

Reproducing that using the GUI requires finding the right application in the launch menu, typing in the password, browsing or searching for Chromium, opening the software listing, and finally installing Chromium.

The terminal method is faster and easier if you know the necessary command.  And therein lies the conundrum.  The GUI is easy to browse and poke around to find what you want.  The terminal requires accuracy and precise knowledge.  But, if you have the accuracy and knowledge, dealing with the GUI overhead just drags the process down.

This is a major reason that Linux masters hang around the terminal.  To us mere mortals, the terminal seems clunky and antiquated.  To them, the terminal seems simple and pure.  As you become familiar with the terminal, you will likely find yourself relying on it more and more.

 

GUI Problem #2: Difficult to Explain

If I were writing a how-to guide on installing Chromium, using the terminal would be much simpler to explain than using the GUI.  The GUI method would need several screenshots and is challenging to follow.

Additionally, GUI layouts and appearances change rapidly while terminal commands rarely change.  An installing Chromium using the terminal guide would likely last for years without needing updating.  An installing Chromium using the GUI guide would likely need updating with each new version of the distribution.

The terminal method requires a short command in an easy to copy & paste format.

 

And while this may not make too much of a difference to you, it does to everyone writing, speaking, or explaining Linux concepts.  If you ask for help on a Linux forum, you will likely be asked to run terminal commands.  If you read a how-to guide, you will likely see terminal commands.  We here at Down To Earth Linux do this often.

Terminal commands are much more clear and concise to write about.

 

GUI Problem #3: Inconsistency

One of the best attributes of Linux is the freedom and flexibility it provides.  It is also one of the worst attributes.  There are countless distributions of Linux, each with their own quirks and personalities.  For each distribution, there are several desktop environments.  For each desktop environment, there are many competing tools to do the same job.

Installing Chromium in Linux Mint running the Cinnamon desktop environment is significantly different from installing Chromium on Ubuntu running the Unity desktop environment.  And that is different from Debian running the XFCE desktop environment.  The tools are different, the methods of access are different.

However, the terminal command I used earlier will work on Linux Mint, Ubuntu, and Debian regardless of the desktop environment they are running.  Not all distributions use the same commands for the same job; however, the possible permutations decrease from hundreds down to only a few.

The simple and spartan nature of the terminal makes it largely consistent regardless of the distribution or desktop environment.

 

GUI Problem #4: Repeating Yourself

Computer geeks have a mantra: “don’t repeat yourself.”  Being computer geeks, they turned that into an acronym: “DRY.”  The DRY principle is simple.  If you find yourself regularly doing a specific task by hand, you’re doing it wrong.

As an example, let’s say we wanted to copy the BACKMEUP directory somewhere once a week, every week.  Doing this by hand is a DRY violation!  We should automate the procedure.

Well, most GUI file managers can’t do that.  But, you can write a short shell script and cron job to do that very quickly, if you’ve mastered the terminal.  Then you never have to copy BACKMEUP again.  It’s done automatically.

 

GUI Problem #5: Nightmarish Batch Operations

A batch operation is a series of jobs executed on a computer without manual intervention.  Running a batch operation is another way to not repeat yourself.  Let’s say we wanted to change all files in a directory with a ‘.php’ extension to ‘.html’ files.  Doing that in most file managers requires changing each one individually.

With a terminal, you need only run the following command once:

 

 

GUI or Terminal, That Is the Question

The problem with all the terminal commands above is that you have to know the commands and be comfortable using them.  Terminal commands are not intuitive, and are difficult to master.  In that respect, GUIs are superior.  You can browse around until you find what you are looking for.  And a well designed GUI requires very little experience or knowledge to master.

I’m not trying to persuade you to abandon the GUI.  However, some jobs and situations are better handled by the terminal.  Being familiar with the terminal, and knowing what it is better equipped to do is highly recommended.  Don’t abandon the GUI, just supplement it with the terminal.

 

 

Moving On: The Terminal Display

 

So now that we have extolled the virtues of the terminal, let’s discuss actually using it.  The first step is finding it.  Many distributions have the terminal prominently displayed in the launcher menu.  If that doesn’t work, look under headings like system, tools, or accessories.

It is usually named Terminal or Terminal Emulator.

 

 

 

My Mouse Doesn’t Work!

Yep!  That’s correct.  The terminal is a keyboard environment.  Most terminal programs will let you highlight text and copy it using a mouse, but you can’t move the cursor or jump around using the mouse.  So set your mouse aside and grab your keyboard.

 

Dissecting the Prompt

When you open up the terminal, you should see something like this:

 

Pictured above is the default prompt for Linux Mint, and it is a fairly standard example.  That being said, the prompt is completely customizable, and many distributions make their own changes.  Yours might be different.  The colors and text may vary, and you might see some other text.

Let’s analyze each section of the prompt above starting on the left and moving right.  Everything before the ‘@’ symbol is your username; in my case, my username is ‘john.’  After the ‘@’ symbol is the computer name.  This was set when installing Linux.  In my case, the computer name is ‘DTELinux.’

Next, we come to the tilde, ‘~’.  In Linux, the tilde is a special symbol meaning the current user’s home directory.  That space containing the tilde displays your current position in the Linux filesystem.  If you are in the Documents subdirectory within your home directory, that part of the prompt changes to ‘~/Documents’.

Then, we have the ‘$’.  This symbolizes that the terminal is waiting for your input.  Before the ‘$’ is contextual information, after the ‘$’ is your input.

And lastly, is the white rectangle.  That is your cursor.  Any typing you do is inserted where the cursor is.

 

Running Your First Command

Let’s start with a simple command that you will likely use often.  Type ‘ls’ into the terminal without the quotes, followed by the Enter key.

 

 

We will discuss what that command does momentarily, for now let’s see what happened.  First, that particular command returns information.  In the terminal, returned information is displayed on its own line, or lines, without a preceding prompt.  After the feedback, a new prompt is given.

The terminal displays a history of what happens as you go along.  We first ran the ‘ls’ command.  Then ‘ls’ displayed information.  Then we had a new prompt.  This history is ordered chronologically with the newest at the bottom.

 

Command Examples: Navigating and Working With Files

The number of Linux commands is huge, and, for most humans, memorizing them is impossible.  Instead, you want to remember a few important ones and then use the magical tool, Google, to find new commands if you need them.

The most fundamental terminal skill is navigating through the file system, and executing basic actions on files.  So I’m going to talk about the most commonly used commands for that task.

ls

 

The first command, ‘ls’, was used earlier.  The ‘ls’ command lists files and subdirectories.  If you don’t specify a directory, it will list the files and subdirectories in your current directory.  In the picture above, that is my home directory.

To specify a different directory to list the contents of, follow the ‘ls’ with a space and then the path to the directory you want.  If I wanted to see what was in the Pictures directory listed above, I could type ‘ls Pictures’ without the quotes.

 

We will be happy to hear your thoughts

Leave a reply

DownToEarthLinux
Logo