Basic Commands
Basic Commands
2
• Pwd
• Cal
• Cat
• Touch
• Cp
3
Date
Format options Purpose of Option Output
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