Command Line Essentials Part 2

This is Part 2 of Command Line Essentials(Part 1). In this Part I will be focusing mainly on common basic text file utilities. Utilities are what command line programs are called.


Options, or switches control how a utility works. For example rm -i works differently than rm. Utilities can have more than one option. ex rm -i-r. This can also be typed rm -ir. There are also a long version of switches for most utilities. --help is one example.

Other Terminal Access

There are other ways to access the CLI(command line interface) than opening a terminal emulator(like gnome-terminal). For example Ctrl-Alt-[F1-f6](C-M-F7 gets you back to normal) gives you a terminal interface to your operating system. You will also encounter a CLI if you use a server most likely. At its core Linux is  a command line OS and all the graphics are just layers on top of it. This contrasts with Windows where the GUI is an integral part of the operating system.

Working With Text Files

Text files are very important in the Linux/Unix operating system(OS)


cat displays a text file.

$ cat fruit

apples oranges


less also displays a text file but in a different way. It displays  it one page at a time. You type space for the next page. When less reaches the end of file(EOF), It displays END at the bottom of the screen. Type q to exit. Less is used to display man pages.


lpr prints files. By default it prints on the default printer. To print on a specific printer use lpr -P printer file.For more info see the man page.

$ lpr text.print


nano is a simple text editor. The keyboard commands are at the bottom of the ‘window’.(^ means Ctrl ex. ^X means Ctrl-x). Nano opens a new file if no file with that name exists. Else it opens the existing file. (a very popular, but harder to use alternative is vi/vim)

$ nano filetoedit


head displays the first ten lines of a text file. Conversely tail displays the last ten. You can use an option to specify the number of lines.

$ head -2 list

the second line


grep is a very useful utility. Here I will only show the basics. Grep searches text files. The syntax is grep string file. to search only for words(ex grep for file could get therefore) use the -w option.

$ grep 'apple' favoritefruits

Ted's favorite fruit is an apple.



Commands and terminal examples are in monospace. User typed input is in bold.

Getting to the Terminal/GUI

In most Desktop environments: Applications -> Accessories -> terminal. In Unity search for terminal.

You can also use run(alt-f2) and type in gnome-terminal or xterm or something similar.


Many(or maybe most) of these commands are also in Mac OS, but since I have no experience with Macs I do not know the specifics of how it differs.

Command Line Essentials Part 1

Although Linux can be used without the command line and has been improving its graphical interface, the command line interface(CLI) is still an important and useful part of being a Linux user. These tutorials about the command line are centered on Ubuntu, that being my current distro of choice. However the command line is all but uniform across distributions and I will note when it is distro specific. To get the most out of these open up the terminal(note on how at bottom) and follow along. To be at all effective on the command line you need to know how to move around the file system and do basic file manipulations This is what Part 1 is about(Part 2, Part 3).



The ls command lists the files and folders inside the working directory. Ex:


foo.txt        pics


To move around in the command line the cd command is used. It is used in the following:

$cd targetfolder

You can use absolute folder name (the whole name i.e.. “/home/me/Documents”) or relative folder names (relative to the current folder i.e.”Pictures”), which leads to the next topic.

Basic Path Extension

“~/” expands to you home folder; “../” is the parent folder [of the working directory]; “/” is the root directory


pwd stands for print working directory. It has no arguments; simply type it in and it prints the folder/directory that you are in. This information is also usually in your prompt.

Making and Removing files/directories

Use ls to see the created folders or deleted files.


This command creates a directory. It is used as follows:

$mkdir newfolder


Alternatively, you can also remove a directory with rmdir. This only works with a empty folder(see rm -r).

$rmdir deleteThisDirectory


This removes a file. By default it will not prompt for confirmation. Nor will you be able to “undelete” the file.

$rm deletefile

rm -i file will prompt for confirmation and rm -r will delete a directory that is not empty.

Copy and Moving files

Like rm, copy and move can destroy files. This happens if you copy or move to a file that already exists. For prompting, like rm, use -i


cp makes a copy of a file.

$ cp file.txt copiedfile

$ ls

file.txt        copiedfile


mv moves a file. It can be used as a rename in the same directory or to move between folders.

$ mv file.txt file.move

$ ls

file.move        copiedfile

Help on commands

From the Command Line

You can use the man command to find info on a command.

$man ls

