Os 2
Os 2
Practical No. 2
Aim: Execute general purpose commands date & time, cal, clear, banner, tty,
script, man.
Theory:
Study the commands and execute the same for given commands.
Precaution: Follow the proper syntax of every command.
Theory:
Study the commands and execute the same for given commands.
Precaution: Follow the proper syntax of every command.
Examples:
1. clear
It clears the screen.
$ clear
Practical No. 2
FC5462 - Operating System
2. banner
This command displays its argument like poster, with maximum of 10
characters per line. Use quotes for your arguments to preserve formatting.
$ banner Hello
# # ##### # # #####
# # # # # # #
##### ### # # # #
# # # # # # #
# # ##### ##### ##### #####
The above output is just for a sample, the actual output may have more or
less Hash symbols.
3. date
Following command displays current date & time if no argument is
given.
$ date
Tue May 6 02:45:40 IST 2003
Formatted output for date command:
Field Descriptor Function
%a Abbreviated weekdays(SUN to SAT)
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Current date & time
%C Century (00 to 99)
%d Day of month 0 to 31
%D Day as MM/DD/YY
%e Day of month as decimal number
%h Abbreviated month
%H Hour 00 to 23
%I 01 to 12 (12 hour clock)
%j Day of the year 001 to 366
%m Month of the year 01 to 12
%M Minute 00 to 59
%n New time
%p AM/PM
%r Time in AM/PM notation
%T Time in hh:mm:ss (23 hrs clock)
Practical No. 2
FC5462 - Operating System
4. cal
It displays calendar of prev/current/next month if no argument is
specified.
Displays calendar of specific year if specified.
$ cal
Table 2.
Options Function
-1 Display single month output.
-3 Display prev/current/next month output.
-s Display Sunday as first day of week.
-m Display Monday as first day of week.
-j Display Julian dates.
-y Display a calendar for current year.
5. man
Specify the command name after man, it will display the man page of
that command.
$ man ls
Note: If output of a command is larger than one page, it can be redirected
to more or less command for slower display as shown below:
$ man ls | less
Practical No. 2
FC5462 - Operating System
6. script
# cat shell_record1
Script started on Fri 09 Jun 2020 06:23:41 PM UTC
[root@centos-01 ~]# date
Fri Jun 9 18:23:46 UTC 2020
[root@centos-01 ~]# uname -a
Linux centos-01 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24
UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@centos-01 ~]# whoami
root
[root@centos-01 ~]# pwd
/root
[root@centos-01 ~]# exit
exit
7. tty
The tty command of terminal basically prints the file name of the
terminal connected to standard input. tty is short of teletype, but
Practical No. 2
FC5462 - Operating System
/dev/pts/19
Note that the command produces a message like "not a tty" if it is not
running inside a terminal.
Practical No. 2
Exercise:
3. Display seconds, minutes & hours of the day by using date command.
6. Execute the command and write the output for cal 05 2020 command.
7. Execute the command & write the output for cal 02 command.
Conclusion: Thus, we successfully executed general purpose commands date & time, cal,
clear, banner, tty, script, man.