Home Classroom Linux Basics


Searching files in Linux

In our Linux basics series so far we have discussed a few areas ranging from the command line or GUI basics to basic administrative topics such as package management.

Modern Linux distributions tend to provide user friendly graphical interfaces comparable to anything available in other operating systems. For example if you consider the current or the upcoming releases of popular distributions like Ubuntu, Fedora, Mint and openSUSE, you will notice that they are very much in the same high quality GUI scale as Apple MacOS X or Microsoft Windows 7. In future articles we plan to discuss more and more graphical tools and tips as we move on. For today however we are planning to give you some tips about a command line tool which can impress your friends.

When you are working in a command line how would you locate a file or a directory? In a GUI you could browse the directories using a file browser or execute a search tool. Would you be surprised that you could search and locate files/directories in a Linux systems with ease using only command line tools, perhaps even better than GUI tools?

New Command: find

The command find is a traditional Unix command you would find in almost all Linux systems. Despite is simple name, the command is a very powerful tool. The price of that power is that the usage of find can be a little daunting for a new user. Perhaps in the past you have tried to use the command and failed or it didn’t give the intended output. Today we take control and learn a few things about find.

Find by the name

Let us have a look at the syntax of the basic find usage. It’s like:

The find has the ability to conduct searching based on many different criteria. For example let us search our home directory to find any files with the “.mkv” extension. If you remember the previous sessions, then you might recall that in Linux a file extension is just another part of the file name. So we are about to run a search based on the file name.

$ find where/to/look what-to-look-forThe find has the ability to conduct searching based on many different criteria. For example let us search our home directory to find any files with the “.mkv” extension. If you remember the previous sessions, then you might recall that in Linux a file extension is just another part of the file name. So we are about to run a search based on the file name.

$ find ~ -name *.mkvLet us try to understand the above example in detail. First of course you know we are running the find command. The we give “~” as the location where to search for. Again if you recall previous sessions, “~” character refers to your home directory.

Then comes the curious part where we tell the find command the criteria of our search. By using “-name” option we tell it to base the search on the file name. As the name pattern we give “*.mkv” which means a name with any number of characters before the ending 4 characters which are “.mkv”.

Once significant thing to mention here is that our search patterns are case sensitive. Which means the above search will find a file named “Avatar.mkv” but not a file named “Avatar.MKV”. The reason is we are saying our search pattern is “*.mkv” not “*.MKV”.

What if we want to find the files with a certain pattern, regardless of the case (Upper, lower or mixed). In such a case (which is quite often) you have to use the option “-iname” instead of “-name”.

Now that you have a firm grasp of that, let try to find the same files inside your current directory.

$ find . -iname *.mkv As you might have correctly remembered the “.” notation here is a shorten way of referring to the current directory. In the same sense you can use “..” instead of “.” to search in the parent directory of the current directory.

The where to look does not have to be one of those characters. For example we could tell find to search in the /tmp/play directory by

$ find /tmp/play -iname *.mkv I case you were wondering, you can give multiple search paths as well in the find command.

$ find . /tmp /usr/share/doc -iname *postgres*.pdfIn the above example we are telling find to search inside the current directory, “/tmp” and “/usr/share/doc” with the characters “postgres” in anywhere in the name and ending with “.pdf”.

As you can see, you can search anywhere in the file system where you have permission. This means that certain directories are not readable for regular users. In such as base you have to use find in conjunction with a command like “sudo” or “su -c” or else run it while logged in as the user “root”.

So far all the above examples are searching for a pattern in the file name. What if you want to search based on the file creation date, last accessed date or the file size.

At this point I am pretty sure that you won’t be surprised to know that “find” can do that too.

Find by the type

Now let us run a search to find only files. Which means directories matching the search pattern will not be included in the results. The option to search for the type is “-type”. So to search for files only we can give “-type f”.

$ find . -type f -iname ubuntu*The above example will search the current directory for any files (no directories) with a name starting from the characters (case insensitive) “ubuntu”.

There are other different types that you can include in your search criteria. Simply use the relevant type character after the “-type” option.

f - regular file
d - directory
s - socket
l - symbolic link
If you don’t understand these types yet, that could because we have not talked about them yet. So no need to panic. If you somehow know them, then you can go ahead and give it a try.

Find by the time

$ find . -type f -mtime 7 -iname *.odt The above example will search the current directory for any files (no directories) with a name ending with “.odt” which has been modified during the past 7 days. The “-mtime” option specifies the last modified time. If you need to use the last accessed time rather than the last modified time, then you can use the “-atime” option

Both “-atime” and “-mtime” takes the next parameter in days (i.e. 24 hours). So as in previous example “-mtime 7″ means last modified date is within 7 days (or 168 hours). What if you need to make these time based searched by minutes instead of days?

For those cases there are two similar options named “-amin” and “-mmin” which acts the same as “-atime/-mtime”, but only with minutes as in the following example.

$ find . -type f -mmin 10 -iname *.odt

Find by the permissions

In the coming articles we can talk about the Linux security model with details including about the file permissions and ownership, etc. As for now it is enough to let you know that the find command has the ability to run searching based on file permissions too.

$ find . -perm -o=wThe above example however asks find to look in the current directory for any file or directory where the “world/other” have write permission. If this does not make much sense to you, do not worry. We can discuss permissions later.

Find by the size

Another useful criteria when you are searching for things is the file size. In the real life application, a server configuration file or a word processed document should be much noticeably smaller in size than a video file of a full movie. As you can see when these kind of distinctions are possible, you can always use the “-size” option with parameters. Let us consider an example.

$ find . -size 1024kThe above example will search the current directory for files with the exact size of 1024 kilobytes (i.e. 1 megabyte). Now what if we want to search all files larger than 1 gigabyte?

$ find . -size +1GAs you can see in the above example we are asking find to look for anything larger than one gigabyte. What if we want to find something smaller than a particular size?

$ find . -size -10M Yes, you guessed correctly. The above example will search for anything smaller in size than 10 megabytes. If you were wondering which are the character notation to specify the units we are going to use (Eg: megabyte, gigabyte, etc.), here are a few.

c - bytes
k - kilobytes
M - megabytes
G - gigabytes
Those four are not the only ones available, but those are the most commonly used ones as you can guess.

In the same lines you can easily search for empty files.

$ find . -size 0c

Find by the owner

Apart from the above talked criteria, there is also the ability to run searches based on the owner of the file. Again the ownership and group ownership are two things we shall be discussing in a future article. For now you can assume that each and every file has an owner.

So to get back to the topic, we can ask find to search files/directories based on the ownership of a file by using the “-user” option with a user parameter.

Eg: $ find . -user gaveen

The above example will search the current directory for things owned by the user named “gaveen”.

Advanced: Perform operations based on the results

If you think the fun gets over there, you were wrong. Our friend “find” can also be utilized in many creative and advanced ways. However without straining you ming let us get to an example. Remember, it is just one of the things possible with find.

$ find . -iname *.png -exec cp {} ~/test/ \;

Since the above example is more advanced than what we have already discussed, let us go through it carefully. First, part of the command might be familiar to you. Consider what is there from the beginning until the part “*.png”. As you might remember it is in fact searching for all files ending with the “*.png” inside the current directory.

Then there is this curious “-exec” option, which opens a whole new world of opportunities. Basically “-exec” executes some command we provide against the results of the first part of the find command. In this case we are asking to copy (using the cp command) the results of the first part of the find command into the directory located at “~/test”.

Let us examine the exec part more carefully. It says, execute cp with the destination location of “~/test”. The pair of curly braces acts as a place holder for the results from the first part of the command. So you must be catching this up gradually. But why the “\;” part?

When “-exec” runs a command, it runs the command for each single result. Which means if there are 25 results found by the first part, the cp command will run 25 times. Consider the “\;” as a break sequence which tells the “-exec” that the commands ends there. So the command completes by that sequence.

Hint: Common error message with find

One of the most common error message you would see with the find command is: “find: paths must precede expression”. This is annoying because after some rigorous rechecking of your command that you can be sure that it is correct. But it would not execute. For example if could be something like this.

Eg: $ find . *.rpm

The problem here is the shell getting confused by the “*” mark in the name pattern we entered. Here is the solution. Use “\” as an escape character for the “*”.

Eg: $ find . \*.rpm

It is good practice to escape special characters anyway in the Linux command line, even if it is not mandatory. In this case however it could be mandatory.

Congratulations if you have come this far. Now you know a fair amount about how to use find properly; one of the most underutilized commands in Linux/Unix which is also a very powerful command. Before we wrap up todays article let us combine some the options we discussed into an advanced find command.

Eg: $ find /tmp -type f -iname fedora*.iso -size +3G -mtime 300 -exec cp {} ~/test/ \;

What the above command is supposed to do is search for files (only) with a name starting with “fedora” and ending with “.iso” which are over 3GB in size and have a last modified date within 300 days, ans then copy them into the directory located at “~/test”.

Well, that is just about what we have to say about the find command today. You let me know if that last command is correct or not.


Yum and APT

