LINUX BASICS 312001 Practical No 2 K Scheme Answer
![]() |
LINUX BASICS 312001 Practical No 2 K Scheme Answer |
Experiment No 02: Execute general-purpose Linux commands
Practical Significance
General purpose commands are programs built into a system that can be invoked in various manners. These commands function interactively through a terminal, which utilizes a shell program to provide a command line interface.
Program code
1. Write down different options of cal command. (Use $man cal)
Answer:
2. Write options of date command. (Use $man date)
Answer :
Result(s)
We successfully execute general-purpose Linux commands.
Practical related questions
1. How you record all the following activities performed by the user.
Answer:
2. Give a command to display calendar for month of February.
Answer:
3. Give single statement command to display the calendar of previous, current and
next month.
Answer:
cal -3
The -3 option with cal instructs it to display three months, starting from the current month. This will display the calendar for the previous month, the current month, and the next month in sequence.
Exercise:
1. What is output of following commands?
a. $cal 04 2023
Answer:
April 2023
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
b. $date “+Today's information: %D and %B”; cal
Answer:
Today's information: 2024-03-09 and March
Sat Sun Mon Tue Wed Thu Fri
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
c. .$date “+My clock is showing %H hours, %M minutes and %S seconds”
Answer :
My clock is showing 14 hours, 23 minutes and 42 seconds
d. $cal -3
Answer:
output
March 2024 April 2024 May 2024 Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 1 2 3 4 5 6 8 9 10 11 12 13 14 7 8 9 10 11 12 13 15 16 17 18 19 20 21 14 15 16 17 18 19 20 22 23 24 25 26 27 28 21 22 23 24 25 26 27 29 30 31 28 29 30 31 << March 2024 >> << April 2024 >> << May 2024 >>
e.$x=echo "var=500;var%=7;var" | bc
$ echo $x
Answer : 3
f. $ echo "var=10;var++" | bc
Answer: 10
g. printf "%f\n" "20.20"
Answer:
20.200000
2. Give the syntax of commands for displaying the output. (use date)
i. This is ............... Month of the year...........................(Abbreviation for month and
4-digit year)
ii. This is the .....................’th day of this year.
Answer:
date "+%b Year of the year...........................(%b. %Y)"