Monday 22 August 2011

Creating Directories & Directory Navigation

Syntax :-

[root@localhost~]# mkdir <option> <directory name>

Example :- Creating a single directory

[root@localhost~]# mkdir directory1

Example :- Creating multiple directories

[root@localhost~]# mkdir direcoty2 directory3 directory4

To check if the directories have been created

[root@localhost~]# ls -d directory*

directory1  directory2  directory3  directory4

Example :- To create nested directories (Sub directories inside directories)

[root@localhost~]# mkdir -p d1/d2/d3/d4

To check if the nested directories have been created

[root@localhost~]# ls -R d1

/d1:
d2

/d1/d2:
d3

/d1/d2/d3:
d4

/d1/d2/d3/d4:

Note :- To list the contents and create a file or directory in a location different from the present working directory, Specify the complete path (example /var/directory1)

Directory Navigation

Syntax :-

[root@localhost~]# cd <argument>

Example :- To go into a directory

[root@localhost~]# cd d1

[root@localhost d1]# cd d2

 [root@localhost d2]#

Example :- To back one level, type cd press spacebar then dot dot

[root@localhost d2]# cd ..

[root@localhost d1]#

Example :- To go back two levels

[root@localhost d1]# cd ../..

[root@localhost /]#

Example :- To go to the Previous working directory 

[root@localhost /]# cd -

/root/d1

Example :- To go to current logged in user's home directory

[root@localhost d1]#cd

[root@localhost ~]# pwd

/root

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews