You are on page 1of 8

Basic Commands

Dr. Sarvesh Tanwar


• Cat
• Cd
• Ls
• Mkdir
• Rm--Removes (Deletes) filename
• Rmdir--Deletes an existing directory provided it is empty
• Man- man ls
• more

2
• Pwd
• Cal
• Cat
• Touch
• Cp

3
Date
Format options Purpose of Option Output

Displays Weekday name in short (like


date +%a Mon, Tue, Wed) Thu
Displays Weekday name in full short
date +%A (like Monday, Tuesday) Thursday
Displays Month name in short (like Jan,
date +%b Feb
Feb, Mar )
Displays Month name in full short (like
date +%B January, February) February
date +%d Displays Day of month (e.g., 01) 07
Displays Current Date; shown in
date +%D 02/07/13
MM/DD/YY
date +%F Displays Date; shown in YYYY-MM-DD 2013-02-07
date +%H Displays hour in (00..23) format 23
date +%I Displays hour (01..12) format 11
date +%j Displays day of year (001..366) 038

4
date +%m Displays month (01..12) 02
date +%M Displays minute (00..59) 44
date +%S Displays second (00..60) 17
Displays nanoseconds
date +%N 573587606
(000000000..999999999)
Displays time; shown as HH:MM:SS
date +%T 23:44:17
Note: Hours in 24 Format
Displays day of week (1..7); 1 is
date +%u 4
Monday
Displays week number of year, with
date +%U 05
Sunday as first day of week (00..53)
date +%Y Displays full year i.e. YYYY 2013
alphabetic time zone abbreviation
date +%Z IS
(e.g., EDT)

5
ls
ls –a
ls -s: print the allocated size of each file
Ls t*
Ls ?est
Ls /dir1/*t
Ls [aeiou]* [start with vowels]
Ls [!aeiou]* [not start with vowels]

6
• Ls [a-d][c-z][4-9]??

This will list all 5 character filenames in the current directory whose
first character is in the range a to d, the second character is in the range
c to z, the third character is in the range 4 to 9, whereas the fourth and
fifth are any valid characters.

• Ls –l
• The dot (.) is a mapping to itself and the dotdot (.) is a mapping to the
parent directory.
7
Command Explanation

ls <path name> By specifying the path after ls, the content in that path will be displayed

Using ‘l’ flag, lists all the contents along with its owner settings, permissions & time
ls –l
stamp (long format)

ls –a Using ‘a’ flag, lists all the hidden contents in the specified directory

Using ‘–author’ flag, lists the contents in the specified directory along with its
ls –author
owner

ls –S Using ‘a’ flag, sorts and lists all the contents in the specified directory by size

ls *.html Using ‘*’ flag, lists only the contents in the directory of a particular format

ls –lS > file.txt Using ‘>’ flag, copies the result of ls command into a text file

You might also like