In the last issue we discussed some basic concepts behind package management in Linux. It is probably good to remind again that in moder Linux distributions installing/uninstalling software is handled via a package management tool. It might not be a very familiar concept to people from different backgrounds such as Windows and MacOS. However Linux users must be quite familiar with how managing packages are done.

The main plus point is you can get all the software you need using one method and having the ease of updating the system, and also keep receiving updates automatically. Once you wrap your head around the basics you will noticed that Linux is one of the easiest environments to install, manage and remove software. Package management itself is one of the features that sets Linux apart from the rest od the mainstream operating systems.

If you have not heard already, there are several package management system approaches in the Linux world. Here are some of the commonly found ones.


  • RPM/Yum – Used by Fedora, Red Hat Enterprise Linux, CentOS, openSUSE, SuSE Linux Enterprise Server, Mandriva, etc.
  • DPKG/APT – Used by Debian, Ubuntu, Mint, etc.
  • Portage – Used by Gentoo

There are many other tools available in the form of TGZ format files in Slackware distribution and so on. However RPM and DPKG based systems are notable very popular. Each of these systems may use a different set of tools for operations.


Relationship between packages, formats, tools and systems

We discussed what a package management system is, in the last issue. So you should have a fair idea about what to expect. In an extension to that we already discussed what is the relationship between a package management system and its tools. In short package management tools are the software tools we use to execute operations in a package management system. A package format is the anatomy or the composition of a package archive, while a package itself is a single archive of that particular format.

In example RPM based package management systems uses software packages of the RPM format and use tools such as “yum” command to execute operations such as add remove software.

Today we are going to look into the two most popular package management tools: Yum and APT.


RPM and Yum

RPM stands for RPM Package Manager (used to be Red Hat Package Manager). It was started by Red Hat but later became the package management infrastructure of choice for many Linux distributions including Fedora, RHEL, CentOS, openSUSE, SLES, Mantriva and more. Another notable fact about RPM is that it is the package format used in the Linux Standard Base, a standard for Linux distributions maintained by the Linux Foundation. If you do not know about the Linux Foundation, it is the primary non-profit consortium chartered to foster the growth of Linux which is also the employer of Linus Torvalds (creator and maintainer of Linux).

The native package format used in RPM is also named RPM packages usually with the extension “.rpm”. For example a released RPM package for the software called “checkinstall” could be “checkinstall-1.6.1-1.i386.rpm”. In our simple example we can notice that the software package in question is named “checkinstall” and is in the version 1.6.1-1 for the i386 (x86) hardware architecture.

RPM package format was developed earlier to be used in discreet package releases. Which means each and every new release would be a completely new full package. However recently the concept of package-deltas in the form of delta-rpms were added into this systems. This enables the RPM system to fetch only the changed portions of the software when a new version is released.

The command line utility to execute operations within the RPM system is named “rpm”. Let us now see a few RPM related commands.

To install a downloaded new package (located in the working directory) named “somepackage” with the version number 1.0.0 and hardware architecture neutral:
# rpm -ivh somepackage-1.0.0-1.noarch.rpm

To upgrade the “somepackage” from an older verion to the new version:
# rpm -Uvh somepackage-1.1.0-1.noarch.rpm

To freshen the package “somepackage”. Works only if “somepackage” is already installed
# rpm -F somepackage-1.1.2-1.noarch.rpm

To uninstall the package “somepackage”:
# rpm -e somepackage

To query which packages with a name starting with “some” are installed
# rpm -qa some*

To query the files installed by the package “somepackage”
# rpm -q somepackage --filesbypkg

To query which package incuded the file /etc/nanorc
# rpm -q -f /etc/nanorc

The RPM system was designed to handle only one version of a given software in a given system. This behavior complies with most of other package management systems available for Linux.

Even though RPM identifies missing dependencies for a package, RPM itself does not provide an easy means of solving dependency related issues. This and several other new features combined gave different vendors the idea to build high-level tools based upon RPM. For example tools like “yum” and “urpmi” came into being.

Yum started it’s life as YUM, the Yellow Dog Updater Modified as a part of the Yellow Dog Linux distribution. It was since been adopted by Red Hat as the preferred high level tool for package management providing additional features on top of RPM. For example it provides an easy means of handling dependencies by incorporating the concept of package repositories.


New Concept: Package Repository

A package repository is a location where a collection of software packages are stored for easy retrieval. For example most Linux package management systems use repositories to provide much needed software compilations where you can select and install. For example a 3rd party repository called RPMFusion (located at rpmfusion.org) is very popular among Fedora Linux users. Meanwhile the Fefora project hosts their official repositories too.

These package repositories can be added or removed from a system with ease. Fedora, RHEL and similar stores Yum package repositories related information inside the directory: “/etc/yum.repos.d/” directory while Debian/Ubuntu systems store APT repository information in “/etc/apt/sources.list” file.

So let us try a few Yum commands.

To search if there is a package with the pattern “vpn” in its name or the description
# yum search vpn

To list the details of the package “openvpn”
# yum list openvpn

To install the package “openvpn”
# yum install openvpn

To update the package “openvpn” into the latest version available
# yum update openvpn

To remove (uninstall) the package “openvpn”
# yum remove openvpn

To search for the names of package groups starting with “gn”
# yum grouplist gn*

To install the package group “GNOME Software Development”
# yum groupinstall "GNOME Software Development"

To downgrade the version of the package “leafpad” from the current version to the previous highest version
# yum downgrade leafpad

To see the summery of the past Yum transactions
# yum history

Further, Yum has this advanced mode called the yum shell. Yum shell is an interactive environment where you can run Yum based commands in succession. Once you have completed your commands you have to option to commit the changes you made. Yum will then take your operation and execute all in one single transaction. This feature alone can make a big difference in tricky situations.

Yum Shell can be invoked by running
# yum shell

As you can see clearly Yum/RPM provides a powerful package management infrastructure. It is also worthy of mentioning that RPM is the preferred format in the upcoming MeeGo distribution for Linux based hardware device (Eg: mobile phones, tablet PCs, media players, e book readers, etc.) sponsored by Intel and Nokia.



While RPM was available for Red Hat Linux in the 90s, Debian project had their own package management going. Their package format was called a Deb package which usually had the extension “.deb”. The command used for the operations was called “dpkg”. Here’s a few “dpkg” commands.

To install a downloaded new package (located in the working directory) named “somepackage” with the version number 1.0.0 and hardware architecture of i386:
# dpkg -i somepackage-1.0.0.i386.deb

To uninstall the package “somepackage”:
# dpkg -r somepackage

To query which packages with a name starting with “some” are installed
# dpkg-query -l some*

To query the files installed by the package “somepackage”
# dpkg -L somepackage

To query which package incuded the file /etc/nanorc
# dpkg -S /etc/nanorc

Even though the development of decent high end tools for RPM was fairly new, Debian had the upper hand there. They had APT, which stands for Advanced Package Tool for quite some time before Yum came into being. Naturally APT was better geared than “dpkg” to handle dependencies.

So let us now try a few APT based commands:

To search if there is a package with the pattern “vpn” in its name or the description
# apt-cache search vpn

To list the details of the package “openvpn”
# apt-cache search openvpn

To install the package “openvpn”
# apt-get install openvpn

To remove (uninstall) the package “openvpn”
# apt-get remove openvpn

As you can see APT also provides a feature set complete with advanced options. The choice of package management tools between APT and Yum are thus, largely a personal choice. It is however very incorrect to compare “apt-get” to “rpm” or, “yum” to “dpkg”. The low-level commands for each platform are “rpm” and “dpkg” while the high-level tools are “yum” and “apt-*” respectively.

Additionally there is a tool called “apt-rpm” which enables the use of APT system on RPM based distributions (Eg: Fedora, RHEL/CentOS). New generation tools like Smart Package Manager and PackageKit has the ability to use more than one package management toolset in a single system.


Graphical Frontends

Other than the command line tools, both of the above systems sport several GUI tools as frontends to their respective package management systems. Let us now take a brief look at two of them.

Recent versions of the Fedora distribution ship with a GUI application named “gpk-application” (mainly for GNOME Desktop Environment). It is a better replacement to the GUI tools previously available. The “gpk-application” also relies on the Yum/RPM and PackageKit integration in Fedora. It has the ability to search for packages, mark packages for install/uninstall operations, search and install package groups among other features. This tool is likely to appear in future versions of RHEL and CentOS too.

Image 1: gpk-application
On Debian/Ubuntu systems, again (mainly for GNOME Desktop Environment) there is the Synaptic Package Manager working as a frontend for DPKG/APT. It also has the ability to search for packages, mark packages for install/uninstall operations, among other things. One nice feature is the ability to generate a list of packages for future use or a script for separate downloading. It is also available under Ubuntu and Mint.

Image 2: Synaptic Package Manager


Package Management System Options

In the new year let us try to understand something slightly more advanced than our previous topics. We finished the last article telling you that we shall be discussing package management on Linux systems and pointing you to an article on Wikipedia. Those who saw the Wikipedia page might already have a basic idea of what we are about to start discussing today.

There are quite a few ways to install software in a Linux system. We will be getting introduced to a few common methods during this article. It could help you in the long run to decide between Linux distributions based on the package management criteria. However please remember that some of the methods and tools are quite uncommon while the rest is more or less popular. So there is no need to intimidate yourself with the variety of methods available.


