1) find = finds one or more files assuming that you know their approximate filenames


find -name mypage.htm
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.

find / -name mypage.htm
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.

find -name file*
In the above example the system would search for any file beginning with file in the current directory and any subdirectory.

find -name ‘*’ -size +1000k
In the above example the system would search for any file that is larger then 1000k.

find /usr -name *stat

Find every file under the directory /usr ending in “.stat”.

find / -mtime -2 -print

Search the system for files that were modified within the last two days (good candidates for backing up)

More examples: http://www.oracle.com/technology/pub/articles/calish-find.html


2) locate = find files by name

Searches are conducted against a database of system contents that is updated periodically. To update the database, use the updatedb command.

locate "*.png"

to display all files on the system that have the .png filename extension

locate "*.png" -q

to suppress error messages, such as those that might be returned in the event that the user does not have permission to access designated files or directories

locate -n 15 "*.html"

display only 15 results in a search for files that have an .html extension:

locate "*.html" | less

presents only one screenful of output at a time

locate -i "*.HtmL"

The -i option performs a case-insensitive search. That is, it will return any results that match the arguments regardless of whether individual letters are lower case or upper case.


3) whereis = the whereis command is used to locate the binary, the source code and the online manual page for any specified program. Take note it is not for searching your files.


whereis locate

locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz

whereis -b locate (search only binaries)

locate: /usr/bin/locate


4) sort =  sort lines of text files

sort can be used in many ways, below are some simple examples

a) example 1

assume i have 1 text file with name fruits containing below


and another text file veggy with contents below


sort fruits veggy : it will produce output in alphabetical order as below


sort fruits veggy > fruitveggy : this command will save into a file fruitveggy

b) example 2

i can create a text file that is sorted in real time, for example, by typing

sort > color

it will put me into data entry mode, i can keep entering data for example blue, green, yellow each followed by <enter> command. once im done, pressing Ctrl-D keep me back at command prompt. now if i check the text file color i can see alll my input is there already sort out

c) example 3

i have a data file data.txt as below:

24 John
45 Sharon
98 Robert

i want to sort it on second field (name by alphabetical order), i can use this command

sort -d -k 2 data.txt , the output will be

24 John
98 Robert
45 Sharon

Explanation: The ‘-d’ switch stands for ‘dictionary sort’ and ensures that sorting

takes place alphabetically as a dictionary would do it. The ‘-k’ switch

stands for ‘key’ and with the ‘2’ tells sort to sort on the second

field in the file, that is the names.


5) grep = finds text within a file

grep tutorial *.htm = search all .htm files in the current directory for the text “tutorial”

grep -i love history.txt = print all lines containing love (ignoring uppercase and lowercase) in history.txt

grep -ic “love me” history.txt = To print just the number of lines containing the word “love me”

grep -r tutorial * = -r is to search not only in the current directory but recursively in all the sub directories, the symbol * means to search all files

ls | grep readme = this command is to print all files that has the phrase “readme” in the filename. take note it is not the text inside the document but the name of the document

ls -l | grep rwxrwxrwx = to find all filesystem objects in the current directory whose permissions have been set so that any user can read, write and execute them



The /bin/ Directory

The /bin is a standard subdirectory of the root directory in  that contains the executable (i.e., ready to run) programs that must be available in order to attain minimal functionality for the purposes of booting (i.e., starting) and repairing a system.


The /boot/ Directory

The /boot/ directory contains static files required to boot the system, such as the Linux kernel. These files are essential for the system to boot properly.


The /dev/ Directory

The /dev/ directory contains device nodes that either represent devices that are attached to the system or virtual devices that are provided by the kernel. These device nodes are essential for the system to function properly. The udev demon takes care of creating and removing all these device nodes in /dev/.

Examples of common files in the /dev include:

/dev/hda - the master device on primary IDE channel.
/dev/hdb - the slave device on primary IDE channel.
/dev/tty0 - first virtual console.
/dev/tty1 - second virtual console.
/dev/sda - first device on primary SCSI or SATA channel.
/dev/lp0 - first parallel port.


