BASIC COMMANDS IN UNIX


COMMANDS: 

1. TASK                  : To display the system date and time.
    COMMAND       :  date.
    SYNTAX             : date.
    EXPLANATION: This command displays the current system date and time on the       
                                   screen.
 OUTPUT             : Tue Jun 19   11:37:17 GMT 2007.


 2. TASK                   : To display the current month.
     COMMAND       : date.
     SYNTAX             : date +%m.
     EXPLANATION:  This command displays the current month on the screen.
     OUTPUT             : 06.


 3. TASK                   : To display the name of the current month.
     COMMAND       : date.
     SYNTAX             : date +%h.
     EXPLANATION: This command displays the name of the current month on the 
                                      screen.
     OUTPUT             :  Jun.


4. TASK                   : To display the current system date.
    COMMAND       : date.
    SYNTAX             : date +%d.
    EXPLANATION: This command displays the current system date on the screen.
    OUTPUT             : 19.


5. TASK                   : To display the current system date (year).
    COMMAND       : date.
    SYNTAX             : date +%y.
    EXPLANATION: This command displays the current year on the screen.
    OUTPUT             : 07.


6. TASK                   : To display the current system time.
    COMMAND       : date.
    SYNTAX             : date +%H.
    EXPLANATION: This command displays the current system time (in hours) on the
                                     screen.
    OUTPUT             : 11.


7. TASK                   : To display the current system time.
    COMMAND       : date.
    SYNTAX             : date +%M.
    EXPLANATION: This command displays the current system time (in minutes) on the
                                    screen.
    OUTPUT             : 43.


8. TASK                   : To display the current system time.
    COMMAND       : date.
    SYNTAX             : date +%S.
    EXPLANATION: This command displays the current system time (in seconds) on the
                                     screen.
    OUTPUT             : 15.


9. TASK                   :  To display the calendar of the current month.
    COMMAND       : calendar.
    SYNTAX             : cal.
    EXPLANATION: This command displays the calendar of the current month on the
                                    screen.
    OUTPUT             :                Jun 07
                           S          M         T          W        T          F          S
                                                                                    1          2
                        3          4          5          6          7          8          9
                        10        11        12        13        14        15        16
                        17        18        19        20        21        22        23
                        24        25        26        27        28        29        30


10. TASK                   : To display user-defined message.
      COMMAND       : echo.
      SYNTAX             : echo “message”.
      EXPLANATION: This command displays on the screen the argument of the echo
                                       command.
      OUTPUT             : echo “OS”.
                                  è OS

11. TASK                    : To display the details of all users.
      COMMAND        : who.
      SYNTAX              : who.
      EXPLANATION : This command lists the information about all the users who have
                                      logged on to that system.
      OUTPUT              :


12. TASK                    : To display the user detail.
      COMMAND        : who.
      SYNTAX              : whoami.
      EXPLANATION : This command displays information about the current user of the
                                      system on the screen.
      OUTPUT              : root.


13. TASK                    : To create a directory.
      COMMAND        : make directory.
      SYNTAX              : mkdir.
      EXPLANATION : This command is used to create a new directory with the specified
                                      name.
      EXAMPLE           : mkdir student.
      OUTPUT               : The directory “student” is created.


14. TASK                    : To change directory.
      COMMAND        : change directory.
      SYNTAX              : cd directory name.
      EXPLANATION : This command is used to switch from one directory to another.
      EXAMPLE           : cd staff.
      OUTPUT              : The directory “staff” is switched onto.


15. TASK                    : To delete a directory.
      COMMAND         : remove directory.
      SYNTAX               : rmdir directory name
      EXPLANATION  : This command is used to delete the specified directory.
      EXAMPLE            : rmdir student.
      OUTPUT               : The “student” directory is deleted.


16. TASK                    : To come out of a sub-directory.
      COMMAND        : change directory.
      SYNTAX              : cd ..
      EXPLANATION : This command helps in switching to the main directory.
      OUTPUT              :

