0% found this document useful (0 votes)
24 views5 pages

Linux Prac 2

This document contains the answers to various Linux commands related to displaying system information, managing directories and files. It provides the commands to print OS name, username, hostname, list logged in users, display calendar, current time in 12 and 24 hour formats, current date and time, home directory, create and remove directories and files.

Uploaded by

Vaibhavi Awale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

Linux Prac 2

This document contains the answers to various Linux commands related to displaying system information, managing directories and files. It provides the commands to print OS name, username, hostname, list logged in users, display calendar, current time in 12 and 24 hour formats, current date and time, home directory, create and remove directories and files.

Uploaded by

Vaibhavi Awale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

25/02/24LINUX OPERATING SYSTEM PRACTICAL 02ROLL NO.

12

1) Obtain the following results


a. To print the name of operating system
Ans-

uname -o: Prints the name of the operating system.


b. To print the login name

Whoami : Displays the current login username.


c. To print the host name

hostname: Shows the host name of the system.

2) Find out the users who are currently logged in and find the particular user too.

Ans -
who: Lists users currently logged in.
who | grep <username>: Finds information about a specific user.
3) Display the calendar for
cal: Displays a calendar.
date "+%a, %b %d %Y": Shows the current date with day abbreviation, month abbreviation,
and year.
a. Jan 2024
25/02/24LINUX OPERATING SYSTEM PRACTICAL 02ROLL NO. 12

b. Feb 2025

c. 9th month of the year 7 A.D

d. For the current month

e. Current Date Day Abbreviation, Month Abbreviation along with year

date "+%a, %b %d %Y": Shows the current date with day abbreviation, month abbreviation,
and year

4) Display the time in 12-Hour and 24 Hour Notations.


Ans -
25/02/24LINUX OPERATING SYSTEM PRACTICAL 02ROLL NO. 12

date "+%r": Prints the current time in 12-hour format.


date "+%T": Displays the current time in 24-hour format.

5) Display the Current Date and Current Time.


Ans-

date: Shows the current date and time.

6) Display the name of your home directory.


Ans-

echo $HOME: Prints the name of the home directory.

7) Create a directory SAMPLE under your home directory.


Ans-

mkdir $HOME/SAMPLE/TRIAL: Creates a sub-directory named TRIAL under SAMPLE.

8) Create a sub-directory by name TRIAL under SAMPLE.


Ans –
25/02/24LINUX OPERATING SYSTEM PRACTICAL 02ROLL NO. 12

mkdir $HOME/SAMPLE/TRIAL: Creates a sub-directory named TRIAL under SAMPLE.

9) Change to SAMPLE.
Ans-

cd $HOME/SAMPLE: Changes to the SAMPLE directory.

10) Change to your home directory.


Ans-

cd: Changes to the home directory.

11) Remove directory TRIAL.


Ans –

rmdir $HOME/SAMPLE/TRIAL: Removes the TRIAL sub-directory.


25/02/24LINUX OPERATING SYSTEM PRACTICAL 02ROLL NO. 12

12) Using a single command change from current directory to home directory.
Ans-

cd ~: Changes from the current directory to the home directory.

13) Create files myfile and yourfile under Present Working Directory.
Ans-

touch myfile yourfile: Creates empty files named myfile and yourfile.

14) Display the files myfile and yourfile.


Ans-

ls myfile yourfile: Lists the files myfile and yourfile in the current directory.

15) Can you remove a directory with files by using a single command?
Ans-

rm -r DIRECTORY_NAME: Removes a directory and its contents. Exercise caution, as it


deletes recursively.

You might also like