Exercise 2 Os
Exercise 2 Os
Ex.No:2.a
GENERAL PURPOSE
COMMANDS
AIM:
To study of Basic UNIX Commands and various UNIX editors such as vi, ed, exand EMACS.
a) date
–used to check the date and time
Syn:$date
Format Purpose Example Result
+%m To display only month $date+%m 06
+%h To display month name $date+%h June
+%d To display day of month $date+%d O1
+%y To display last two digits of years $date+%y 09
+%H To display hours $date+%H 10
+%M To display minutes $date+%M 45
+%S To display seconds $date+%S 55
b) cal
–used to display the calendar
Syn:$cal 2 2009
c)echo
–used to print the message on the screen.
Syn:$echo “text”
d) ls
–used to list the files. Your files are kept in a directory.
Syn:$lsls–s
All files (include files with prefix)
ls–l Lodetai (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)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>my list Output of „ls‟ command is stored to disk file named „my list‟
e)lp
–used to take printouts
Syn:$lp filename
f)man
–used to provide manual help on every UNIX commands.
Syn:$man unix command
$man cat
h) uptime
–tells you how long the computer has been running since its last reboot or power-off.
Syn:$uptime
i)uname
–it displays the system information such as hardware platform, system name and processor, OS type.
Syn:$uname–a
j) hostname
–displays and set system host name
Syn:$ hostname
k) bc
–stands for „best calculator‟
$bc $ bc $ bc $ bc
10/2*3 scale =1 ibase=2 sqrt(196)
15 2.25+1 obase=16 14 quit
3.35 11010011
quit 89275
1010
Ā
Quit
$bc $ bc-l
for(i=1;i<3;i=i+1)I scale=2
1 s(3.14)
2 0
3 quit
Ex.N0.2.B FILE MANIPULATION COMMANDS
a) cat–this create, view and concatenate files.
Creation:
Syn:$cat>filename
Viewing:
Syn:$cat filename
Add text to an existing file:
Syn:$cat>>filename
Concatenate:
Syn:$catfile1file2>file3
$catfile1file2>>file3 (no over writing of file3)
b) grep–used to search a particular word or pattern related to that word from the file.
Syn:$grep search word filename
Eg:$grep anu student
a) cd- The cd command stands for (change directory). It is used to change to the directory you want
to work from the present directory.
Syn:cd dirname
Eg:$cd 251062
b) mkdir- With mkdir command you can create your own directory
Syn:mkdir dirname
Eg:$mkdir os_programs
c) rmdir- The rmdir command is used to remove a directory from your system
Syn:rmdir dirname
Eg:$rmdir 251062
d) ls- The ls command is used to show the list of a folder. It will list out all the files in the
directed folder.
Syn:ls dirname
Eg:$ls os_programs
e) pwd – The pwd command stands for (print working directory). It displays the current working
location or directory of the user. It displays the whole working path starting with /. It is a
a built-in command.
Syn:pwd dirname
Eg:$pwd os_programs