Software and package management

First of all, you might be wondering why are we talking about this at all. Let us see why.

If you have used any computer operating system before, then you may be familiar with the concept of installing and uninstalling software on that system. What we mean by the term package management is essentially the same. So software package management is managing the install, update and uninstall of software.

A software package is a bundled collections of files, directories which form a software. A package can come in many formats. Those who come from the Windows world might already know of .msi type packages. In Linux also there are software packages. What we are going to discuss today is some of those package formats and how to work with those.


New Concept: Software Package

So you now know what package management is. What is a package anyway?

A package is a collection of files and metadata bundled into form a distribution of a software. From this point onward it is important to remember that a single software project might be distributed in several packages. Let us take the example of gedit, which is the default GUI based text editor on a lot of Linux systems. gedit usually comes split in to a few packages. In the Fedora Linux distribution, they are as follows:
gedit : Text editor for the GNOME desktop
gedit-devel : Support for developing plugins for the gedit text editor
gedit-plugins : Plugins for gedit

As you can see there are more than package containing the parts of gedit. The part everyone care is the package named “gedit”. It contains the executable gedit which will invoke the gedit editor. The package gedit-plugins contain the additional plugins which will provide extended features for the editor.


New Concept: Package Dependencies

As you saw in the previous section, some software projects are split into several different packages. In the previous example we saw gedit and gedit-plugins. So what would happen if we try to install just the gedit-plugins package, without the gedit package?

As we know gedit-plugins provide extended features for the gedit editor. However without gedit the gedit-plugins package has no purpose and cannot function. In such as situation, the system (with the help of the package management system) knows that the user should not be allowed to install gedit-plugins without gedit itself.


So are you thinking what immediate benefits are there of using a package management system? As we already know it makes installing software easy by handling dependencies. Then when you want to update your installed packages, a package management system will automate most of the process making it much easier than to update manually. In the case where you want to remove a software, you would have to go and delete all the files/directories and then the metadata manually unless you are using a package management software.

These are the most obvious and straight forward reasons to use a package management system. Sure, it adds a bit of a complexity. But as the benefits well out weight the added overhead. This is why all the major operating system support at least one proper package management mechanism by default.


New Concept: Package Types

In Linux there are at least two major package management systems and many more in the wild. This has given the rise to many different package formats. If you had tried installing some software on your Linux distribution of choice you might have already noticed a few different types. A package format is essentially a agreed upon standard way of putting a collection of files and metadata together.


Yum and APT (or RPM and Deb)

Yum and APT are arguably the most popular package management tools around for Linux. These respectively utilize package types RPM and Deb.

RPM initial stood for Red Hat Package Manager, but nowadays it just means RPM Package Manager. RPM is a package format which was initially developed by Red Hat and then adopted by SuSE, Mandriva (Mandrake) and many more. The popular Fedora distribution is also using RPM package format. Deb format of packages were initially developed by the Debian project, but are utilized in many other projects such as Ubuntu.

RPM and Deb packages can be manipulated within the system with the use of tools like rpm and dpkg respectively. For example here is how you install a software using those commands.

Eg: Install software package using 1st level tools
On Fedora
# rpm -ivh somepackage-1.0.0.rpm
# dpkg -i somepackage-1.0.0.deb

Eg: To uninstall a package:
# rpm -e somepackage
# dpkg -r somepackage


While these basic tools provide a useful method of working with packages, the high level tools such as yum and apt-get makes things very easy to handle. Let us take the following examples.

Eg: Search the package repositories for a package with a name matching a pattern
# yum search mysearch
# apt-cache search mysearch

Eg: Install a package from the repositories
# yum install mypackage
# apt-get install mypackage

Eg: Uninstall package
# yum remove otherpackage
# apt-get remove otherpackage

Eg: Update a package
# yum update updatepackage
# apt-gate update updatepackage


Portage, Pacman and others

While Yum/APT based package managements systems are the post popular they are by mo means the only options out their. Probably the most popular out of these alternative tools is the Gentoo Portage system which was inspired by the FreeBSD Ports systems.

Then there is other package management systems like Pacman tool available in Arch Linux and a several other different and more archaic systems.


PackageKit, SmartPM and the Hybrids

In the recent year there have been attempts to create more abstract package management tools which acts effectively as a frontend to existing package management tools. Perhaps the first popular attempt of this nature comes from the Smart Package Manager. However in the past few months a newer systems has taken a clear lead in this front; PackageKit

Originally developed by the innovation driving Fedora project, PackageKit aims to provide a common frontend to existing package management tools. It complies to the standards of the FreeDesktop.org and also integrates with PolicyKit, a framework to manage privileges in Linux systems. By today a number or major Linux distributions uses PackageKit/PolicyKit such as Fedora, Ubuntu/Kubuntu, OpenSuse, Foresight, etc.


It is always good practice to try to install the software using these package management tools. But in order to use these you will need to find a pre-packaged version of the software you are interested. Unluckily not every software is packaged. Software authors sometimes opt to not package their software at all owing to several reasons. One such common reason is the variety of package formats they need to convert to. To this end some of the software projects only provide an executable installer package or just a source code bundle.


Executable Installers

Various reasons prevent prevent authors from using conventional package manager compatible bundles. So some of them choose alternative executable installer options. Some of these installers are GUI based and some of these are command line based or both. This method of software delivery is usually discouraged as they bypass the package manager.

One common source of such delivery is commercial software vendors. While some companies like Adobe (Reader, Flash Player) and Google (Chrome, Picasa) provide traditional packages such as rpms and debs, some companies prefer executable installer approach. For example various game vendors who ship Linux versions of their software choose to a GUI based installer. The advantage of this approach is that it might be familiar to those who are from the Windows world. The obvious downside is that this will bypass the package manager thus making it unaware if the availability of that software. Which also means that if some other package requires it as a dependency, the package manager wouldn’t know that it’s already installed in the system.

One popular GUI based installer for Linux environment is BitRock Installer which can build installers to multiple target environments including Linux, Mac and Windows. In addition they give you the option to generate traditions RPM/Deb packages from your software.

Some of these alternative installer systems provide their own tracking system. For example Autopackage and Zero Install programs keep track of the software installed installed through them.


Compiled Software Archives

Some software are provided in an ready to run bundle format. You just need to extract them somewhere convenient for you and then run the software. For example some games such as Nexuiz and Urban Terror are provided in this manner.


Source Distributions and Tarballs

One of the most common package types you would encounter with FOSS projects is a source distribution. They are usually bundled into what it know as a tarball (i.e.: tar.gz or .tar.bz2). Extract such as archive and you will get the source code of the particular software. Then you have to build yourself.

To extract a source archive you can either use a regular GUI based tool (Eg: right click and select, Extract Here) or a command line. Here is how to use the command line with the different type of tar archives.

tar.gz – $ tar xzvf package.tar.gz
tar.bz2 – $ tar xjvf package.tar.bz2
tar.lzma or tar.7z – $ tar –lzma xvf package.tar.lzma

After this point you can either to compile & build the software or build & generate a package. There is no specific instruction from here onwards. You have to refer the install instructions for further instructions. These can be found usually inside the files INSTALL and/or README inside the source directory.

In common cases running the following 3 commands in sequence should suffice, but remember that there is a few popular build systems and some software need specific requirements to be built.

$ ./configure
$ make
$ sudo make install

Due to the possibility of a number of various scenarios, it is not feasible to describe every situation when building a software from source. Therefore it is highly recommended that you refer to the instructions from the particular software distribution.

One obvious downside of this approach is again, this process bypasses the package manager.


As you can see downloading some piece of software from Internet and installing it can be no-so straight forward in Linux. But the variety usually means there is a lot of flexibility. However as a beginner to the Linux is is highly recommended you use the provided software channels (Eg: package repositories) with the preferred tools. There are nice GUI tools to query, select and install/uninstall software from those channels without much trouble. Just look under System –> Administration or Applications –> Systems Tools menus to find such applications if you are using a GUI. If you are using only the command line, or prefer to use it the most convenient way is to use a tool like yum or apt-get.

However with the advent of PackageKit-like systems the software installation process seems to be going in a unifying direction, which can be a good thing. As of now, remember it is always best to go with a package management system. Even in its current state, only some reasonable adapting is required from you to be comfortable with managing software on Linux. Once you get use it, it will seem much organized with probably preferred workflows.