17. TASK                    : To list all the files and directories.
      COMMAND        : list.
      SYNTAX              : ls.
      EXPLANATION : This command displays all the files and directories of the system.
      OUTPUT              :


18. TASK                    :  To create a file.
      COMMAND        : cat.
      SYNTAX              : cat> file name.
      EXPLANATION : This command leads to the creation of a new file with the specified
                                      file name and contents.
      EXAMPLE           : cat> wind.
      OUTPUT               : A null file called “wind is created.


19. TASK                     : To view a file.
      COMMAND         : cat.
      SYNTAX               : cat file name.
      EXPLANATION  : This command displays the contents of the specified file.
      EXAMPLE            : cat wind.
      OUTPUT                : Contents of the file called “wind” will be displayed on the screen.


20. TASK                     : To copy a file.
      COMMAND         : copy.
      SYNTAX               : cp sourcefile destinationfile.
      EXPLANATION  : This command produces a copy of the source file and is stored in
                                       the specified destination file by overwriting its previous
                                       contents.
      EXAMPLE            : cp sun moon.
      OUTPUT               : The contents of “sun” file will be copied to the “moon” file.


21. TASK                     : To move a file.
      COMMAND         : move.
      SYNTAX               : mv sourcefile destinationfile.
      EXPLANATION  : After moving the contents of the source file into destination file,
                                       the source file is deleted.
      EXAMPLE            : mv sun moon.
      OUTPUT               : After copying contents from the “sun” file to “moon” file, the                    
                                            sun” file is deleted.                                
                        
22. TASK                    : To display / cut a column from a file.
      COMMAND        : cut.
      SYNTAX              : cut –c no.  file name.
      EXPLANATION : This command displays the characters of a particular column in the
                                      specified file.
      EXAMPLE           : cut –c3 moon.
      OUTPUT              : Those characters occurring in the 3rd column of the file called
                                           moon” are displayed.


23. TASK                     : To delete a file.
      COMMAND         : remove.
      SYNTAX               : rm file name.
      EXPLANATION  : This command deletes the specified file from the directory.
      EXAMPLE            : rm sun.
      OUTPUT                : The file called “sun” will be deleted.


24. TASK                     : To retrieve a part of a file.
      COMMAND         : head.
      SYNTAX               : head   -no. of rows   file name.
      EXPLANATION  : This command displays the specified no. of rows form the top
                                        of the specified file.
      EXAMPLE            : head -1 sun.
      OUTPUT                : The first row of the file called “sun” is displayed.


25. TASK                      : To retrieve a file.
      COMMAND          : tail.
      SYNTAX                : tail -no. of rows   file name.
      EXPLANATION   : This command displays the specified no. of rows form the bottom
                                          of the specified file.
      EXAMPLE             : tail -1 moon.
      OUTPUT                : The last row of the file called “moon” is displayed.


26. TASK                     : To sort the contents of a file.
      COMMAND         : sort.
      SYNTAX               :  sort   file name.
      EXPLANATION  : This command helps in sorting the contents of a file in ascending
                                        order.
      EXAMPLE            : sort win.
      OUTPUT               : The contents of the file “win” are displayed on the screen in a
                                         sorted order.
27. TASK                     : To display the no. of characters in a file.
      COMMAND         : word count.
      SYNTAX               : wc   file name.
      EXPLANATION  : This command displays on the screen the no. of rows, words, and
                                        the sum of no. of characters and words.
      EXAMPLE            : wc ball.
      OUTPUT                : The no. of rows, words, and no. of characters present in the file
                                           ball” are displayed.


28. TASK                     : To display the calendar of a year.
      COMMAND         : cal.
      SYNTAX               : cal year.
      EXPLANATION  : This command displays on the screen the calendar of the specified                                                          year.
      EXAMPLE            :  cal 2007.
      OUTPUT                : The calendar of the year 2007 will be displayed.

0 comments:

Post a Comment