
1> date - It displays system date and time
$date [option] [+Format]
FORMAT controls the output.
•$date –R Output date and time in RFC 2822 format
•$date –d Display time described by STRING
•$date –s Set time described by STRING
•$date –u Print or set Coordinated Universal Time
Sr. No. Format name Description
1 %a abbreviated weekday name (e.g., Sun)
2 %A full weekday name (e.g., Sunday)
3 %b abbreviated month name (e.g., Jan)
4 %B full month name (e.g., January)
5 %d day of month (e.g, 01)
6 %H hour (00..23)
7 %j day of year (001..366)
8 %m month (01..12)
9 %M minute (00..59)
10 %u day of week (1..7); 1 is Monday
11 %w day of week (0..6); 0 is Sunday
12 %y last two digits of year (00..99)
13 %Y Year
2> cal - Displays calendar for current month.
•$cal -1 Display single month output.
•$cal -3 Display prev / current / next month output.
•$cal –s Display Sunday as the first day of the week. (This is the default.)
•$cal –m Display Monday as the first day of the week.
•$cal –j Display Julian dates (days one- based, numbered from January 1).
•$cal –y Display a calendar for the current year.
3> clear - Clear the terminal screen
4> tty - Print the file name of the terminal connected to standard input.
5> script - Make typescript of terminal session
•If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.
•$script file1 file1 is created
6> man - It gives manual help for any command.
1> who - This command is used to display who are the users connected to our computer currently.
•Syntax: $who [option]
•-a – display all the users who have been login
•-b – display time of last system boot
•-d – print dead processes
•-H – print line of column heading
•-l – print system login processes
2> who am i -It will display details of the currently working user.
•Syntax: $who am i
3> login - This command is used to switch from one user to another user at any time
•Syntax : $login
4> passwd - Set password of current user. It ask for entering new password and then confirm password.
•Syntax: $passwd
5> su - This command provides super user privileges. It will ask for super user password
•Syntax : $su
6> pwd - It displays present working directory
•Syntax : $pwd
1> ps (process status) - Display the characteristics of a process (i.e. terminal number, time required, PID no and command name)
•$ps –f Full listing showing PPID of each process
•$ps –u username Displays processes of user ‘username’
•$ps –a Processes of all users
•$ps –e processes including user and system processes
2> wait - Waits until all background processes are completed and then exits.
•$wait
3> sleep - Used to execute commands after certain amount of time by sleeping for given seconds.
•$sleep 10 ; ps
•ps command will be executed after 10 seconds
4> exit - Used to quit the shell.
•$exit
1> ls - It is used to lists files in the current working directory
•Syntax :- $ls [option]
Option Meaning
-a List all files including hidden file starting with ‘.’
-d List directories - with ‘*’
-i List file’s inode index number
-l List with long format showing all user permissions
2> rm - It is used to remove the file.
•Syntax :- $rm filename
•$rm –i file1
•-i will ask to remove file
3> mv - It is used to move a file from one location to another. (Rename the file)
•Syntax :- $mv [option] source destination
•Example :- $mv abc.txt aaa.txt
To rename the file abc.txt to aaa.txt
•-i (interactive) : the mv command with –i option ask for confirmation
•Example :- $mv –i abc.txt aab.txt
4> cp - It is used to copies a file to destination file. •If second file doesn’t exist, then first it creates one and content is copied to it. But if it exists then it is simply overwritten without any warning.
•Syntax - $cp sourcefile destinationfile
•Example :- $cp xyz.txt zzz.txt
join - It is used for joining lines of two files on the basis of common field in each file called as a key.
•Syntax:- join [option] file1 file2
•Example:- join student1 student2
5> split - It is used to split the large file into smaller files. Default size is 1000 lines per file.
•Syntax :- split –n filename tagname
-n number of lines in each smaller file
-tag name by default the split builds the output files named xaa, xab, xac ….. If tag name specified, it replaces the x with that tag name.
•Example:- split -10 student
6> head - It is used to read the first ten lines of file. (10 lines by default). The number of lines to be displayed may be specified in the head command.
•Syntax :- $head –n filename
-n means how many lines to be displayed
7> tail - It is used to print last few number of lines of a file (10 lines by default).
•Syntax:- tail {[+/-] n [lbc]} filename
+n Displays all lines starting from nth line
-n Displays n lines from end of the file
l Indicate lines
b Indicates blocks
c Indicates characters
8> touch - It is the easiest way to create new, empty files.
•Syntax:- $touch filename
1> mkdir command - It is used to create a new directory in a current directory
Syntax : $ mkdir <directory name>
2> cd command – It is used to change directory. We can use it to change to any directory by specifying a valid absolute or relative path.
Syntax : $cd <directory name>
3> diff - This command is used to show difference between two text files. It also tells which line in one has to be changed to make the two files identical.
Syntax : $diff filename1 filename2
a - Add text to file
c – Changes to be made in the file
d – Delete lines
< - Lines from the first file
> - Lines from the second file
4> comm - This command compares two sorted files.
•It compares each line of first file with its corresponding line in the second file and generates three column output.
•The first column lists the lines only in first file
•The second column lists the lines only in second file
•The third column list the lines in both files.
Syntax : $comm filename1 filename2
5> cmp - This command is used to compare files. It uses two filenames as an argument and display the difference on the terminals.
•$cmp filename1 filename2
6> pr - Convert text files for printing. The pr command does minor formatting of files on the terminal screen or for a printer. It does not modify the original file.
Syntax : $ pr filename
7> chmod - It is used to change or set three permissions (read, write and execute) for all the three categories of user.
•Types of users – user, group and other
•chmod can be operated in two ways –
–Symbolic or alphabetical notation
–Octal or absolute notation
A> Symbolic or alphabetical notation
Option Symbols Meaning
Category u Owner of the file and directory
g Members of the group belonging to the user
o All other system users
a All the users
Permission r To assign read permission to a file
w To assign write permission to a file
x To assign execute permission to a file
Operations + Assign permission
- Removes permission
= Assign absolute permission
Syntax : - $chmod <category> <operation><permission><filename>
Ex.- $chmod ugo+x abc
Assign the execute permission for user/owner, group and other
B>Octal or absolute notation
•This method uses a number to specify each set of permissions for the file.
•It assigns permissions in three digits.
•First digit for owner, second digit for group and third digit for other.
•Digit range is 0 to 7.
Number Assignment
0 No permission
1 Execute permission
2 Write permission
4 Read permission
5(4+1) Read & execute permission
6(4+2) Read & write permission
7(4+2+1) Read., write & execute permission
Syntax : - $chmod <Three Digit Octal Number> <filename>
Ex.- $chmod 750 abc
Assign all permissions for user, read & write for group and no permission for other
1> tr - It is the abbreviation of translate or transliterate, indicating its operation of replacing or removing specific characters in its input data set.
•Syntax: $tr [option] SET1 SET2
•-d - delete characters in SET1, do not translate
•-s - replace each input sequence of a repeated character that is listed in SET1 with a single occurrence of that character
2> cut - It is used to copy columns to the standard output file. It is used to cut portion of a file.
•Syntax : $cut [option] filename
•-f - print only these fields
•-c - select only these characters
3> paste - This command is used to join files horizontal by outputting lines consisting of lines from each file specified, separated by tab as delimiter.
•Syntax: $paste [option] [files]
4> spell - It is a spell-checking program which scans a text file for misspelled words and print each misspelled word on its own line.
•Syntax: $spell [option] filename
5> sort - This command is used to sort a file.
•Syntax: $sort [option] filename
•-o - write result to FILE
•-n – sort a file numerically
•-r sort in reverse order
6> grep - It is used to search a pattern/word inside files
•Syntax: $grep <option> <pattern> <filename>
•-c – display the count of the number of occurrences of the pattern
•-l – display the list of the filenames which contains a pattern
•-n – display line numbers along with the lines containing a pattern
7> more - If the file is too large for its contents to fit in one screen, it will scroll off your screen. Use more command to display file contents page wise.
•Syntax: $ more [option] filename
There are different types of Operating Systems. One of the most important Operating system is Linux Operating system. Most of the industries use Linux Operating System as it is multiuser, multithreaded Operating System. Linux has various flavors like Kali Linux, Ubuntu, etc. Linux works in two modes Graphics User Interface & Command Line Interface. Linux commands are needed many times in industry for various operations. There are thousands of commands in Linux. In this course I will cover frequently used commands. In first section I will tell you about General Purpose commands like date, time, cal, clear, tty, script, man commands. This section also cover basic commands like who, who am i, login, password, su and pwd commands. In second section I will tell you about various Process commands like ps, wait, sleep, exit. In third section I will teach you various file and directory manipulation commands. In first lecture I will cover ls, rm, mv, cp, join, split, cat, head, tail and touch commands. In second lecture I will teach diff, comm, pr, chmod, mkdir, rmdir, cd, pwd, dir and cmp commands. In fourth section I will cover various text processing commands like tr, wc, cut, paste, spell, sort, grep and more command.