Sunday 23 February 2014

Navigation file system using terminal.

Like Windows, a Unix-like operating system such as Linux organizes its files in what is
called a hierarchical directory structure. This means that they are organized in a tree-like
pattern of directories (sometimes called folders in other systems), which may contain
files and other directories. The first directory in the file system is called the root
directory. The root directory contains files and subdirectories, which contain more files
and subdirectories and so on and so on.
Note that unlike Windows, which has a separate file system tree for each storage device,
Unix-like systems such as Linux always have a single file system tree, regardless of how
many drives or storage devices are attached to the computer. Storage devices are
attached (or more correctly, mounted) at various points on the tree according to the
whims of the system administrator, the person (or persons) responsible for the
maintenance of the system.
The directory we are standing in is
called the current working directory. To display the current working directory, we use the
pwd (print working directory) command.

[me@linuxbox ~]$ pwd
/home/me

To list the files and directories in the current working directory, we use the ls command.

[me@linuxbox ~]$ ls
Desktop Documents Music Pictures Public Templates Videos

To change your working directory (where we are standing in our tree-shaped maze) we
use the cd command. To do this, type cd followed by the pathname of the desired
working directory. A pathname is the route we take along the branches of the tree to get to
the directory we want. Pathnames can be specified in one of two different ways; as
absolute pathnames or as relative pathnames

Using absolute pathnames:
An absolute pathname begins with the root directory and follows the tree branch by
branch until the path to the desired directory or file is completed.

[me@linuxbox ~]$ cd /usr/bin
[me@linuxbox bin]$ pwd
/usr/bin

Using relative pathnames:
Where an absolute pathname starts from the root directory and leads to its destination, a
relative pathname starts from the working directory.

[me@linuxbox usr]$pwd 
/usr

Now we are already in /usr directory, to move to /usr/bin , we can either follow the above method using absolute pathname or use relative pathname as given below:

[me@linuxbox usr]$ cd /bin
[me@linuxbox bin]$pwd
/usr/bin


No comments:

Post a Comment