You are on page 1of 7

BAHRIA UNIVERSITY, ISLAMABAD

Department of Computer Science

Operating System
Lab Journal 3
Student Name: AMMARA BABAR
Enrolment No.: 01-23151-043

Title: General Purpose utility LINUX Commands


Objectives: To study and execute commands in Linux
Tools Used: Linux Ubuntu Terminal, Shell: GNU Bash

Procedure: Start Linux operating system. Open terminal and type the commands for the following
tasks preceded by a dollar sign ($). Every command in terminal starts with a dollar sign.

Task # 1: Date Command

Task # 1.1: Current Date and Time


Command: $ date
Output:

Task # 1.2: Abbreviated Week day


Command: $ date +%a
Output:

Operating Systems Lab Designed by Umarah Qaseem


Task # 1.3: Full Week day
Command: $ date +%A
Output:

Task # 1.4: Abbreviated Month


Command: $ date +%b
Output:

Task # 1.5: Full Month


Command: $ date +%B
Output:

Task # 1.6: locale's date and time


Command: $ date +%c
Output:

Task # 1.7: current Century


Command: $ date +%C
Output:

Operating Systems Lab Designed by Umarah Qaseem


Task # 1.8: day of month
Command: $ date +%d
Output:

Task # 1.9: date in mm/dd/yy format


Command: $ date +%D
Output:

Task # 1.10: Hour


Command: $ date +%H
Output:

Task 1.11
Check the difference between date +%l and date +%I?
Answer: %I gives you hour with the leading 0 and %l only gives you hour.

Operating Systems Lab Designed by Umarah Qaseem


Task 1.12: Month of the year
Command: $ date +%m
Output:

Task 1.13 Minute


Command: $ date +%M
Output:

Task 1.14: Display whether it’s AM or PM


Command: $ date +%p
Output:

Task 1.15 Seconds


Command: $ date +%S
Output:

Task 1.16: HH:MM:SS format


Command: $ date +%T
Output:

Task 1.17 Week of the year


Command: $ date +%U
Output:

Task 1.18:
Command: $ date +%y
Output:

Check the difference between %y and %Y

Operating Systems Lab Designed by Umarah Qaseem


Command:$ date +%Y
Output:

Task 1.19 Time Zone


Command: $ date +%z
$ date +%Z
Output:

Task 1.20: Display date and time in your own custom format
Date:
Command: $ date +%Y-%m-%d
Output:

Time:
Command: $date +%s:%M:%H
Output:

Task # 2: Calendar Command


Purpose: To display the calendar of the year or particular month of calendar year.
Task 2.1: Entire Calendar of given year:
Command: $ cal 2020
Output:

Task 2.2: Calendar of a particular month

Operating Systems Lab Designed by Umarah Qaseem


Command: $ cal oct 2020
Output:

Task # 3: Difference between echo and printf()


The difference between echo and printf() command is that echo will send a newline at the end of its
output by default and on the other hand printf() only displays output.

Task # 4: Installation of a software application through Shell and use it.

Task 4.1: Installation of Banner


Command: $ sudo apt install sysvbanner
Output:

Task 4.2: Use Banner Command


Command: $ banner AMMARA 043
Output:

Task # 8: Basic Calculator Mode

Task 8.1: Take two variables. Perform Addition, Subtraction, Multiplication, Division, and
Mod operation on them using the two modes of Bench calculator taught to you.
Command:
 $ c=$(echo "$a +$b" | bc)

Operating Systems Lab Designed by Umarah Qaseem


 $ c=$(echo "$a -$b" | bc)
 $ c=$(echo "$a *$b" | bc)
 $ c=$(echo "$a/$b" | bc)
 $ c=$(echo "$a%$b" | bc)

Output:

Task 8.2: Perform the operations of sqrt(x), scale and power. (See details in tutorial provided)
Command:
 $ c=$(echo "sqrt(50)" | bc)
 $ c=$(echo "5^2" | bc)
 $ c=$(echo "scale=5;sqrt(50)" | bc)
Output:

Submission Date: Instructor: Ms. Umarah Qaseem

Operating Systems Lab Designed by Umarah Qaseem

You might also like