In the next issue, we will be discussing how to use Yum and APT based package management tools (i.e. how to use package management tools in Fedora/Red Hat and Debian/U


Command-line Tips and Tricks – Bash

In the past two issues we have been looking in detail the structure and organization of the Linux file system hierarchy standard (FHS). In this issue we will get back to the command line discuss a few tips and tricks for you to use, and also to impress your friends.


Tip 1: Tab Completion


The first tip I am going to give you is the tab completion. If you have been following the articles so far, there is a good chance that you have already found it. When you are about to enter a command in a terminal you can type part of that command and press the “tab” key to use the completion. For example if you want to enter the command “whoami” command, you can type “whoa” and press tab key to complete the rest. The command line will search in your systems and find which commands start from “whoa”, and use the results to complete what you are typing.


You might wonder what should be the case where there is more than one command starting with the letters you have typed before pressing type. In this case the command will not be completed. If you press the tab key again (resulting in two consecutive tab key presses), your command line will show you the possible completion options.



[gaveen@midgard ~]$ wh

whatis    which whiptail  whoami

whereis   while who    whois

[gaveen@ravana ~]$ who

who whoami  whois

[gaveen@ravana ~]$ who
As you can see in the example when you first enter “wh” and press tab key twice, the available completions will be displayed. To narrow down the possibilities then we entered an “o” to make the entered string “who”. The system narrows down the possibilities and then shows us that there are three possibilities starting with “who”. In my case typing an additional “a”, resulting in a “whoa” was enough for the system to narrow down the command possibilities to “whoami”.
Command completion is a useful feature, specially if you do a significant amount of work from the command-line. Is this a feature of Linux or the specific command line we are using?

New Concept: Shell


In Unix systems (and in non-Unix systems too), there is a concept called “shell”. A shell is an interface for the user to access the functions of an operating system. A shell can be command-line, a GUI or something different. For example the graphical user interface you see in many modern operating systems can be thought as a graphical shell, while command-line interfaces you find in Unix systems are command shells.


If you are running a Linux systems, it is highly possible that the default command shell available in your systems is “Bash”. Bash (Bourne Again Shell) is a modern Unix shell available for many Unix type operating systems including Linux. When you open a terminal program like GNOME Terminal or Konsole, or in the case where you use a text console in your Linux installation you are running a shell (most probably Bash).


So a shell is essentially an interface for the user to communicate with the operating system. There are many shell programs our there such as Bourne Shell (sh), C Shell (csh), Korn Shell (ksh), etc. By today the Bash is probably the most popular shell around.


The command line tips and tricks described in this article are for Bash. Now that you know tab completion you may want to give it a try before continuing.


Tip 2: How to get completion for options and parameters of commands


As you see command completion is a pretty nifty feature for bash built in commands. Have you ever wondered if this feature can be extended to further convenience.


You have already seen how command line completion helps you with directory/file names and so on. But how about options to commands? You still have to remember those. For example most Linux commands accept word based options. In such a case you are required to type the whole thing.

Eg: $ ls –version


This is just one simple example, but in the long run would not it be nice to have your shell support you out when you try to figure out what to input? That is why there is a very handy software package to do just that.


To use this you need to install a software package named “bash-completion” under most of the Linux distributions. Installing such software and package management cannot be discussed without more detail. That is why we are going to move that discussion into the next article. More details about the next article can be found towards the end of this article.


After you have the bash-completion package installed your shell will help you out when you try to use options for a command. Let us take the example where you want to tell the command “cp” to remove each existing destination file before attempting to open it. The option in question is “–remove-destination”. With the newly enabled completion aid you should be able to just type cp –rem and hit tab to get the option completed for you.


New Concept: Options


Well, this is not so much a new concept. After all you have been seeing it from article 1. But to make things more clear for you let me explain a bit about what an option is.


An option is something we pass to a command, usually in the form of a few characters to change the default behavior of the command. For starters you already know that while the “ls” command will provide a list of things in a directory by default, if you throw in the “-l” option the list would be in the longer more detailed format.


Options in Linux commands come in two major types (and an additional flavor). The two types are the short single character options and the longer word-like options. Let us take example for each type. The first type, the short options are usually single charactered but can be chained in use.


While “ls -l” will provide a long listing the “ls -a” will provide a listing consisting of everything (including hidden files). So the “ls -la” will provide a long listing of everything in the directory you are working. Similarly “ls -hal” will provide you a long listing of everything with the size of the files in human friendly format.


As you can notice the order of the options in such chaining does not matter. This is true as far as the option does not require any parameters. For example the “-t” option for mount command mandates a file system type after the option. So you cannot use any other option before you specify the type. In this case you can type the next option separately from the first option.

Eg: $ mount -t ext4 -v /dev/sda5 /mnt


Notice the usage of “-t” and “-v” options here are different from the chaining of options we discussed before.


The second major type of options is the longer, word-like options which are preceded by two “-” (hyphen/dash character). We have seen such options too.

Eg: $ ls –version


These type of options are longer and usually have more explanatory name. In the above example it is obvious what the options does; prints the version of the “ls” command you are using.


Mixing these two types of options are fine.

Ex: $ ls -l –author


The above example will display a long list and include a column stating who is the author of each file.


There is one last thing to mention before we move the additional option type. When using options of a command, there is no specific or preferred order to follow. They all carry the same weight as long as they do not conflict.


Now that you know the main two types of types of options let us see the 3rd type of options; bsd style options. Before I tell you what are they let me tell you a very little note on how the cam into being.


In traditional Unix systems the command options were usually the short format options with single character. As the Unix developed into different flavors, so did the command line. When the second-most popular branch of Unix gained popularity (from the University of California, Berkeley) their style of options also came to the public use. These options are typed without any trailing characters such as “-”, and works pretty much the same way the short type options we talked already.

Eg: $ ps aux


The above command will show you the list of all the processes running in your systems at the time of the execution of that command. The other type of the options (longer format) were popularized by the GNU project which provides a lot of command line utilities for Linux and other Unix operating systems.


The “ps” command is a good place of reference to the different types options as it supports all the 3 major types of options. The classic Unix style options (single letter options which can be grouped and preceded by a single “-”), BSD style options (single letter options which can be grouped and is not preceded by “-”) and finally the newer GNU style longer options (which are preceded by two “-” characters. i.e.: “–”).


Tip 3: Clearing a Terminal

If you have been practicing what has been discussed so far in this Linux basics series, you may have wondered if there is a way to clear the contents of a terminal. For example it is always less distracting when you work in a clean terminal rather than in a terminal with output from previously executed commands. If you were keen enough you might have found that the “clear” command clears a terminal. While this is great, it is still 6 key strokes to get there. We have a trick for you to make it quicker. Pressing Ctrl+l keys (i.e. pressing “Ctrl” key and holding it down while pressing “l”) will clear your terminal.


Tip 4: Keyboard traversing in a terminal


When you work in a terminal you are bound to get the need to move your cursor here ans there. You can always use your arrow keys. But pressing down an arrow key till the cursor reaches the point you need takes time, and after a few times it becomes frustrating. If you have typed a long command you usually do not want to hit backspace all the way back deleting what you have typed. Here are some keyboard shortcuts that should aid you.>


Ctrl+a will take you to the beginning of the line.


Eg: lets say you have typed something in a terminal, you have not hit the enter key yet because you need to go to the beginning of the line and add/change something. Currently your cursor is at the end of the line. In this case after “t”.


$ mount /dev/sdb1 /mnt


Pressing Ctrl+a will get the cursor to the beginning of the line. In this case to where the first “n” is. Think of it in this way. “a” is the beginning of the alphabet. So Ctrl+a means go to the beginning.


Ctrl+e in the opposite of Ctrl+a, which means Ctrl+e will take the cursor to the (E)nd of the line.


Ctrl+RightArrow or Alt+f will move the cursor to the next word, which means in the forward direction. It is more convenient if you want to jump from word to word instead of going through single characters.


Ctrl+LetfArrow or Alt+b will move the cursor one word backwords.


Next Issue


In the last couple of articles we have been going though the use of Linux command line. And in this article we discussed a few useful command line tips. As the articles continue we can find out more tips.


However our last few article ventures kept us in the command line. So you might be looking forward to go into the GUI for a change. So far we have discussed some essential things to make you comfortable with moving around and working in the command line, which is in my humble opinion is one of the advantages and true powers of Linux (and other Unix systems have). Since now you should be familiar with the Linux basics we can move on to more day to day topics and possibly more working time in the GUI if you prefer.


Linux systems usually inherit a concept called package management and in turn a concept called software packages. These concepts are actually related to system administration. However a user of a desktop Linux systems also need to search, install ans remove software. Because of this reason we will be dedicating the next article to package management. While there is no possible way of explaining every single available variant of package management software for Linux in a single or a few articles, we can try to discuss the basic concepts and usage quite quickly.


So get yourself busy on this months article, and try to get a picture of package management by reading the Wikipedia article http://en.wikipedia.org/wiki/Package_management_system


File System Hierarchy – Structure

Let me first apologize for the unavailability of the Linux article in last diGIT issue. On the bright side that could have given you plenty of time to get yourself comfortable with moving around a Linux file systems. Before we wander to different ares, let us wait a minute and revisit the file system.

By now, you already know how to move around in a Linux/Unix file system fairy easily. However you might be wondering about unfamiliar names and a different directory structure than you might have seen before. So let us venture in and have a more educated look.

If you remember correctly the Root directory included many other directories with interesting names like bin, var, usr, tmp, etc. Did you wonder if they were the result of creative naming or if it had a rationale behind it? The answer is that there is a rationale for why the directories are named in the particular manner.



A brief history of file system hierarchy in Linux

Traditionally Unix file systems had a hierarchically structured directory structure. As we discussed in the last issue, everything starts from the single called the Root of the file system (note as “/”). With time many variation of Unix systems were designed and implemented, including Linux. Since historically Unix lacked a common official standard, the structure of the directory organization usually had own touches of the individual distributions. This fragmentation was widened with the advancement of the technology. For example when the earlier Unix/Linux systems were designed, removable media optical (Eg: CD, DVD) or magnetic (Eg: hard disks, floppy diskettes) weren’t around as much as they are today. So naturally people went in different ways to organize things.

To overcome these problems on the then new found Linux, a release of a tentative standard was made in 1994. From that point onward it has been developing. As of this writing, the file system hierarchy standard (known as FHS) is at version 2.3 which was release in 2004. This standard document is not a set of golden rules, but rather a convention. As Linux is as customizable as you want to, there is no one to stop you from using whatever convention for the directory structure. However most of the major Linux distributions tend to adhere to FHS, at least for a certain level


FHS Organization

We are not going to discuss FHS in detail here. If you are interested in learning more about this standards and related information you could always visit the web site at: http://www.pathname.com/fhs/

So let us now take a more detailed look at a typical directory structure. Here we can discuss what are these directories actually meant for generally.

The root directory (/) is the root of the hierarchy. The bin and sbin directories are to hold the command binary files. The bin directory is the place to find the essential command binary files such as ls, cp, mv, rm and cat. As you might have already guessed, what we call a command binary is which is the executable file for the particular command. While bin holds the essential command binaries, the sbin directory holds systems command binaries which usually requires Superuser (administrator/root user) privileges to execute. This directory may typically hold commands such as mount, init, route, mkfs and modprobe.

The directory named “dev” is the place where a Linux systems holds the files representing devices. It includes files representing hardware (Eg: hda1, sda, ttyS0 and sr0) and also holds special device files required by the system (Eg: null, zero, random and urandom). While the special systems related device files tend to be the same in every systems, the hardware related device files differ from system to system based on the available hardware. For example a systems with only IDE disks will have devices starting with hd in their names (Eg: hda1, hdb1, hdc4) while systems with S-ATA or SCSI disks will have devices with names starting from sd (Eg: sda1, sdb3, sdc2).

The directory “/home” is the place where a normal user would spend most of the time. Usually in a Linux system a regular user will be allocated a home directory under “home”. This means, if your computer has many user accounts they each will have a home directory under “home”. For example my home directory is “/home/gaveen” while a user account named student may have her home directory located under “/home/student”.

While rest of the users have their home directories located under “/home” the super user (root) does not have a home directory there. The home directory of the user “root” is isolated from other home directories in “/root”. You can see that appearing in our directory listing in the example 1.

In the same listing you might have noticed a directory named “boot”. This is a very important directory in a Linux file system. The “boot” directory holds the files necessary for the boot process of the system. This usually hold the boot loader files, the operating system kernel and several more files. Because of the critical nature of this directory for the boot process, it is usually gives a separate disk partition.

The “tmp” directory which is pronounced “temp” is the place where a Linux systems holds temporary data. The content of this directory is cleaned periodically or during reboot (depending on the configuration). So it is not advisable to put anything important or anything you need to be persistent there.

The “var” directory holds data that is variable (changing). For example “var” is the place where log files, temporary e mail stores, printer spools are kept. If you have database management systems running, “var” is usually the place to hold that data too.

The “mnt” (pronounced “mount”) is a place which is kept to mount file systems temporarily. Do not worry about the new term “mount”. It is a little more advanced concept which we will be discussing shortly in this Linux article series. Few years ago “/mnt” was used to mount removable media such as floppy disks, CDs and DVDs. However the Linux vendors gradually started using “mnt” for what it was originally meant. They adhered to the FHS and started using the “/media” directory to mount removable media including CD. DVD, USB flash drives, etc.

“proc” directory is a special directory as it is not a physical space consuming directory. The “/proc” is a virtual space where the status of the systems is represented in text files. Thus one can change the state of many system components by editing the text files in “/proc”.

The last directory we are going to describe is the one probably consuming the most disk space in your Linux installation. It is “/usr” which is pronounced as “user”. This is the place where user programs go. Which means this is the place where the bulk of the things from your OpenOffice.org, Firefox, etc. is stored. So if you plan to install a lot of software in your Linux system, make sure that there is enough space in the “/usr”.

As you can see Linux file system organization is a bit different than that of Microsoft Windows. However there is no denying that things are quite organized. This is the basic introduction to what the directories does. If you wish to learn more about to FHS and the directory organization, the Wikipedia article http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard has much to offer.


Mounting a file system

In the previous section we have come across the term “mount” but there was no explanation given at that point. It might not be something you are already familiar with if you are from the Windows world. However if you have any previous knowledge about Unix systems there is a chance that you have heard about this.

Mounting is the concept of making a file system usable for the operating system. The term comes with a historical background where users had to physically mount a magnetic tape or a disk drive before using it. Even nowadays we have a similar thing going. An example would be using USB flash drives where you physically mount the device to the computer. What we call “mounting” happens after that. The device is read by the operating system and the file systems of the device is then mounted on the file systems of the running system. After that you are able to access the contents of the flash drive.

This is true to any file systems we can have. For example we can have disk partitions with a file systems which is not mounted by default. Consider the Windows system partition (usually identified as drive C: in the Windows world) is a multi-boot systems. It is there in the hard disk space but it is usually not accessible from the Linux system. If we want to access the Windows file systems we have to mount it.

As we know there is a place in the Linux file systems hierarchy to mount other file systems temporarily. If you are thinking of “/mnt” you are correct. In the scenario we are discussing, we can mount our Windows file system under “/mnt”. After this is completed successfully we can access the content of the Windows file system under “/mnt”. If there was a folder named “Windows” in your Windows file system, now it can be accessed as “/mnt/Windows”.

Let us take a little different scenario. Let us say that I have a hard disk with an old Linux installation which have four (4) disk partitions containing different Linux file systems.



Then suddenly I want to copy the photos from an old trip which is stored in my old hard disk, under the directory “home”. So I find and wipe the dust out from the old hard disk and plug it into my working computer. It is available as the device “sdb” inside the “/dev” of my working system. And now I am ready to copy the files. What would you suggest me to do? Here is what I did.

I needed to mount the file systems in the partition 3, which has a directory named “home” in it. To do this I had to have administrator privileges. Depending on the Linux distribution and version you are using the, the need to have administrator privileges may or may not be there. But as a general security practice, the ability to use the “mount” command (the command which is used to mount a file system) usually requires administrative privileges. So I used a command named “su” to switch to root user temporarily.

Note: We are not going to discuss “su” command in detail today, nor introduce it as a new command. The “su” command will be discussed in detail in a future article. For todays work enter the following command. While you are switched to the root user please only issue the commands in this following mounting section./p>

This is how to issue to su command to switch to root user. When asked for password enter the root/administrator password of the system.

[gaveen@ravana ~]$ su -




[root@ravana ~]#


Now that I was working temporarily as the use root, I went on to mount the file system.


New Command: mount

[root@ravana ~]# mount /dev/sdb3 /mnt


[root@ravana ~]# cd /mnt


[root@ravana ~]# ls




Let us try to understand what the above command does. In this command we tell “mount” command to use the device “/dev/sdb3″ and mount it on “/mnt”. I told you that the hard disk was using “/dev/sdb”. So it is perfectly natural for your to think “where did that sdb3 thing came from?”.

As the hard disk was “sdb”, the path to the device was “/dev/sdb”. But we specifically needed the Partition 3. That is where the “3″ in “sdb3″ come into play.

If the mounting is successful, usually you don’t get an output message. After I mounted the file system in the partition 3 of my old hard disk on “/mnt”, I could easily copy the files I needed. After the mount this is how my directory structure looked like.


Using “mount” command without any parameters and options will give you an output of already mounted file systems. Let us see an example.

Eg 2:

[root@ravana ~]# mount


/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)


