5 Basic Linux Terminal Commands

The Linux Terminal: Use Ctrl+Alt+T To Begin With

For most Windows users, using 'cmd' might have never occurred to you given how GUI driven the World's most popular operating system truly is.

Linux, on the other hand, can be a bit different. This is because since its inception, users were mostly geeks, who preferred using the 'command line'.

Yes, that's the generation I grew up in given that Windows 3.x or even 95 were still in development for years.

Which begs the question: what is this “command line”?

It is simply a window (also called the Terminal) that allows you to type certain commands that will help you perform certain functions – sometimes far more efficiently compared to the graphic user interface.

That said, the commands in Windows as well as in Linux are usually the same with a few exceptions, of course.

Yet in order to get started, hit Ctrl+Alt+T on Ubuntu (or any other Linux distro), to open a Terminal window, much like the one below:

Fig. 1: The Command Line - Ctrl+Alt+T

Using the Linux Terminal - What's the Big Deal, Anyways?

When I first started using Linux a few years ago, there was always a desire to learn how to use the command line fluently.

Yet any learner, who does not understand as to why this is important, might not put much effort into his or her learning in the first place.

The first thing that came to mind was if we do have a File Management system that allows us to do away with the command line, then what's the point of learning it in the first place. After all, most of us have a number of things on our plate each day and learning how to use the command line might not be top on those lists of things to do.

While that's true, if there's anything that learning a few Linux command line commands can help you with is to speed up certain tasks if not more than you can imagine. This is only if you take the time, of course!

Probably the simplest thing that I can think of here is the scenario where you might have to transfer about 20,000 images from a folder that has varying file types. Well, you can use the mouse and keyboard to select the files, right?

Yes, you can. But that takes so much more time than entering a single command that can copy these files in no time without error. Not unless you make a mistake with the command itself.

Speaking of which, it's best to learn a few simple commands before moving on to running more complex tasks with the Linux command line.

Fig. 2: The "command line" in Windows. Circa 1993. No Windows 3.x.

1: The "Working" Directory

Step #1: Type "pwd"

Step #2: Hit Enter

Step #3: That's it.

Now the purpose of this command is for you to see the directory that you in. Once you know where you are located in the Linux file system, you can use other commands to move to certain directories and sub-directories.

In this case, as in Fig 3 shown below, the location is home/swapan...

Now if you want to move to another directory - to access a few files - the next command should help you with that.

Fig 3: The Working Directory

2: Listing Files in a Directory

Step #1: Type "ls".

Step #2: Hit the Enter key.

Step #3: Look at the files (marked in white) and directories (marked in blue) as shown in Fig 4.

Now if you want to move to another directory, there's a command for this. But before we get to that one, let's look at how you can clear your screen if it has too much information on it.

Fig 4: Listing Files in a Directory

3: Clearing Your Screen

Step #1: Type "clear"

Step #2: Hit Enter.

Step #3: That's it. You should clear your screen with the command prompt at the top of your screen.

Refer to Fig 5 below to see the results.

Fig 5: Clearing Your Screen

4: Changing Directories

Now there are a few ways by which you can use the "cd" command.

The first way to do this is by typing: cd <foldername>. In the example below, there are three folders: Files, Archive & Assorted.

In order to change the working directory from Files to Archive (the latter being a sub-directory!), type cd Archive. If you want to go one step lower, then type cd Assorted. That's it.

Conversely, if you want to move back up from Assorted to the Files folder, you can type twice: cd ..

(Remember: there's a space between "cd" and ".." that you must not forget. You can also use the ls command if you do not know Folder names in each directory.)

Fig 6: Changing Directories...

5: Making a New Directory

Step #1: In order to make a new direction, type mkdir <foldername> at the command prompt.

Step #2: Now type "ls" to look for the directory created. (Look at Fig 7 for the folder named "daniel".)

Step #3: Finally, if you want to navigate to that directory, use cd <foldername> to move to that folder.

Fig 7: Making a New Directory

Using the "man" command

The "man" command is an interesting one since it throws up information about the particular command that you might wish to use. In most cases, you might not know what that command does.

For example, type "man clear". Hit Enter.

Once you do this, you'll find information about the clear command as shown in Fig. 8 below.

Fig 8: The "man" page for the clear command

In Closing

Now, that we've learned 5 new Linux terminal commands, it's a good idea to play around with them as you move through various directories on your file system.

As soon as you begin using these commands fluently, there's a host of commands that you can try out on your own.

One last thing: if you want to learn more about the command line, this book by Williams Shotts is a good starting point. Don't worry - none of us were born geeks - we all had to start somewhere.