Professional Documents
Culture Documents
Os Record Exp1 Mythra
Os Record Exp1 Mythra
Ex no: 1
BASIC UNIX COMMANDS
Date:
AIM:
To study and implement the basic UNIX commands.
1.DISPLAY COMMANDS
a)date – used to check the date and time Syntax: $ date
Format Purpose Example Result
+ % m To display only month $ date + % m
+ % h To display month name $ date + % h
+ % d To display day of month $ date + % d
+ % y To display last two digits of the year $ date + % y
+ % H To display hours $ date + % H
+ % M To display minutes $ date + % M
+ % S To display seconds $ date + % S
OUTPUT:
1 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
d)ls – used to list the files. Your files are kept in a directory.
Syntax: $ ls
ls – s All files (include files with . prefix) ls – l Long detail (provide file statistics) ls – t Order
by creation time
ls – u Sort by access time (or show when last accessed together with –l) ls – s Order by size
ls – r Reverse order
ls – f Mark directories with / ,executable with * , symbolic links with @ , local sockets with =
, named pipes (FIFOs) with |
ls – s Show file size
ls – h “Human Readable”, show file size in Kilo Bytes & Mega Bytes (h can be used together
with –l or-s)
ls [a-m]* List all the files whose name begin with alphabets From “a” to “m” ls [a]*
List all the files whose name begins with “a” or “A”.
Eg: $ ls > mylist
Output of “ls” command is stored to disk file named “my list”.
OUTPUT:
2 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
g)who & who am i – it displays data about all users who have logged in to the system
currently. The next command displays about current user only.
Syntax: $ who
Syntax :$ who am i
OUTPUT:
h)uptime – tells you how long the computer has been running since its last re boot or power-
off.
Syntax: $ uptime
OUTPUT:
i)uname – it displays the system information such as hardware platform, system name and
processor,OS type.
3 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
Syntax: $ uname –a
OUTPUT:
4 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
b)grep – used to search a particular word or pattern related to that word from the file. Syntax:
$ grep searchword filename
Eg: $ grep anu student
OUTPUT:
5 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
6 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
k)wc – it counts the number of lines, words, character in a specified file(s) with the
options as – l, -w, -c
Syntax: $wc –l filename
$wc –w filename
$wc –c filename
7 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
3.DIRECTORY COMMANDS
a)mkdir – used for creating a directory.
Syntax: $ mkdir <directory name>
OUTPUT:
4.PROCESS COMMANDS
a)exit – terminates a process
Syntax: $ exit
b)kill – terminates or send a signal to process
Syntax: $ kill
8 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
OUTPUT:
a)The semicolon (;) - used ot execute more than one command at a time
eg: $ who ; date ; ls
OUTPUT:
b)The && operator – signifies the logical AND operation. It means that only if first command
is successfully executed, then the nest command will be executed.
OUTPUT:
c)The || operator – signifies the logical OR operation. It means the first command will
happen to be unsuccessful, it will continue to execute next command.
Eg: $ ls marks || date
OUTPUT:
9 717822Y135-MYTHRA E
DEPARTMENT OF CYBER SECURITY 21YD03-OPERATING SYSTEMS
RESULT:
Thus the program was executed successfully.
10 717822Y135-MYTHRA E