proc on /proc type proc (rw)


/dev/mapper/VolGroup00-LogVol02 on /home type ext3 (rw)


/dev/sda1 on /boot type ext3 (rw)


/dev/sdb3 on /mnt type ext3 (rw)
The actual output you would see in your system should differ from the above example. However the pattern will remain the same.

In the above output we can see that our mounting operation was successful, because there is a line saying “/dev/sdb3 on /mnt type ext3 (rw)” (last line). Do not worry about the other details available in the output. We just wanted to make sure that the mounting was successful.

I hope now you have a fair understanding about the concept named “mounting”. Once you mount a file systems you will need to unmount them too. This is how you do it.


New Command: umount

The command “umount” does the opposite of mounting, that is unmounting. To do so first make sure you have all terminals, windows, dialog boxes opened from the file system you want to unmount (in this case: “/mnt”). Make sure you have no open files or there is no running operations from that file systems. If any of the above are still there, the unmounting would fail. Once you are ready to do the unmount operation there is the command to use.

[root@ravana ~]# umount /mnt


What we did was to tell the command “umount” to unmount the file system mounted under “/mnt”. Once you have unmounted you can run the “mount” command again and make sure it is not in the mounted file systems list


Next Issue

Congratulations for learning the more advanced concept of mounting. If you are not following this off the magazine, do not worry. It was provided here because I wanted you to understand what I meant by the term mount. It is a term you will often get to see in Linux guides, tutorials and other references. So I hope it will be useful for you in the future.

