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

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,           change your output  directory ..like i change it to the documents by browsing the folder. after that check the box for encrypt files .. after that it will ask for the password.. input your password for the sec

KALI LINUX -SECURITY ,CONFIGURATIO AND UPDATES

      Configuring network services and  secure  communications The first step in being able to use Kali is to ensure that it has connectivity to either a wired or wireless network to support updates and customization. You may need to obtain an IP address by DHCP (Dynamic Host Configuration Protocol), or assign one statically. First, confirm your IP address using the  command  ifconfig command from a terminal window, as shown in the following screenshot: IP address is 192.168.1.11.... If an IP address was not obtained, an address can be assigned by DHCP using the command dhclient eth0 (or other available interfaces, which will depend on the  specific configuration of the system being used). If a static IP address is used, additional information may be required. For example, you can assign a static IP of 192.168.1.11as follows:                     inet addr:192.168.1.11            Bcast:192.168.1.255            Mask:255.255.255.0        Securing com

EVERY LINUX_ADMIN-COMMANDS TO BE KNOW

Hello Friends,             in todays article i am gonna cover the most used 16 linux commands,every linux admin should know it.in the whole article i just show the uses of all the commands and their additional attributes too.