Monday, April 14, 2008

Linux Commands - Part 2

ls - This command is use to list files and folders.

   ls                       {list current directory}
   ls /media         {list /media files and folders in  directory media }
   ls -l                   {list permission}
   ls -a                  {list all, including hidden files, etc}

cp - This command is use to copy files and folders

   cp  test /home/melick { copy test file to /home/melick folder}
   cp  /root/s.txt  .        {copy s.txt to current directory (.)}
   cp -r /root  /home/melick      {copy entire root folder to melick}                 

mv - This is used t move and rename files and folders

  mv  test /home/melick       { move test file to /home/melick folder}
  mv  /root/s.txt  .   { move s.txt file in /root to current folder (.)}
  mv test1 test2         {rename test1 file to test2}          

rm - This is used t delete files and folders

  rm /home/Melick/test      {delete the test file}
  rm -r /home                        {delete the entire home folder}                
 rm -i /home    {ask confirmation to delete}    

mkdir - This is used to create folders.

  mkdir Melick            {create the Melick folder in current directory}
  mkdir /home/Sachika     {create Sachika folder in home directory} 

rmdir  - This is used to delete empty folders

  rmdir Melick            {delete the Melick folder in current directory}
  rmdir /home/Sachika    { delete Sachika folder in home directory}   

ln - This is used to create links (something like shortcuts) 

  ln -s test  shorttest             {create link 'shorttest' to file test }    
  ln -s /home/test  shorttest 
                         {create link 'shorttest' to file test ('home' folder)}
  ln test test2  
 {create hard link 'test2' to file test.create a nother copy of test}              

 Out put of above commands 

lrwxrwxrwx 1 melick melick    4 2008-12-30 00:21 shorttest -> test
  -rw-r--r-- 2 melick melick    0 2008-12-30 00:20 test
  -rw-r--r-- 2 melick melick    0 2008-12-30 00:20 test2

Post a Comment