JAVA SCRIPT

RH033 2. BASIC COMMANDS IN LINUX:

->  To Set Date:  (Date command)


    date  =Shows current date and time
    date <mmddHHMMYYYY> =Set current date and time
    date +%a =Shows week
    date +b  =Shows month
    date +Z  =Shows timezone
    date +T  =Shows time only



->  To  check  Calender:   (cal command)

    cal         =Show current cal
    cal -3      =Show current next and previous cal
    cal <YYYY> =Show particular years calender



->  To create File:    (cat and touch command)

   CREATE FILE
   cat  >  <file>  =Create file    add contents, ctrl c save file
   cat  >> <file>  =Append exisiting file
   cat  -n <file>  =Number  file

   touch <file>                   =Creates empty file
   touch file file2 file3 file4   =Create 4 empty files



->  To remove file:    (rm command)

   rm    <file>    =Remove file by prompting
   rm -f <file>    =Remove file without prompt




->  To create directory:  (mkdir command)

   mkdir  <Dir>              =Create dir
   mkdir -p <Dir1/dir2/dir3> =Create parent dir




->  To remove directory:  (rm command)

   rmdir    <dir>            =remove empty dir
   rm    -rf <dir>           =remove dir which has contents




-> List contents of directory and  its options. 
(ls command)

   ls          =List contents of dir
   ls -l       =Long listing
   ls -a       =List hidden file
   ls -l <file>=Long list individual file
   ls -ld <dir>=Long list individual dir
   ls -i <file>=Shows inode num of file
   ls -h <file>=Shows human readable size of file



-> To change directory (cd command)

   cd  <dir>  =Change to specified dir
   cd         =Change to home dir
   cd ..      =Change to immediate parent dir



-> To copy  files  (cp command)

   cp   <file1> <file2>  =Copy file to file
   cp   <file1> <Dir>    =Copy file to dir
   cp -r <dir1> <Dir2>   =Copy dir1  to dir2



->  Move or Rename  file  (mv command)

   mv <file1> <file2>  
Move/rename file, once moved source file dont exist.

No comments:

Post a Comment