Unix Tutorial 2 : Basic Unix Commands

#1) cal: Displays the calendar.
  • Syntax: cal [[month] year]
  • Example: display the calendar for April 2018
    • $ cal 4 2018
#2) date: Displays the system date and time.
  • Syntax: date [+format]
  • Example: Display the date in dd/mm/yy format
    • $ date +%d/%m/%y
#3) banner: Prints a large banner on the standard output.
  • Syntax: banner message
  • Example: Print “Unix” as the banner
    • $ banner Unix
#4) who: Displays the list of users currently logged in
  • Syntax: who [option] … [file][arg1]
  • Example: List all currently logged in users
    • $ who
#5) whoami: Displays the user id of the currently logged in user.
  • Syntax: whoami [option]
  • Example: List currently logged in user
    • $ whoami
#6) touchCreate a new file or update its timestamp.
  • Syntax: touch [OPTION]…[FILE]
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ touch file1 file2
#7) cat: Concatenate files and print to stdout.
  • Syntax: cat [OPTION]…[FILE]
  • Example: Create file1 with entered cotent
    • $ cat > file1
    • Hello
    • ^D
#8) cp: Copy files
  • Syntax: cp [OPTION]source destination
  • Example: Copies the contents from file1 to file2 and contents of file1 is retained
    • $ cp file1 file2
#9) mv: Move files or rename files
  • Syntax: mv [OPTION]source destination
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ mv file1 file2
#10) rm: Remove files and directories
  • Syntax: rm [OPTION]…[FILE]
  • Example: Delete file1
    • $ rm file1
#11) mkdir: Make directory
  • Syntax: mkdir [OPTION] directory
  • Example: Create directory called dir1
    • $ mkdir dir1
#12) rmdir: Remove a directory
  • Syntax: rmdir [OPTION] directory
  • Example: Create empty files called ‘file1’ and ‘file2’
    • $ rmdir dir1
#13) cd: Change directory
  • Syntax: cd [OPTION] directory
  • Example: Change working directory to dir1
    • $ cd dir1
#14) pwd: Print the present working directory
  • Syntax: pwd [OPTION]
  • Example: Print ‘dir1’ if a current working directory is dir1
    • $ pwd
#15) ls: List directory contents
  • Syntax: ls [OPTION] [FILE]
  • Example: list all (including hidden files) directory contents, in long format, sorted by time,
    • $ ls -alt
#16) which: Locate a command
  • Syntax: which [-a] filename
  • Example: List all paths from where ‘cat’ can run
    • $ which -a cat
#17) man: Interface for working with the online reference manuals.
  • Syntax: man [-s section] item
  • Example: Show manual page for the ‘cat’ command
    • $ man cat
#18) su: Change user-id or become super-user.
  • Syntax: su [options] [username]
  • Example: Change user-id to ‘user1’ (if it exists)
    • $ su user1
#19) sudo: Execute a command as some other user or super-user
#20) find: Used to search for files and directories as mentioned in the ‘expression’
  • Syntax: find [starting-point] [expression]
  • Example: In ‘/usr’ folder, find character device files, of name ‘backup’
    • $ find /usr -type c -name backup
#21) du: Estimate disk usage is blocks
  • Syntax: du [options] [file]
  • Example: Show number of blocks occupied by files in the current directory
    • $ du
#22) df: Show number of free blocks for mounted file system
  • Syntax: df [options] [file]
  • Example: Show number of free blocks in local file systems
    • $ df -l
    • $ df -h

Comments

Popular posts from this blog

Hive Tutorial 31 : Analytic Functions

Hive Tutorial 37 : Performance Tuning