You are on page 1of 16

OPERATING SYSTEMS LAB 03

TOPIC: Linux Commands and Practice Problems

SUBMITTED BY: Muhammad Hassan Imtiaz


SUBMITTED TO: Mr. Kashif Nazir

DEPARTMENT: Computer Science


CLASS: BSCS-5th
ROLL NO: FC-071

NATIONAL UNIVERSITY OF MODERN


LANGUAGES
Problem 1:
Enter the following commands on LINUX prompt, and try to interpret the
output. Give description of each command in at least one line.

01:
Displays the text "hello world" to the terminal.

02:
Allows a user to change their password.

03:
Prints the current date and time.

04:
Shows the system's hostname.
05:
Displays the CPU architecture of the system.

06:
Shows detailed system information, including the kernel version

07:
Provides information about how long the system has been running.

08:
Shows the current user's login information.

09:
Lists all users currently logged in.
10:
Displays user and group information.

11:
Shows a list of recent logins

12:
Displays a list of logged-in users and their activities.
13:
Opens a real-time system monitoring tool; press 'q' to quit.

14:
Prints the path to the user's default shell.

15:
Opens the manual page for the "ls" command; press 'q' to quit.
16:
Opens the manual page for the "who" command; press 'q' to quit.
17:
Clears the terminal screen.
18:
Displays the calendar for the year 2000.
19:
Shows the calendar for September 1759.
20:
Calculates and displays the result of 5 + 4 using the "bc" calculator.

21:
Repeatedly prints "please" until interrupted with Ctrl-C.

22:
Measures and displays the time taken for the "sleep 5" command to execute.
23:
Shows a list of previously executed commands.

24:
Installs the NASM assembler using the APT package manager with superuser
privileges.
PROBLEM 02:
 cd - Change to the user's home directory.

 pwd - Display the current directory (home directory).

 ls -al - List all files and directories in detail in the current directory (home
directory).
 cd . - Change to the current directory (no change).

 pwd - Display the current directory (home directory, no change).

 cd .. - Change to the parent directory.

 pwd - Display the current directory (parent directory).


 ls -al - List all files and directories in detail in the parent directory.

 cd .. - Change to the parent directory's parent directory (grandparent


directory).

 pwd - Display the current directory (grandparent directory).

 cd /etc - Change to the '/etc' directory.

 ls -al | more - List all files and directories in '/etc' and use 'more' to paginate
the output.
cat passwd - Display the contents of the 'passwd' file.
 cd - - Change back to the previous directory ('/etc' to the current directory
before the 'cd' command).

 pwd - Display the current directory (previous directory).

You might also like