Sunday, September 30, 2012

Creating and Deleting Directories

"mkdir"  command

          used to create directories. 
  
eg: creating a directory using mkdir

  $ mkdir mydir1
  $ ls
   exit.png  Library.sql  mydir1  out1-1.ogv 


     creating multiple directories using mkdir

$ mkdir mydir2 mydir3
$ ls
exit.png  Library.sql  mydir1  mydir2  mydir3  out1-1.ogv  


"rmdir" command 

      used to delete directories

  eg: deleting a single directory

       $rm mydir1
       $ls
       exit.png  Library.sql mydir2 mydir3 out1-1.ogv 

      deleting multiple directories

       $ rmdir mydir2 mydir3
       $ ls
       exit.png  Library.sql  mydir1  out1-1.ogv 



     but you will get an error saying  rmdir: failed to remove `directory name': Directory not empty if you try to delete a directory containing files.

To forcefully delete directories containing files we have to use "rm" command with command line argument -rf

 ex:
     $ rmdir -rf mydir1



Sunday, September 23, 2012

Basic Terminal Navigation Commands

"cd"  command 

             used to change the current directory
         
       cd directoryName   or  cd fullpath/directoryName

 ex:
   [ravindu@localhost ~]$ cd Desktop
   [ravindu@localhost Desktop]$

   [ravindu@localhost Desktop]$ cd /home/ravindu/Documents
   [ravindu@localhost Documents]$

   to go back to the previous directory use cd ..

  ex:
     [ravindu@localhost Documents]$ cd ..
     [ravindu@localhost ~]$

 

"ls" command

   used to list files and directories of the current directory
   ex:


ls -a
   displays all the files in the current directory including hidden files
   ex:



ls -l
   displays long list of files in the current directory with  details

   ex:



to view all other available command line arguments for ls command type
ls --help


"pwd" command
       prints the current directory

 ex:
     [ravindu@localhost Documents]$ pwd
     /home/ravindu/Documents