The /etc/ Directory

The /etc/ directory is reserved for configuration files that are local to the machine. No binaries are to be placed in /etc/. Any binaries that were once located in /etc/ should be placed into /sbin/ or /bin/.

/etc/opt/ – Configuration files for /opt/.

/etc/X11/ – Configuration files for the X Window System, version 11.

/etc/sgml/ – Configuration files for SGML.

/etc/xml/ – Configuration files for XML.


The /lib/ Directory

The /lib/ directory should contain only those libraries needed to execute the binaries in /bin/ and /sbin/. These shared library images are particularly important for booting the system and executing commands within the root file system.


The /media/ Directory

The /media/ directory contains subdirectories used as mount points for removeable media such as usb storage media, DVDs, CD-ROMs, and Zip disks.


The /mnt/ Directory

The /mnt/ directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removeable media, please use the /media/ directory. Automatically detected removeable media will be mounted in the /media directory.


The /opt/ Directory

A package placing files in the /opt/ directory creates a directory bearing the same name as the package. This directory, in turn, holds files that otherwise would be scattered throughout the file system, giving the system administrator an easy way to determine the role of each file within a particular package.

For example, if sample is the name of a particular software package located within the /opt/ directory, then all of its files are placed in directories inside the /opt/sample/ directory, such as /opt/sample/bin/ for binaries and /opt/sample/man/ for manual pages.

Packages that encompass many different sub-packages, data files, extra fonts, clipart etc are also located in the /opt/ directory, giving that large package a way to organize itself. In this way, our sample package may have different tools that each go in their own sub-directories, such as /opt/sample/tool1/ and /opt/sample/tool2/, each of which can have their own bin/, man/, and other similar directories.


The /proc/ Directory

The /proc/ directory contains special files that either extract information from or send information to the kernel. Examples include system memory, cpu information, hardware configuration etc


The /sbin/ Directory

The /sbin/ directory stores executables used by the root user. The executables in /sbin/ are used at boot time, for system administration and to perform system recovery operations.


The /srv/ Directory

The /srv/ directory contains site-specific data served by your system running Red Hat Enterprise Linux. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the /home/ directory.


The /sys/ Directory

The /sys/ directory utilizes the new sysfs virtual file system specific to the 2.6 kernel. With the increased support for hot plug hardware devices in the 2.6 kernel, the /sys/ directory contains information similarly held in /proc/, but displays a hierarchical view of specific device information in regards to hot plug devices.


The /usr/ Directory

The /usr/ directory is for files that can be shared across multiple machines. The /usr/ directory is often on its own partition and is mounted read-only. At a minimum, the following directories should be subdirectories of /usr/:

   |- bin/
   |- etc/
   |- games/
   |- include/
   |- kerberos/
   |- lib/
   |- libexec/
   |- local/
   |- sbin/
   |- share/
   |- src/
   |- tmp -> ../var/tmp/

Under the /usr/ directory, the bin/ subdirectory contains executables, etc/ contains system-wide configuration files, games is for games, include/ contains C header files, kerberos/ contains binaries and other Kerberos-related files, and lib/ contains object files and libraries that are not designed to be directly utilized by users or shell scripts. The libexec/ directory contains small helper programs called by other programs, sbin/ is for system administration binaries (those that do not belong in the /sbin/ directory), share/ contains files that are not architecture-specific, src/ is for source code.

The /usr/local Directory

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable among a group of hosts, but not found in /usr.

The /usr/local/ directory is similar in structure to the /usr/ directory. It has the following subdirectories, which are similar in purpose to those in the /usr/ directory:

        |- bin/
	|- etc/
	|- games/
	|- include/
	|- lib/
	|- libexec/
	|- sbin/
	|- share/
	|- src/


The /var/ Directory

Since the FHS requires Linux to mount /usr/ as read-only, any programs that write log files or need spool/ or lock/ directories should write them to the /var/ directory. The FHS states /var/ is for:

…variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.

Each type of filesystem has its own set of rules for controlling the allocation of disk space to files and for associating data about each file (referred to as metadata) with that file, such as its name, the directory in which it is located, its access permissions and its creation date.


Minix filesystem

1) The earliest versions of Linux used the Minix filesystem, which was developed by Professor Andrew S. Tanenbaum for use in his MINIX operating system, a small clone of UNIX that was intended only for computer science education purposes.

2) Although mostly free of bugs, it suffered from a small maximum partition size of 64 megabytes and a file name length limit of 14 characters.


The extended file system, also called Ext

1) Was released in April 1992 and was included in the Linux kernel (i.e, core of the operating system) version 0.96c.

2) It overcame the main Minix limitations by allowing a huge increase in maximum partition size to two gigabytes and file names of up to 255 characters

3) However, ext still had problems: in particular, it lacked support for separate access for each user and group, and it also lacked timestamps for modifications to inodes and to data. An inode is a data structure on a filesystem on Unix-like operating systems that stores all of a file’s metadata except its name.

4) Another problem was that the linked lists data structure ext used to track free blocks and inodes gradually became unsorted as the filesystem was used, thus causing the filesystem to become fragmented (i.e., parts of files widely dispersed rather than in contiguous blocks).


Ext2 filesystems

1) Ext2 was initially designed by Rémy Card, a French software developer, based on ext but incorporating many ideas from the Berkeley Fast File System and with extensibility in mind.

2) Ext2 features (1) improved algorithms that greatly increase its speed, (2) additional timestamps (such as date of last access and date of last inode modification), (3) the ability to track the state of the filesystem and (4) support for a maximum file size of 4TB (one terabyte equals 1024 gigabytes).

3) It maintains a special field in the superblock that indicates the status of the filesystem as either clean or dirty; the latter will trigger a utility to scan the filesystem for errors. As a result of these improvements, ext2 has completely superseded ext.

4) Ext2 is designed so that data is held in blocks of equal size on the HDD or other storage medium, although blocks can be different sizes on different partitions, different HDDs, etc. The size is set when the filesystem is created by the mke2fs program. The disadvantage of this approach is that an average of half of the block size is wasted for each file. For example, with a a block size of 1024 bytes, each 1025 byte file would require two blocks.


Ext3 filesystems

1) Ext3 has been integrated into the Linux kernel since version 2.4.16 and has become the default filesystem on Red Hat and some other distributions. It is basically an extension of ext2 to which a journaling capability has been added, and it provides the same high degree of reliability because of the exhaustively field-proven nature of its underlying ext2.

2) Also featured is the ability for ext2 partitions to be converted to ext3 and vice-versa without any need for backing up the data and repartitioning. If necessary, an ext3 partition can even be mounted by an older kernel that has no ext3 support; this is because it would be seen as just another normal ext2 partition and the journal would be ignored.

The ext3 file system adds, over its predecessor:

  • A Journaling file system
  • Online file system growth
  • htree indexing for larger directories (specialized version of a B-tree — not to be confused with H tree)



1) ReiserFS, developed by Hans Reiser and others, was actually the first journaling filesystem added to the Linux kernel. As was the case with ext2, it was designed from the ground up for use in Linux.

2) However, unlike ext3, it was also designed from the ground up as a journaling filesystem rather than as an add-on to an existing filesystem, and thus it is widely considered to be the most advanced of the native Linux journaling filesystems.

3) Features include high speed, excellent stability and the ability to pack small files into less disk space than is possible with many other filesystems.

4) A new version of ReiserFS, designated Reiser4, was scheduled for release in the first half of 2004. It is a complete rewrite from version 3 and is said to result in major improvements in performance, including higher speeds, the ability to accommodate more CPUs, built-in encryption and ease of customization.



