Skip to main content

LINUX TERMINAL COMMAND -2-NAVIGATION

                     





IN PREVIOUS ARTICLE LINUX TERMINAL-COMMAND-I-INTRODUCTION WE ONLY DISCUSS THE BASIC COMMANDS.
so, today we are going to discuss about the navigation of the file directory in the linux distribution system..basically today we learn mostly three things..

pwd : current working directory

ls : content in the directory

cd : changing the directory

but before starting it must to be understand how the file system orgnized in the linux..so let's start ...

but before if you don't read my previous article in linux commanding please read it first..

                             
                                           LINUX TERMINAL-COMMAND-I-INTRODUCTION 

Understanding The File System Tree

Like Windows, a Unix-like operating system such as Linux organizes its files in what is called a hierarchical directory structure.
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.

The Current Working Directory

When we first log in to our system or start a terminal emulator session our current working directory is set to our home directory.

At any given time, we are inside a single directory and we can
see the files contained in the directory and the pathway to the directory above us called the parent directory and any subdirectories below us. 

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.

command :pwd



Listing The Contents Of A Directory


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

command : ls




Changing The Current Working Directory

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.


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.

like here if you want to navigate to the directory..'bin' ,which is subdirectory of 'usr' directory...

then you have to pass through 'usr' directory.

command : cd /usr/bin  




..actually '/'(forward slash) use for the navigation from directory to subdirectory.

so , cd /usr/bin ..is an relative pathname start from the root directory to the destination.

Relative pathname..

it start from the working directory.
lets understand what it's mean..

like by command : cd /usr/bin...

command :pwd...this will give you the current directory name..which is 'bin'..

so if you want to navigate to another directory like to '/usr'..from the current working directory ..'bin'..then you have to go with relative pathname.

for this their is two command ...
1.  '.'(dot) command :actually this is use for current working directory.if you don't get the point we will discuss it through practicle..wait..||

2. '..'(double dot): through this it will navigate to parent directory of the current working directory..
means if you are in 'bin' directory currently..then

command : cd ..


this will take you to the parent directory of the 'bin' directory, which is 'usr'.

ok ,that's it for theory now start the practicle game...
but before this just someup basic things...

pwd : use to display current working directory pathname.

ls : listing the content of the directory

cd : used to change the directory

pathname:-

absolute pathname : start from the root to destination directory.

relative pathname :- start from the current working directory.

The "." symbol refers to the working directory and the ".." symbol refers to the working
directory's parent directory. 


Here is how it works. Let's change the working directory to

/usr/bin..

commands :

ubuntu@ubuntu:~$ cd /usr/bin
ubuntu@ubuntu:/usr/bin$ pwd
/usr/bin
ubuntu@ubuntu:/usr/bin$



so by 'cd' command we change directory to '/usr/bin' and by 'pwd' command we
get the current working directory '/usr/bin'.

Okay, now let's say that we wanted to change the working directory to the parent of
/usr/bin which is /usr.

for this their is two way to doing this.

1. by absolute pathname..

commands :

ubuntu@ubuntu:/usr/bin$ cd /usr
ubuntu@ubuntu:/usr$ pwd
/usr
ubuntu@ubuntu:/usr$ 




2. or by the relative pathname..

commands :

ubuntu@ubuntu:/usr/bin$ cd ..
ubuntu@ubuntu:/usr$ pwd
/usr
ubuntu@ubuntu:/usr$ 




here what we learn above used here that..
by using '..' it will navigate to parent directory of the current working directory.

Two different methods with identical results. Which one should we use? The one that
requires the least typing!

Likewise, we can change the working directory from /usr to /usr/bin in two
different ways. Either using an absolute pathname:

commands :

ubuntu@ubuntu:/usr$ cd /usr/bin
ubuntu@ubuntu:/usr/bin$ pwd
/usr/bin
ubuntu@ubuntu:/usr/bin$ 



or by the relative pathname :

commands:

ubuntu@ubuntu:/usr$ cd ./bin
ubuntu@ubuntu:/usr/bin$ pwd
/usr/bin
ubuntu@ubuntu:/usr/bin$ 




like what we learn that command '.' will represent the current working directry which is now 'usr'..so

commnad :   "cd /usr/bin"  or "cd ./bin" both are equivalent.


an important thing here :
"if you do not specify a pathname to something, the working directory will be assumed"

it's mean that in 'usr ' directory their is many directory . so if you ommitted './' from command it will assume that you are working in the current directory.
if you don't get this see here..

commands :

ubuntu@ubuntu:/usr$ ls
bin  games  include  lib  local  sbin  share  src
ubuntu@ubuntu:/usr$ cd bin
ubuntu@ubuntu:/usr/bin$ pwd
/usr/bin
ubuntu@ubuntu:/usr/bin$ 




some useful ..'cd shortcuts'..

1. cd       Changes the working directory to your home directory.

2. cd -     Changes the working directory to the previous working directory.

commands :

ubuntu@ubuntu:~$ cd /usr/bin
ubuntu@ubuntu:/usr/bin$ pwd
/usr/bin
ubuntu@ubuntu:/usr/bin$ cd ..
ubuntu@ubuntu:/usr$ cd -
/usr/bin
ubuntu@ubuntu:/usr/bin$ cd -
/usr
ubuntu@ubuntu:/usr$ 




that's it for today..

read my next article based on commanding..
                                         
                     LINUX TERMINAL COMMAND – EXPLORE THE SYSTEM

until next article  this is..
                        
                        ZEROCOOL
                        SIGN OUT


Popular posts from this blog

MALTEGO-INFORMATION GATHERING GRAPH

Hello Friend,                 Welcome back to Hacker_heaven .in this article i am gonna show you how to gather deep information about any specific website.so just stick with me...

DEEP SOUND -STEGNOGRAPHY

In the series of the steganography ..today we are going to discuss the hiding of data in the music file through the help of the window based tool name       "DEEP SOUND" ..now a days very famous TV series name             Mr. Robot . . off course i am  fan of this show..where elliot use this tool for hiding his secret data.. read previous article on steganography                                                         so without wasting much time lets start .. 1.install the DEEP SOUND go to the official website of the deep sound and download it to your machine.  and open up the interface of the deep sound. 2. setting click on the setting gear icon, an pop-up window show up...where languge remain same as english,           ch...

MANIPULATING THE FILE AND DIRECTORIES

HELLO GUYS WELCOME BACK TO HACKER HEAVEN..I HOPE YOU ENJOYED MY PREVIOUS ARTICLE ... i hope at this point, we are ready for some real work! This article will introduce the following commands:       ● cp – Copy files and directories       ● mv – Move/rename files and directories       ● mkdir – Create directories       ● rm – Remove files and directories       ● ln – Create hard and symbolic links These five commands are among the most frequently used Linux commands. They are  used for manipulating both files and directories. Now, to be frank, some of the tasks performed by these commands are more easily done with a graphical file manager. With a file manager, we can drag and drop a file from one directory to another, cut and paste files, delete files, etc. So why use these old command line programs ? The answer is power and flexibility . While it is easy to perform simple file manipulati...