Using the shell in Linux

Last month in this column, I introduced some of the tools available for graphical file management, which can go a long way to easing the transition from another operating system. This month I will discuss the Linux command line, or shell, and demonstrate how it can be used just as effectively as any GUI application.

The most common shell used in Linux systems is Bash, or the Bourne Again Shell. The purpose of a shell is "to interface the user's applications with "the kernel (core of the Linux operating system). The Linux shell, being a functional system configuration and development environment, works independently of the X Window System.

CONSOLE OR TERMINAL? There are two ways in which a user can access the Linux shell: in console mode or through a terminal emulation program. Console mode is simply your monitor's blank screen, with a shell prompt that can be accessed by pressing -- while in the X Window System. Your X Windows System display will then switch temporarily to console mode (it will continue to run in the background) where you can log in and begin using the shell. -- will switch to another console, and so on, until you press -- to return to the X display.

Alternatively, you can use the shell while in X with the aid of a terminal, which will allow you to perform the same tasks as if you were logged in at the console. Common terminals, or terminal emulation programs, for Linux and UNIX systems are xterm and rxvt. The KDE and GNOME desktop environments have their own terminals called Konsole and GNOME Terminal, respectively.

SHELL COMMANDS For anyone familiar with a DOS command line, learning the Linux shell shouldn't be difficult. The first thing you will see when logged in at a shell is the prompt. Many Linux systems use the dollar sign ($) as the default prompt for a user and the hash (#) character for the root (administrator) account. Executing a command simply involves typing it at the prompt and pressing . Try this with the pwd, or print working directory, command:$ pwd/home/jsmithThe output "/home/jsmith" indicates that the user jsmith is currently working in their home directory. Changing to another directory is as simple as using the cd command:$ cd /homeThis will make your current directory /home. Executing cd on its own will return you to your home directory by default. One of the most-commonly used commands is ls, which lists the contents of a directory:$ ls
$If nothing comes up then you have not yet created anything in your home directory. You can get more information about files by running ls with a flag:$ ls -l /etcThis will give a long format description of all files in /etc. The output will be more than 100 lines long. To see it, you can hold down -, or a useful feature of the Linux shell called piping, by entering:$ ls -l /etc | lessHere, the | (or pipe) sends the output of the ls -l to the program called less. Less is a text viewer which allows you to navigate slowly through a file using the keyboard arrows. A similar way of adding text to a file is with a text editor:$ pico helloThis will open up an editor window where you can do all standard text editor procedures. There are also other text editors, such as vi and emacs. Once you've created a file, you might like to delete it with the rm (remove) command:$ rm helloThis removes the file hello. NOTE: unlike other operating systems, if you delete a file under Linux, it's gone permanently. You could have also copied the hello file to another file, with:$ cp hello hello2You might be wondering why the files do not have extensions on the end like .txt. This is simply a matter of choice. You can rename hello2 to hello2.txt with mv (move):$ mv hello2 hello2.txtTo help with organisation, you will want to be able to make directories in which to put files:$ mkdir testUsing ls, you can see test exists in your home directory. You can remove it with rm:$ rm -rf testNow you can make a directory in which to store your Linux information:$ mkdir tuxYou can copy all the files that you have made into it:$ cp hello hello2.txt tux/The commands demonstrated here are only a starting point for what is achievable with the Linux shell. With some practice, you will find that using the shell is very intuitive. It is also necessary for a fuller understanding of Linux.

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Rodney Gedda

PC World
Show Comments

Brand Post

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Christopher Low

Brother RJ-4230B

This small mobile printer is exactly what I need for invoicing and other jobs such as sending fellow tradesman details or step-by-step instructions that I can easily print off from my phone or the Web.

Aysha Strobbe

Microsoft Office 365/HP Spectre x360

Microsoft Office continues to make a student’s life that little bit easier by offering reliable, easy to use, time-saving functionality, while continuing to develop new features that further enhance what is already a formidable collection of applications

Michael Hargreaves

Microsoft Office 365/Dell XPS 15 2-in-1

I’d recommend a Dell XPS 15 2-in-1 and the new Windows 10 to anyone who needs to get serious work done (before you kick back on your couch with your favourite Netflix show.)

Maryellen Rose George

Brother PT-P750W

It’s useful for office tasks as well as pragmatic labelling of equipment and storage – just don’t get too excited and label everything in sight!

Cathy Giles

Brother MFC-L8900CDW

The Brother MFC-L8900CDW is an absolute stand out. I struggle to fault it.

Luke Hill


I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?