In the last two issues we have been talking about Linux file system hierarchy and organization and also the mount and umount commands. This is a lot digest for a new Linux user. So read well and let me know you feedback and any questions you have about the Linux article series so far. You can use the feedback form provided in the magazine for this purpose.

In the next issue we can move to the command line again and learn a few tricks and tips which would come handy (and also to impress your friends) when you work in command line.


File System Hierarchy – Lay of the Land

In the previous issue of diGIT we discussed a little background of Linux and what it is meant by a distribution (a distro). Then we went on to find how to log into a Linux systems and how to execute a few simple commands. Today we are going to find out how to find your way through a Linux file system.

New Term: File System

By the term File System I mean the structured organization of files and directories in a system. Please do not confuse this with other uses of the same term to note a technical implementation of such an organization. For example, by file system I mean the things like /usr directory tree. And the technical implementations like ext2/ext3/ext4 (Linux), FAT16/FAT32 and NTFS (Microsoft Windows) will be referred to as file system types. To avoid confusion the term will be used on lower case (i.e: file system) to identify the file organization.

Linux as many of the Unix systems has a hierarchical file system. Which means that the structure of the file organization is a tree-like structure with a single root point. So we call that point “the root”

New Term: Root

In Unix world the term Root can mean different things. When taken in a file system context, root refers to the single point of a file system hierarchy.

When taken in users and system privileges root means the Superuser (i.e: the user with all the administrative privileges, generally know as a system administrator). The root users home directory is usually located at /root. You should not confuse this with the root directory (i.e: /). Do not worry, you can see what these means in a few minutes.


Let us start with a simple commands we learned last week.

Eg 1:

[gaveen@ravana ~]$ ls

Documents   Pictures    Public    Templates   Videos

Desktop Download    Music Projects    Software

The root directory (i.e: /) is the topmost directory/location in a Unix file system. Within that directory there will be other files and subdirectories which will form the file system. Let us now have a look at what directories are there in a common Linux system and what are the purposes of them. However note that these standards are more like conventions rather than written-in-stone-rules. If you wish to stray away from the standard no one will stop you from doing just that, but if you plan to make your system public it is best to follow the standard. Besides that is the point of having a standard.

As you already know the ls command lists the contents of a directory, in this case the home directory. Using this command let us list the contents of the root directory.

Eg 2:

[gaveen@ravana ~]$ ls /

bin    boot   dev    etc    export fun    home

lib    media  mnt    opt    proc   root   sbin

srv    sys    tmp    usr    var

Your actual directory listing of / may be different than mine. However you should be able to figure out at least a few common items. Now let is take a deeper look into a file system. For this purpose I am going to show a listing of the file system tree/hierarchy of my Fedora Linux system. Do not worry about the names as some of the directories are created and named by me.

For the clarity I have ended each directory name with a “/” (Eg: bin/, rc.d/) where there are no “/” characters after a filename (Eg: passwd, shadow). The numbers/letters noted are there as future referencing points. The numbers notify a standard directory while an English letter notify a directory created by me (non-standard).


Now that we have a directory tree to examine let us start with how to note a directory and its path. Let us take the above examples for a moment. We already know that the home directory for user gaveen is in /home/gaveen and that the root directory is at “/”. Let us take some new examples to identify how you could correctly specify a file/directory location.

Eg 3:

Let us take location [A]. The directory name is “fun”. It is located directly under the root directory so we can specify the location as


If you decide to specify it as ‘/fun/’ it is still fine. The last “/” makes sure that you are referring to a directory and looks clear to you. If you do not use it, there is no harm done.


As you might have guessed, the starting “/” refers to the root directory. From now on you can be sure that any file/directory path starting with “/” means that we are specifying its location from the root directory.

Eg 4:

Let us now take the location [B]. According to what we have talked so far can you try to guess the path for the [B]? It is


Note the uppercase letter G in Games. Since the directory we are trying to refer to is actually named “Games” it should be specified exactly as Games. Any other usage of the word such as games, GAMES, GaMeS, etc. are not valid this is because of one important thing.

New Concept: Case Sensitivity

It should be noted that Linux is case aware and differentiate based on the case. In simple words Linux identified the difference between capital ans simple (uppercase and lowercase) letters. Because of this you can perfectly have all the four files named file, FILE, File, FiLE within the same directory. Unlike some operating systems (Eg: MS-DOS, Microsoft Windows 9x, Windows XP, etc.) you may or may not have used, Linux treats the above four files as four different files. Which means that you should be specifying file/directory names and also commands exactly as it is. For example, you cannot use “LS” instead of “ls” command.

The technical reasoning behind this is most Linux file system types (including the current de facto standard ext3) are both case sensitive and case preserving. Which means that they will not only identify the different between cases but also preserve the case properties. This is contrast to the NTFS file system type one could find with Microsoft Windows XP and similar. NTFS is case preserving, but does not differentiate between upper and lowercase.

Let us again get back to the examples we are discussing.

Eg 5:

Let us take [N] and try to specify its path. So it starts with “/” and the path goes like this

/home/gaveen/Software/Setups/NMS/Zenoss Core

But if you try to cd into it using this path it might produce an error similar to what you see below.

[gaveen@ravana ~]$ cd /home/gaveen/Software/Setups/NMS/Zenoss Core

bash: cd: /home/gaveen/Software/Setups/NMS/Zenoss: No such file or directory

So what went wrong? Why the system is trying to access a directory named Zenoss even though we wanted to access “Zenoss Core”?

The reason is the space in the directory name. While a space (whitespace) is a perfectly valid character to use in file and directory naming, Linux command line (in this case stated as “bash”) has a special use of the space and treats the space as a special character. To overcome this we can do a little trick.

Actually there are more than one way of doing this. The most common way is to tell the Linux command line that the space is not a special character. We can do this by adding a “\” (backslash) before a space (in a file/directory name) to escape the treatment of a special character.

[gaveen@ravana ~]$ cd /home/gaveen/Software/Setups/NMS/Zenoss\ Core

While this is the preferred way let us check another workaround.

[gaveen@ravana ~]$ cd “/home/gaveen/Software/Setups/NMS/Zenoss Core”

Both these techniques work. But the first one is used mostly because it works well with the tab-completion feature of the command line. We can discuss tab completion and a few more command line features in the next issue.

Exercise: Specify the paths in the above tree diagrams

Now that we know how to refer to any file/directory in a file system you can test your knowledge by specifying paths to all the other files and directories. Try to complete the listings from A – O and 1 – 17.

Absolute paths and relative paths

You can now traverse a Linux file system. For example let us go the location noted by [G].

Eg 6:

[gaveen@ravana ~]$ cd /home/gaveen/Software/Setups/

[gaveen@ravana Setups]$ pwd


As you can remember the pwd command will assure that you are inside the Setups directory.

Now what would you do if you want to change into [H]? You can try the following of course.

[gaveen@ravana ~]$ cd /home/gaveen/Software/Setups/Development

[gaveen@ravana Development]$ pwd


If you are feeling a little frustrated about the repetitive typing you had to do, there is goos news. You do not have to type the full path always. Let us see.

First you are already in “/home/gaveen/Software/Setups/” after the example 6. The directory named “Development” is right under that directory. Rather than typing in the full path you can just say go to the “Development” directory from this point. This is how you do it.

Eg 7:

[gaveen@ravana Setups]$ pwd


[gaveen@ravana Setups]$ cd Development/

[gaveen@ravana Development]$ pwd


There is one important thing to notice here. When you entered “cd Development”, there was no “/”(forward slash) before ‘Development’, thus not asking the command line to start from the root directory. This short variation of path is known as a relative path.

New Term: Absolute/Full Path

An absolute path is a path specified starting from the root directory. Eg: /home/gaveen/Software/Setups/Development

New Term: Relative Path

A relative path is a path specified from your current location on a file system. Which means the path you specify is relative to your current location. Because of this if you specify a relative path from a different working location (pwd) it will not be correct. The point is that a relative path is always relative to your current working directory and does not start with a “/”. Eg: Development/

The “.” and the “..”

If you have been following this far you might be wondering what to do in a case like this.

Eg 8:

[gaveen@ravana Development]$ pwd


You are in “/home/gaveen/Software/Setups/Development” but want to get to [K] which is “/home/gaveen/Software/Setups/Servers”.

As you can see both ‘Development’ and ‘Servers’ directories are located within a common parent directory “Setups”. But you are currently located one level below the ‘Setups’ directory (i.e: Setups/Development). You already know that we have to use the “cd” command. And you may be thinking of specifying the full path “Servers” directory. However there is a shortcut.

Eg 9:

[gaveen@ravana Development]$ pwd


[gaveen@ravana Development]$ cd ..

[gaveen@ravana Setups]$ pwd


[gaveen@ravana Setups]$ cd Servers/

[gaveen@ravana Servers]$ pwd


What we used was the “..” with the “cd” command. That is two dots.

New Concept: “.” and “..”