1) JFS was originally developed by IBM in the mid-1990s for its AIX Unix operating system, and it was later ported to the company’s OS/2 operating system. IBM subsequently changed the licensing of the OS/2 implementation to open source, which led to its support on Linux.

2) JFS is currently used primarily on IBM enterprise servers, and it is also a good choice for systems that multiboot Linux and OS/2.

3) JFS provides fast file system restart in the event of a system crash. Using database journaling techniques, JFS can restore a file system to a consistent state in a matter of seconds or minutes, versus hours or days with non-journaled file systems.



1) XFS was developed in the mid-1990s by Silicon Graphics (SGI) for its 64 bit IRIX Unix servers. These servers were designed with advanced graphics processing in mind, and they feature the ability to accommodate huge files sizes.

2) The company likewise converted XFS to open source, after which it was also adopted by Linux. Because it is a 64-bit filesystem, XFS features size limitations in the millions of terabytes (in contrast to the still generous 4TB limit of ext2).

The XFS filesystem provides the following major features:

  • Quick Recovery The XFS journaling technology allows it to restart very quickly after an unexpected interruption, regardless of the number of files it is managing. Traditional filesystems must do special filesystem checks after an interruption, which can take many hours to complete. The XFS journaling avoids these lengthy filesystem checks.
  • Fast TransactionsThe XFS filesystem provides the advantages of journaling while minimizing the performance impact of journaling on read and write data transactions. Its journaling structures and algorithms are tuned to log the transactions rapidly.

    XFS uses efficient tree structures for fast searches and rapid space allocation. XFS continues to deliver rapid response times, even for directories with tens of thousands of entries.

  • Massive ScalabilityXFS is a full 64-bit filesystem, and thus is capable of handling filesystems as large as a million terabytes.
  • Efficient AllocationsXFS implements extremely sophisticated space management techniques. Efficiency in space management has been achieved through the use of variable sized extents, rather than the simple single-block-at-a-time mechanism of many other filesystems. XFS was the first filesystem to implement delayed space allocation for buffered writes, supports direct I/O, provides an optional realtime allocator, and is able to align allocations based on the geometry of the underlying storage device. The XFS allocator performs admirably in the presence of multiple parallel writers, and is renowned for its resistance to space fragmentation under such conditions.
  • Excellent BandwidthXFS is capable of delivering very close to the raw I/O performance that the underlying hardware can provide. XFS has proven scalability on SGI Altix systems of multiple gigabytes-per-second on multiple terabyte filesystems.



Feature ext2 ext3 ReiserFS3.6 (not supported by Oracle)
Maximum partition size 4TB 4TB 16TB
Maximum file size 2GB-2TB 2GB-2TB 8TB
Block size 1KB-4KB 1KB-4KB 4KB only
Journaling capabilities No Yes Yes
Reboot after a crash Slow Fast Very Fast
State of data after crash Good Very Good Fair
ACL support Yes Yes No
Stability Excellent Good Good

All the color settings is in this file: /etc/DIR_COLORS. In example below I will show how to change the color for  directory listing. The default font color for directory/folder is dark blue with black background so I want to change it so that it is easier to read.

The steps as below

1) use any editor to modify the file, example : vi /etc/DIR_COLORS

2) Scroll down until you find this:     DIR XX;XX       # directory (XX = 2 digits number)

3) Change the font color using the code shown below. For example if I want the folder to be shown as yellow with black background i will change the line to  DIR 33;40       # directory

4) Save the file. If using vi use this command: !wq <enter>

5) To have the color to have effect in root ,  copy the file to root directory

cp /etc/DIR_COLORS /root/.dircolors

6) To have the color to have effect in user account, copy to home directory

cp /etc/DIR_COLORS /home/.dircolors

7) Exit from your shell window, login again.  Type ls to see the effect, Volla!

Besides directory, you can change other color settings in the same file.

1) more = to view a text file one page at a time, press spacebar to go to the next page

more filename : show the document one page at a time

