Pratham Exp4
Pratham Exp4
EXPERIMENT - 4
2.OUTCOME : Demonstrate Unix commands for file handling and process control.
3.OBJECTIVE : Develop the ability to manage files and directories efficiently by performing tasks like
viewing ,copying ,identifying files type,and checking,disk usage.
4.INTRODUCTION : File handling commands in Linux , such as man, uptime , pr , sort ,are used for
managing file and directories by performing tasks like viewing, copying, identifying ,file types and
analyzing content efficiently.
5.THEORY :
man:
Description: The man command in Linux is used to display the user manual of any command that we
can run on the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS,
DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES.
Options :
. -c : config-file
. -d : default
. -f : what is
. -c : cat man
Uptime:
Syntax: uptime [OPTION]…
Description: The uptime command is a handy utility tool that provides information about how
long a Linux system has been running, the number of users logged in, and the current system
load average.
Options:
pr:
Syntax: pr [options][filename]
Description: In Linux/Unix pr command is used to prepare a file for printing by adding
suitable footers, headers, and the formatted text. pr command actually adds 5 lines of
margin both at the top and bottom of the page. The header part shows the date and
time of the last modification of the file with the file name and the page number.
Options:
Clear:
Syntax : clear
Descritption: In Linux, the "clear" command is used to instantly remove all visible text
from the terminal screen, providing a clean slate to work with without deleting any
data; essentially, it just clears the current output displayed on the terminal window,
allowing for a better view of new commands.
Options:
. clear
. reset
Whoami:
Syntax : whoami [option]
Description: The whoami command in Linux displays the username of the current user. It is
often used in shell scripts or the terminal.
Options:
• -h, --help - Display a help message and exit.
• -V, --version - Shows the version information and exit.
free:
Syntax: free [OPTION]
Description: The "free" command in Linux is a utility used to display detailed information about
your system's memory usage, including the total amount of RAM, how much is currently used,
how much is free, and the status of swap space, allowing you to monitor and troubleshoot
memory related issues on your system.
Options:
lsof:
Syntax: lsof [option] [action or filepath].
Description: lsof is a command meaning "list open files", which is used in many Unix-like
systems to report a list of all open files and the processes that opened them. This open source
utility was developed and supported by Victor A. Abell, the retired Associate Director of the
Purdue University Computing Center.
Options:
. - p [PID] Shows all open files associated with a specific process ID.
pipe:
Syntax: command1 | command2
Description: A pipe is a form of redirection (transfer of standard output to some other
destination) that is used in Linux and other Unix-like operating systems to send the output of
one command/program/process to another command/program/process for further processing.
Options:
• ls | grep file.txt.
• $ ls -l | more.
• ls -l -> temp.
• sort record.txt | uniq
ps:
Syntax: ps [options]
Description: In Linux, the "ps" command stands for "process status" and is used to display
information about currently running processes on the system, including their process ID (PID),
user, CPU usage, memory usage, and the command that launched them, providing a snapshot of
the system's active processes and allowing users to monitor their status and identify potential
issues.
Options:
• ps aux: Displays all processes in the system
• ps -ef: Lists and filters both processes and threads
pwd:
Syntax: pwd [optional_arguments]
Description: The pwd command in Linux prints the full path of the current working
directory. The path is written to the standard output, starting from the root directory.
Options:
grep:
Syntax : grep [options] [pattern] [file]
Description: In Linux, the "grep" command is a utility used to search for specific patterns within
text files, essentially allowing you to find lines containing a particular string or pattern by
printing only those lines that match the search criteria; "grep" stands for "Global Regular
Expression Print", meaning it can use complex regular expressions to identify matches within
text files effectively.
Options:
Viva questions :