In Unix/Linux file and directory path convention the “..” refers to the parent directory of your current working location while the “.” refers to your current working directory.

So the work in example 9 can be done like the following way too.

[gaveen@ravana Development]$ pwd


[gaveen@ravana Development]$ cd ../Servers/

[gaveen@ravana Servers]$ pwd


As you can see we combined our understanding of relative paths and the “..” notation to get it done.

Here is a few useful hints to make your life easy when you browse through your file system.

$ cd ~

or just

$ cd

shall take you directly to your home directory. While

$ cd -

shall take you to the directory where you were before your last “cd” command.

There is one last tip I have to share before we conclude this issues article. That is, when you need to change into a directory quickly but temporarily and change back again. Say you are in “/home/gaveen/Software/Servers” and have a quick change into “/fun” and get back. This is how you do it.

Eg 10:

[gaveen@ravana Servers]$ pwd


[gaveen@ravana Servers]$ pushd /fun

/home/gaveen/Software/Servers /fun

[gaveen@ravana fun]$ pwd


[gaveen@ravana fun]$ popd


[gaveen@ravana Servers]$ pwd


Please note that the “pwd” commands listed in all the examples are there for the clarity. You are not required to type all those commands for just the functionality. For example you only need the “pushd” and “popd” commands from example 10.

Next Issue

Congratulations! Now you know everything you need to know in order to have a comfortable traversing of a Linux file system.

In next issue we can discuss more tips, hints and details about the Linux command line/shell. Until then have a good read of this important topic of file system and try to do the little work I mentioned above. If you are not clear about what are all the directories about, do not worry. We can discuss their purpose too in the next issue.


Say Hello to Linux

After the introduction on the February issue, today we are ready to start out Linux Basics series. First let me apologize for the absence from the March issue. I hope that break however gave you enough time to install or get access to a Linux system. While it is not mandatory to have a Linux system while you follow this series, it would be much better if you can try and practice the commands/operations along the way.

What is Linux?

You already know that Linux is an Operating System. I am pretty sure that you already have heard of commercial operating systems such as Microsoft Windows and Apple OS X. You may or may not have heard about classification of operating systems as Server operating systems and Desktop operating systems. While this kind of classifications are usually general and informal, nowadays these limits tend to blur. Anyway, you might be excited to hear that Linux is both a Server and Desktop capable operating systems. For example this article is written on a Laptop running a Linux system and when you see this on diGIT website, it will be hosted on a web server which is also running a Linux system.

As I said in the last article, Linux is probably the operating system running on the largest number of platforms with also a highly diverse set of implementations.

Is Linux a Unix?

Short answer is Yes and No. What is Unix anyway? UNIX was a name given (which later became a trademark) to an operating system developed by Ken Thompson and Denise Ritchie and several others in late 1960s. It was first owned by Thompson’s then employer Bell Labs of AT&T. Later UNIX developed into many different variations with different flavors, in which BSD UNIX (Berkeley Software Distribution by Computer Systems Research Group of the University of California, Berkeley) was one of the most notable. By today there are hundreds of different variants of the Unix family, but the original UNIX isn’t around anymore. In this sense Linux is a member of the Unix family which also includes the likes of FreeBSD, Solaris, OS X, MINIX, etc. However Linux does not have the legitimate right to use the UNIX trademark. This is the most notable reason for not calling Linux a Unix system. In order to avoid confusion the family of operating systems is usually called Unix-like systems. It can be noted that there is no pure descendants of the original UNIX developed and maintained anymore. Most of the existing Unix-like systems have incorporated developments from others. So I deem calling Linux a Unix-like operating system is as perfectly correct as it could be.

What is the latest Linux version? And what is Fedora, Ubuntu, Mint and all these?

So one of your friends gave you the latest version of Ubuntu Linux system which as of this writing is 8.10. You are happy to learn that until you find out that Fedora is already on version 10. This is a point where most new Linux users get confused.

The core part of a Linux system is called the Linux kernel. As of this writing the latest stable kernel version is Most of the Linux distributions such as Fedora, Ubuntu, Debian are shipped with a 2.6.2x series kernels usually a bit older than the latest stable version. For example Debian 5 has kernel version 2.6.26 while my Fedora 10 system currently runs a kernel in the 2.6.27 range.

Kernel version is not the only thing that defines the newness of a system. A lot of Desktop Linux users like to run newer versions of application software they use. For example as of this writing, the latest OpenOffice.org office suite version is 3.0.1 and the latest Firefox web browser version is 3.0.7. While newer versions are usually provided as updates, a lot of people find it convenient to use a Linux distribution which provides newer versions and which keeps updating regularly.

Technically speaking there is no meaning to the term “latest Linux operating system version”. However each and every different Linux distributions have a version number. It should be noted that the version numbering convention is not common to all the distribution. Ubuntu projects number their releases as in year.month syntax (Eg: 6.06, 8.04, 8.10, etc.) while Fedora uses an incremental numbering (Eg: 7, 9, 10, etc.). So you cannot compare Linux distribution by the version number. For example, Ubuntu 8.10 contains more updated software than Fedora 9.

What is this Distro thing anyway?

A Linux distribution, or more commonly spoken as a Distro is a Linux system bundled with other software, tweaks and enhancements usually complete with unique look and feel. Different distributions tends to be different in the approach they take. For example Fedora is usually targeting Desktop/Laptop users. So it usually includes software which are commonly used by desktop users. On the other hand a distribution like Red Hat Enterprise Linux is usually targeted for server environment. So it usually ship with server related software. However this is not to say that you can’t install server software on desktop distros or vice-versa. Unlike in Microsoft Windows and other commercial operating systems, there is no system capability limitation forced upon the user based on the distro you use.

Enough talking, let’s try something

When you boot a Linux system you will pass through different screen before finally presenting you with a login screen. People coming from Windows might be thinking whether there is a way to enable auto login into the system. It is possible, however most Linux distros by default does not allow that due to security concerns.


As any other operating system, Linux can also support many types of authentication systems. The most common type of these is the username/password based authentication.

You will be presented with a screen either with a Graphical User Interface (GUI) or a Command-Line Interface (CLI) in most common cases. It will prompt you for a username and a password. If you installed the system, you might have created the account yourself. If not contact your System Administrator for your login details.

If you are using a CLI to login, first type your username at the prompt and press Enter (Return) key. Then it will prompt for a password. Unlike when keying the username, the password prompt might not show the number of characters entered. This is also a security measure.


Fedora release 10 (Cambridge)
Kernel on an i686 (tty2)

ravana login: gaveen
Last login: Fri Mar 20 08:37:41 on :0
[gaveen@ravana ~]$

If you are using a GUI login to log in you might be greeted with many different graphical login prompts. In most you will have to either do as if it was a CLI login or click on your username if it is already available in a list. Then it will prompt for the password. Key in your password and press Enter (Return) key.

These steps will log you in to a Linux system. If you were using a GUI login screen, then most probably you will be taken to a graphical desktop environment completes with windows, menus, icons and a pointer. We will keep the topic of how to navigate and operate the GUI desktop to another month. From this point onward this issues article will concentrate on how to use a CLI to do simple tasks in your Linux system.

Opening a Terminal

If you used a CLI login prompt, most probably you’ll automatically get to a CLI based environment where you can execute commands. If you are in a GUI based environment you can start a terminal program. Click on the main menu and look for an entry similar to Terminal. For example in a Fedora Linux system, you can start the gnome-terminal program by following this menu path:

Applications –> System Tools –> Terminal

In come systems you can start a terminal program by right clicking on the Desktop and selecting Open Terminal entry. Whatever the case maybe you will get a window (the terminal program) where you can enter commands to execute.

Eg: You might get a terminal with a prompt similar to

[gaveen@ravana ~]$

What the prompt say will be different in your system, but you will most probably get a terminal with a blinking cursor. This is your new friend.

You might be wondering what are the parts displayed in the prompt saying thing like ravana and gaveen. Do not worry about that for now. For the curious, in a Fedora system the prompt is displayed as <code>[username@hostname pwd]$</code> pattern where username is your login username, hostname is the name of the computer and pwd is the current directory. According to that gaveen is the username and ravana is the computer name I’m working in. We will discuss these later, so you do not have to worry.

New Command: ls

One of the most basic commands you’ll learn is ls. It is so simple and yet you will use it many many times than you would care to remember in your life. What is does is list the contents of a directory.

New Term: Directory
Think of a directory as a place where you keep other directories and files. If you have used other operating systems before, you might already know about a similar concept called Folders. If you are more comfortable with calling these things Folders, you are free to do so.

New Convention: Abbreviated Names
Think of ls as a shorten form of the word list. Like ls many Unix/Linux commands are actually shorten forms of more descriptive terms. This convention not only applies for commands for commands (Eg: ls, cp, rm), but also for system directory naming too (Eg: tmp, proc, mnt).

So lets go ahead and execute ls command.

Eg 1:

[gaveen@ravana ~]$ ls
Documents   Pictures    Public    Templates   Videos
Desktop     Download    Music     Projects    Software