blah blah blah(not real)

You can also, on most programs, type command -h or command --help. Note that some Utilities such as ls do not work with -h.

$ls  --help

blah blah(not real)


Books, Internet(like googling ls), Friendly Linux users



Commands and terminal examples are in monospace. User typed input is in bold.

Getting to the Terminal/GUI

In most Desktop environments: Applications -> Accessories -> terminal. In Unity search for terminal.

You can also use run(alt-f2) and type in gnome-terminal or xterm or something similar.


Many(or maybe most) of these commands are also in Mac OS, but since I have no experience with Macs I do not know the specifics of how it differs.


The rest of this series: Part 2, Part 3

Best Linux Distro for Absolute Beginners

A commonly asked question is  “what distro should I try, as a beginner”.  Some people say that they should choose what is best for them. While this strategy is well and good for people who have some experience, a beginner will have no idea what works best for them and will not want to try multiple distros. Therefore I will try and give them a good answer. A beginner is probably looking at ease of use, usefullness, and support. In this I am considering Ubuntu, Linux Mint, and Fedora (the three most popular distros according to Distrowatch). In case you do not know, distro or distributions are kinds of Linux. Many are based off of other distros and therefore are very similar.

Overview of the Distros

  • Ubuntu – Currently the biggest desktop distro out there. Based on Debian
  • Linux Mint – Another major player. Relatively new as a top distro and based on Ubuntu.
  • Fedora – Another major distribution. Based on the well known Red Hat.

Ease of Use

All of these distributions have good interfaces.  However these interfaces differ greatly. Ubuntu has a nice (Not so nice according to many people) new GUI (Unity) that will likely be most familiar to Mac users although most people should find it fairly easy to use after a few days . Linux Mint has a interface very similar to that of Windows so it will be familiar to most new users. Fedora has yet another way of thinking about things with a very unique approach in the GUI (Gnome 3, which also has had some complaints from the community). The best one for administration (adding software for example) is Ubuntu(I don’t thing the ‘Mint’ thing are that great). I think, though, that a new user wants something familiar so in this category I would place Linux Mint in the lead. However learning a new interface is not that difficult so in the long run what really matters is if it can do what you want easily.


This is a rather ambiguous category. What I mean is:  Does it do everything you need it to do and most of what you want it to do?  They are all about the same.For someone who just surfs the Internet, checks email, writes some documents and maybe plays some casual games any of these would be fine. However I find that the pre-installed software on Ubuntu and Mint are probable better for the beginner. These both also have many software packages available to them, although Fedora has plenty as well. If you want paid-for applications (there is rarely a need) then Ubuntu(with the Software Centre) and Fedora(with commercial support from its Red Hat legacy but is harder to find and install) have the upper hand. Mint, not to be outdone also provides access its other software (than Ubuntu, which mint is based on) that allow for more restricted multimedia things(not in other distros because of copyright restrictions). In this category(for beginners) I would say that Ubuntu edges ahead(you can enable the extra software sources) but is closely followed by Mint. Of course, these are all very capable operating systems.


This is a very important aspect and may affect your choice. (Here I’m talking about free support.) Ubuntu probably has the best support of all the Linuxes, mainly due to its popularity and active forums. That said, Mint is so closely related to Ubuntu that most, if not all, Ubuntu help can be applied to Mint. Mint also has a fair amount of its own. Fedora also has support available but less so than Ubuntu. The best support is if you know a Linux person. Unfortunately that is not that common so most will have to keep with online support. Here Ubuntu wins but Mint by extension has the same kind of support (if you know how to find it).


In conclusion, I think that Mint is the best for beginners starting out on their own without any particular dedication. You can use it basically out-of-the-box with little tweaking for it to do everything you want initially. Support is available and you can use the extensive Ubuntu support to a certain degree. Ubuntu is the runner-up. It is more established and has some advantages such as a much better (in my opinion) software centre. If you know some one who knows Linux and will help you out, I would recommend Ubuntu, even with its odd tablet/Mac/something-else interface. Fedora, although a good OS, is not great for beginners.


I had hoped to have time for a more in-depth article but this will have to do since I had a bit of a time constraint.

There are many good resources for Linux information. They can generally be found through Google.

I have also heard that PCLinuxOS is beginner friendly but I have no experience with it.

Update: You may want to see my review of Mint 12.