more -num filename : show the document page few lines as specified bu (-num)

example : more -10 filename will show 10 lines for every page


2) less = is much the same as more command except:

a) You can navigate the page up/down using the less command and not possible in more command.

b) You can search a string in less command. (use /keywordto search)

c) “more” was fairly limited, and additional development on “more” had stopped

d) it uses same functions as vi editor

the usage : less filename


3) head = displays the first ten lines of a file, unless otherwise stated.


head myfile.txt – Would display the first ten lines of myfile.txt.

head -15 myfile.txt – Would display the first fifteen lines of myfile.txt.


4) tail = display the last part of the file

usage : tail filename

tail -n filename : display the last n lines of the file


5) cat = can be used to join multiple files together and print the result on screen (it will not show page by page)


cat 01.txt
to displat the contents of file 01.txt

cat 01.txt 02.txt
to display the contents of both files

cat file1.txt file2.txt > file3.txt – Reads file1.txt and file2.txt and  combines those files to make

cat note5 >> notes – attach note5 to notes

cat >> file1 – add additional data in file1

1) man = manual provides in depth information about the requested command

man mkdir – gives the details how to use mkdir command together with the syntax

man -k reboot – quickly search for manuals containing reboot within them

man -h keyword – Print a one-line help message and exit.


2) apropos = Its useful if you  know only a part of the name or description of a command. Say for example, you want to add a user, but you do not know the specific command, you can try apropos user. It will list out the database of commands that related to user.


3) info = readable online documentation.

for example, info useradd will give a detail explanation of this syntax


4) whatis = it search the database for the keyword, and print it in a single line. it is the same as apropos except you must type the correct keyword else it will not show any result

Example: whatis finger


5) help = display a brief help on a command (it doesnt contain all commands)

usage = keyword –help

Ecample: reboot –help

Many of the syntax are not available for example useradd –help will not give any result


6) file = determine file type 


file * : will list all files in the directory with the file type information

file report2007.txt :  report2007.txt: ASCII text

1) mv = renames a file or moves it from one directory to another directory


mv [-f] [-i] oldname newname  (to rename)

mv [-f] [-i] filename newdirectory

-f mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.
-i Prompts before overwriting another file.
oldname The oldname of the file renaming.
newname The newname of the file renaming.
filename The name of the file you want to move directory – The directory of were you want the file to go.


mv myfile.txt newdirectory/ – moves the file myfile.txt to the directory newdirectory.

mv myfile.txt ../ – moves the file myfile.txt back one directory (if available).


2) cp = copies files from one location to another


cp file1.txt newdir

Copies the file1.txt in the current directory to the newdir directory.

cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak

Copies the mylog.txt file in the public_html directory into the public_html/backup directory as mylog.bak. The files are identical however have different names.

cp *.txt newdir

Copy all files ending in .txt into the newdir directory.

cp -r /home/hope/files/* /home/hope/backup

Copies all the files, directories, and subdirectories in the files directory into the backup directory.


3) rm : deletes a file without confirmation (by default).

rm myfile.txt

Remove the file myfile.txt without prompting the user.

rm -r directory

Remove a directory, even if files existed in that directory. It will prompt for every single file

rm -rf directory

Remove a directory, even if files existed in that directory.It will not ask for confirmation for each file.

To remove a file whose name starts with a `-‘, for example `-foo’, use one of these commands:

rm -foo
rm ./-foo


4) mkdir = to create a new directory

mkdir filename


5) rmdir = deletes a directory

rmdir mydir – removes the directory mydir (it wont work if files existed in the directory)

rm -r directory – would remove a directory, even if files existed in that directory.

there is no -r option for rmdir, therefore to remove a directory with files inside can use rm -r or rm-rf

rmdir -p dir3/dir4/dir5 - remove dir5, dir4 and dir3 if dir5 were empty, dir4 only contained dir5 and dir3 only contained dir4 (which, in turn, contained dir5):