Example 1 shows how the ls command lists the contents of my directory. Yours might differ from the above listing. If nothing appears after you run the ls command, that means that there is nothing inside the directory your working on.

Now let us list the contents of a different directory. Let us list the contents of the directory Music.

Eg 2:

[gaveen@ravana ~]$ ls Music
Hindi   Music   Sinhala   Tamil   Western

Example 2 shows that when when we run the ls command for Music directory it shows us the content of that as Hindi, Music, Sinhala, Tamil, Western.

Now what if you want to list contents of more than one directory.

Eg 3:

[gaveen@ravana ~]$ ls Music Software
Hindi  Music  Sinhala  Tamil  Western

Setups  Sources

Example 3 show how to list the contents of directories Music and Software. As you can see, contents are listed separately.

If you follow this patter you can list more than two directories. All the parameters you pass in this manner to the ls command will be considered a directory (or a file) and will be listed. Let me leave that exercise for you to try out.

As you have seen, the ls command does the simple task of listing the contents of a directory. All you have seen so far is simple listings. It’s not all. The ls command can do more things. Let us try something then.

Eg 4:

[gaveen@ravana ~]$ ls -l Software
total 8
drwxrwxr-x 41 gaveen gaveen 4096 2009-03-18 23:40 Setups
drwxrwxr-x 33 gaveen gaveen 4096 2009-03-19 23:52 Sources

Example 4 will give a more detailed listing of the directory Software. The “-l” option (think of it as shorten for long) is responsible for that. The letters given with a “-” (hyphen) after the command are the options of the command. There are many more options for ls command as well as for most of other Linux commands. We shall discuss them on our way. Another thing to notice is options can be combined to get desired results.

Lets get the option “-h” (human friendly formatting) can be used along with the “-l” option to get a long list which is formatted more human friendly. Which means the sizes will be display in kilobytes (kB), megabytes (MB) and gigabytes (GB). See Example 5.

Eg 5:

[gaveen@ravana ~]$ ls -lh Software
total 8.0K
drwxrwxr-x 41 gaveen gaveen 4.0K 2009-03-18 23:40 Setups
drwxrwxr-x 33 gaveen gaveen 4.0K 2009-03-19 23:52 Sources

New Command: pwd

When you work in a Linux system you are bound to traverse through many directories and file systems. It is easy to get lost. How would you find your current location? How would you know in which directory you are working in? The answer is the pwd command. Think of it was an abbreviation of “Present Working Directory”. The pwd command will tell where you are.


[gaveen@ravana ~]$ pwd

The example shows you that pwd command produces the output of the current working directory. No matter where ever you are in your system, the pwd command will tell you where you are.

New Command: cd

Now that you know how to list the contents using the ls command, and to check your working directory using pwd command, you must be wondering how to go to other directories in your computer. To achieve this we use the cd command. Think of it as an abbreviation of “Change Directory”. The syntax is simple. First you type cd and then after a space the destination directory.

Eg 1:

[gaveen@ravana ~]$ pwd
[gaveen@ravana ~]$ cd Music
[gaveen@ravana Music]$ pwd

In example 1 you can see that we used the cd command to change into the Music directory and used the previously learned pwd command to confirm out location. The first pwd command is given to confirm that we were not in the Music directory in the first place.

Next Month

If you read the article carefully you might me wondering why the working directory is list as <code>/home/gaveen/Music</code> when we changed into the directory named “Music”. The reason is because it is the actual location of the “Music” directory. Which means that the directory “Music” is in a directory named “gaveen”, which in turn is in a directory named “home”. It might get a little confusing if I try to explain where that “home” directory is. That’s why we leave to to the next month.

In the next diGIT issue we will discuss the Linux file system hierarchy. After that you will be able to find your way inside any Linux system. Meanwhile try to get your hands on a Linux system and try different things. Read more about Linux online and try to practice what you learn. Until we meet again in the next month have a good time, welcome the summer and have a happy Sinhala and Tamil new year!


Linux: The Revolution OS

On 25 August 1991, a Finnish student named Linus Torvalds posted a message in an Internet newsgroup about a hobby software project he was doing. He had no idea how wrong he was regarding the content of that message. Linus’s particular message started with a disclaimer and went on confirming about the hobby nature of his project.

“I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones…

…and it probably never will support anything other than AT-harddisks, as that’s all I have :-[i]

Then 22 year old Linus, honestly believed that his project would be a fun project and just that. He was considering the name Freax for his OperatingSystem (OS). However the person responsible for allocating storage for Linus’sfiles didn’t like the name and created the space under the name Linux [ii]. Today, roughly 18 years later, we all know and call that piece of software as Linux. Linus was utterly wrong about his predictions about his own OS.

Image1:Linus Toriyalds  

Image 2: A Typical Modern Linux Desktop
Image 3: Tux – The Linux Mascot

Today Linux powers computers ranging from our common desktop and laptop PCs to the tiniest embedded computers to the fastest of Super Computers. In fact as of this writing, the worlds fastest Super Computer, named Roadrunner runs Linux. This article you are reading, is being written on a laptop computer running Linux. It is a common knowledge that Linux is the OS which runs on the most diverse collection of platforms including mobile phones, cameras, netbooks, gaming consoles, telecommunication devices, networking equipment, set-top boxes, web servers, et.


The Other OS, the free one

In short terms Linux has grown into one of the most widely used operating systems ever, and that is even without having a company controlling it. Linux is in fact an operating systems developed by people for people. It is one of the best examples can be given for Free and Open Source Software (FOSS). Which means, unlike most of the operating systems you might have used or heard, Linux gives you the full freedom with the software. This freedom includes the freedom to use, modify and redistribute, all which are 100% legal.

As you might already know, most of the software you download or copy freely from friends or buy cheaply from Unity Plaza are pirated copies and are illegal. However using, modifying, copying and redistributing FOSS such as Linux is perfectly legal. While Linux (or sometimes called as GNU/Linux) provides an alternative to proprietary operating systems, many other FOSS applications provides alternatives to different types of other proprietary software. Chances are you have already heard or experienced them. For example Firefox, Konqueror (web browsers), Evolution, Thunderbird (e mail), MPlayer, VLC, Amarok (media playback), Pidgin (IM), OpenOffice.org (office productivity) are some applications which are FOSS and available under Linux. More information regarding what FOSS is and their background shall be discussed in detail elsewhere in Digit.


Image 4: A Linux system with an E17 Desktop Environment
Image 5: A Linux system with a KDE Desktop Environment
Game Plan

After reading this far of this article, you might be wondering what to expect from this Linux series. Here is what we are going to do.

Linux itself is a powerful, secure and stable alternative to common desktop operating systems. There are thousands and thousands of users who use Linux as their desktop (day-to-day) OS, and the number is always growing. Starting from today in Digit, we shall initially focus on how to get you intimate with Linux basics, and allow you move around and get things done with a Linux system with comfort. Finally we hope to make you efficient with the art of mixing Graphical User Interface (GUI) and Command Line Interface (CLI)

The Linux basics series shall continue as tutorials. It would be much beneficial if you can practice what appears on Digit issues. The best way and the only way to properly learn Linux is to try it. So it is highly encouraged to try the examples and explore on your own. Let us now try to setup the work environment for the Linux sessions.


Image 6: A Linux system with a GNOME Desktop Environment
Image 7: MPlayer media player playing a video

A quick way to try Linux is to boot (start) your computer with a Live Disk. A live CD/DVD is a disk which can be used to boot a computer into a working environment. The hard disk is left untouched while you work within that live environment. When you are done, you can remove the disk from the drive and reboot (restart) the computer. However it should be noted that the changes you make to the live system are not persistent (i.e. the changes are lost when you reboot), thus it will give you a nice sandbox to play.

I recommend Fedora, Mint or Ubuntu live disks as they can be used for installations too. You can download the ISO images from the respective web sites and burn them. If you have speed, bandwidth or Internet connectivity problems, you can always borrow a disk from a friend and make a copy. It’s perfectly legal and even encouraged. If you still can access Internet, you can order a free Ubuntu CD from Ubuntu Shipit service. It is totally free and send a CD to your home. You will need a Launchpad account (free registration) for the ordering process.

If you wish to install Linux systems for long term use, you can find online guides for Fedora 9 / 10, Ubuntu 8.04 / 8.10 installations. If your Linux distribution version is different, try to follow the above links for general guidelines. For your convenience, please avoid installing outdated versions (Eg: Fedora version before 9, Ubuntu version before 8.04, Mint version before 5, All older Red Hat version like 8, 9).


In March

That is it for the introductory. I hope that you will have already looked into Linux systems and probably looking for more by the time Digit March issue comes out. I hope to discuss a bit of Linux history, why there are different version of Linux systems (Eg: Fedora, Ubuntu, Mint, SuSE, Debian, Gentoo, etc.), then log you into the system using GUI/CLI and try a few Linux commands.

[1] http://groups.google.co.uk/group/comp.os.minix/browse_thread/thread/76536d1fb451ac60/b813d52cbc5a044b

[2] Torvalds, Linus and David Diamond, Just for Fun: The Story of an Accidental Revolutionary, 2001, ISBN 0-06-662072-4

[3] http://www.top500.org/system/9707