A beginner’s introduction to the GNU/Linux command line

An introduction to the command line for novices that teaches some simple commands such as ls, cd and pwd and explains how to learn more

Download the whole article as PDF

Write a full post in response to this!


So you have decided to try a free software operating system such as GNU/Linux, congratulations. GNU/Linux is not that different from other operating systems on the surface. You point and click using the mouse and call down menus to get programs to work.

However, these icons and windows are just the sweet candy coating on top of a much older system, a system of programs designed to be accessed by the command line.

If you know the correct commands, then you can start any program, check your computer’s status, and see what files you have stored without having to find the listing in your menu

The command line is an interface that allows you to talk directly to your computer using words called commands. If you know the correct commands, then you can start any program, check your computer’s status, and see what files you have stored without having to find the listing in your menu. Also, some functions can only be accessed through the command line, so if you want to truly understand your new system it is worth learning.

Finding a terminal program

To access the command line you will need to open a terminal which will allow you to talk directly to the computer. Look for a program called Xterm, terminal, Konsole, console or something similar. Since different versions of GNU/Linux have different menus, this may take a bit of searching.

The icon for a terminal is usually a computer screen, and different windowing systems will have their preferred terminals. Gnome has a gnome-terminal and KDE has Konsole. On my Debian Linux system, I found a terminal called Xterm under Debian —>Xshells.

First, open a terminal on your computer screen. It will usually list the computer name, or yourname @ yourcomputer and there will be some kind of punctuation mark like a $ or a # followed by a blinking box or line-shaped cursor. That blinking thing is called a prompt because it is prompting you to give it a command. Think of it as a genie coming out of a lamp asking you. “What is your command my master?”

What is your command my master?
What is your command my master?

If you are at your computer now, you may want to follow along. Open a terminal and then type whoami. (Remember to run all of the words together with no spaces, and press enter.) Here’s what you get:

$ whoami
rosalyn
$

This may seem to be a bit of a philosophical question to be asking your computer, but don’t worry. Your computer has a very concrete world-view.

It should return your login name. The word that you just typed is a command. The computer executed the command and returned a result, your username.

Using commands

Commands are written in a particular way. The command is typed first with no spaces in the name. Then after a space, you can sometimes modify the command by adding what are called options. Options change or limit the way the command is executed. Options are usually preceeded by a dash. A command may also include the name of a file or directory that you want the command to work on. The finished command will look something like this.

command -option file

The best way to understand the command line is to use it. Try typing ls.

Remember that GNU/Linux is case sensitive so you must use lower case. When you press enter, the computer will return to you a list of file names in the directory that you are in. The command ls stands for list.

When I type this command, I get the following response:

$ ls
captions.txt  photo1.png
$

Files are documents, images or programs on your computer. Directories are like boxes that hold the files. You are always considered to be within some directory. Most of the time, commands only act on the files within the directory in which you are located. So, when you list using ls, you get a list of all of the files in the directory that you are in, not all of the files in the computer.

When you use the command line, you are learning to talk “face to face” with your system. You can tell it precisely and concisely what you want it to do. There is something truly freeing about this power

Command names are usually shorthand ways of representing a word, such as ls for list, or mv for move. Sometimes, however, they are oddly abbreviated. Using the command line requires you to learn the names of the commands. The advantage is that by learning the language you can talk directly to the computer without needing a point and click interpreter program explaining what you mean.

When you type ls the names of all of the files in your current directory are written on the terminal screen, and the prompt returns waiting. It is asking, “What next my master?”

Don't miss out on the other pages!
123next ›last »

Write a full post in response to this!

Similar articles

0

Do you like this post?
Vote for it!

Copyright information

This article is made available under the "Attribution-Sharealike" Creative Commons License 3.0 available from http://creativecommons.org/licenses/by-sa/3.0/.

Biography

Rosalyn Hunter: Rosalyn Hunter has been on the internet since before the web was created. Born into a family of instructors, she has made it her life's goal to teach others about the important things in life, such as how to type kill -9 when a process is dead. She lives in a little house on the prairie in the American West with her husband, her three beautiful children, a cat and a dog.

depi's picture

thanks

Submitted by depi on Mon, 2006-06-26 12:04.

Vote!
0

I must to say that this is really useful tutorial for the beginners or for the average linuxers too because it shows some commands or commands atributes which not everybody must know. So good point!

P.S. I like the root tree image too :)

Anonymous visitor's picture

Changing directories

Submitted by Anonymous visitor on Thu, 2006-08-24 09:10.

Vote!
0

I know it is the simplest of commands but I still haven't found commands for
changing directories(outside of /path/to/another/device)like the CD ROM sitting there so close but so far...

Everyone wants to show how to move within Mr. Torvalds structure but HOWTO Change into that GUI icon that won't let you drag and drop without a password, won't let you cd, what, no drive letter. (drive letter_:where are you?). I see ///, not close. OH WHERE in the world is that tutorial. Oh, yes, revised Tutorial.

Big Yellow Tuxi's picture

toehold

Submitted by Big Yellow Tuxi on Mon, 2006-08-21 08:50.

Vote!
0

Clear and well written, this is just what I needed! Moving from DOS to linux is a humbling experience and mastery of a few simple commands (and understanding of similarities and differences between DOS and linux) feels like a first toe on the ladder. Thanks - looking forward to reading more sometime.

Anonymous visitor's picture

Thanks for the intro to Linux shell

Submitted by Anonymous visitor on Mon, 2006-10-16 22:42.

Vote!
0

Dear Rosalyn,

Thanks for giving me my first Linux shell command. It gave me great satisfaction and a sense of freedom and relief. If you would like teach me some more feel free to contact me.

Hope all is well

Kindest Regards

Robert

Robert Davidson
robert@datamatrix.co.nz
Director
Datamatrix New Zealand ltd www.datamatrix.co.nz
Genatron ltd www.genatron.com

mysurface's picture

Futher learning linux command

Submitted by mysurface (not verified) on Thu, 2007-05-17 13:47.

Vote!
0

Once you get into it, you will definitely love the command line. You may even start GUI apps in terminal with help of nohup and & so GUI won't terminate even you close the terminal. You can record what have you type in terminal with script and replay back with scriptreplay. vim will be the next thing you wanna try after I start to dip your toe into CLI.

A lots of fun stuff, you can get it cover at http://linux.byexamples.com

Anonymous visitor's picture

Great tutorial article for

Submitted by Anonymous visitor (not verified) on Sun, 2007-07-29 11:13.

Vote!
0

Great tutorial article for me to enter commandline shell. Thank you very much.

sanjayss's picture

GUI help

Submitted by sanjayss (not verified) on Thu, 2007-08-16 05:22.

Vote!
0

What is Gnome, KDE. Please explain !!!!!!

Dave Guard's picture

Wikipedia is where you should look

Submitted by Dave Guard on Sat, 2007-09-08 19:16.

Vote!
0

Here is KDE and here is GNOME.

harsh patel's picture

A good tutorial to start on

Submitted by harsh patel (not verified) on Fri, 2007-10-05 12:46.

Vote!
0

A good tutorial to start on with ....thanks a lot!! .