0% found this document useful (0 votes)
11 views6 pages

Exp 2

This document outlines an experiment focused on various general-purpose file utility commands in UNIX, detailing their syntax, descriptions, and examples. The commands covered include cal, date, bc, echo, who, pwd, ls, rm, mkdir, rmdir, find, and history, each serving specific functions for system management and user monitoring. Additionally, it includes viva questions related to the commands discussed.

Uploaded by

rhythmbhandari99
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)
11 views6 pages

Exp 2

This document outlines an experiment focused on various general-purpose file utility commands in UNIX, detailing their syntax, descriptions, and examples. The commands covered include cal, date, bc, echo, who, pwd, ls, rm, mkdir, rmdir, find, and history, each serving specific functions for system management and user monitoring. Additionally, it includes viva questions related to the commands discussed.

Uploaded by

rhythmbhandari99
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/ 6

EXPERIMENT -2

1.Title: Study of various general purpose file utility commands.

2.OUTCOME- Demonstrate retrieving information, tracking users, and executing commands smoothly.

3.OBJECTIVE – Develop the ability to formulate system management,user monitoring, and calculations
efficiently.

4.INTRODUCTION- UNIX commands are instructions given to the operating system to perform various
tasks such as managing files, handling processes, and interacting with the system. These commands help
users navigate the file system, perform calculations, check system information, and control user access.

4.THEORY-

1. cal – Display a Calendar Syntax: cal [month] [year]

Description: The cal command is used to display the calendar of a specific month or year. If no
arguments are provided, it shows the current month's calendar.

Examples:

cal → Displays the current month's calendar.


cal 3 2023 → Shows the calendar for March 2023.
cal $(date +"%Y" -d "2 years ago") → Displays the calendar for two years ago.
OUTPUT-

Rhythm Bhandari 24100BTCSE17833


2. date – Show and Modify System Date and Time Syntax: date [options]

Description: The date command displays or modifies the system's date and time.

Examples:

date → Shows the current date and time.


date --date="2 years ago" → Displays the date exactly two years ago.
date --date="yesterday" → Displays yesterday’s date. date --date="tomorrow" → Displays
tomorrow’s date.

OUTPUT-

3. bc – Basic Calculator for Mathematical Operations Syntax: bc [options]

Description: The bc command is used for performing mathematical calculations, similar to a basic
calculator.

Options:

-h, --help → Prints usage and exits.


-i, --interactive → Forces interactive mode.
-l, --mathlib → Loads the standard math library.

Examples:

echo "5+3" | bc → Outputs 8.


echo "scale=3; 10/3" | bc → Outputs 3.333 (sets decimal precision to 3 places). OUTPUT-

4. echo – Print Text on the Terminal Syntax: echo [text]

Description: The echo command prints messages or variables to the terminal.

Examples:

echo "Hello, UNIX!" → Prints "Hello, UNIX!".

echo "Section C" → Displays "Section C".

OUTPUT-

Rhythm Bhandari 24100BTCSE17833


5. who – Show Logged-in Users Syntax: who [options]

Description: The who command displays information about logged-in users.

Examples:

who → Shows the list of logged-in users.


who -q → Displays the number of logged-in users.

OUTPUT-

6. pwd – Show Current Directory Syntax: pwd


Description: The pwd (Print Working Directory) command displays the current location in the file system.
Example:
pwd → Prints the full path of the current directory.

7. ls – List Files and Directories Syntax: ls [options] [directory]

Description: The ls command is used to display files and directories.

Examples:

Rhythm Bhandari 24100BTCSE17833


ls → Shows all files in the current directory.

ls -l → Displays detailed file information.

OUTPUT-

8. rm – Remove Files Syntax: rm [options] [file]

Description: The rm command is used to delete files.

Example:

rm file.txt → Deletes the file "file.txt".

OUTPUT-

9. mkdir – Create a Directory


Syntax: mkdir [options] [directory_name]
Description: The mkdir command creates a new folder.
Example:
mkdir myfolder → Creates a folder named "myfolder".
OUTPUT-

10. rmdir – Remove an Empty Directory Syntax: rmdir [directory_name]

Description: The rmdir command deletes an empty folder.

Rhythm Bhandari 24100BTCSE17833


Example:

rmdir hi → Removes the "hi" folder if empty.

11. find – Search for Files


Syntax: find [path] -name [pattern]
Description: The find command is used to search for files in directories.
Examples:
find . -name "*.txt" → Finds all text files in the current directory.
find /home -name "*.jpg" → Finds all JPG images in the /home folder.
OUTPUT-

12. history – View Previously Used Commands Syntax: history

Description: The history command shows a list of previously entered commands.

Example:

history | grep ls → Shows history of ls commands used.

OUTPUT-

Rhythm Bhandari 24100BTCSE17833


5.Viva Questions

1. How do you check who is currently logged into the system?

2. How do you check the current working directory in UNIX?

3. How do you list files in a directory?

4. What is the difference between rm and rmdir?

5. How do you create and remove a directory in UNIX?

Rhythm Bhandari 24100BTCSE17833

You might also like