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

Name: Ashwath Shivram Reg. No.: 22BAI1188 Title: Lab Report 1 Course Code: BCSE303P Operating Systems 1. PWD Command

This document contains a lab report describing various Linux commands used for operating systems course BCSE303P. It provides 17 commands - pwd, mkdir, cd, head, awk, sort, cut, diff, find, su, uname, hostname, ifconfig, netstat, nslookup, history, and echo along with their syntax and usage. For each command, it explains the purpose and provides examples of common options.

Uploaded by

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

Name: Ashwath Shivram Reg. No.: 22BAI1188 Title: Lab Report 1 Course Code: BCSE303P Operating Systems 1. PWD Command

This document contains a lab report describing various Linux commands used for operating systems course BCSE303P. It provides 17 commands - pwd, mkdir, cd, head, awk, sort, cut, diff, find, su, uname, hostname, ifconfig, netstat, nslookup, history, and echo along with their syntax and usage. For each command, it explains the purpose and provides examples of common options.

Uploaded by

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

Name: Ashwath Shivram

Reg. No.: 22BAI1188


Title: lab report 1
Course code: BCSE303P Operating Systems

1. pwd Command
The pwd command is used to display the location of the current working directory.

2. mkdir Command
The mkdir command is used to create a new directory under any directory.

Use the mkdir command to create one or multiple directories and set their
permissions. Ensure you are authorized to make a new folder in the parent directory

3. cd command
Use the cd command to navigate the Linux files and directories. To use it, run this
syntax with sudo privileges

4. head command
The head command prints the first ten lines of a text file or piped data in your
command-line interface.
5. awk command
The awk command scans regular expression patterns in a file to retrieve or
manipulate matching data.
The action can be mathematical operations, conditional statements like if, output
expressions such as print, and a delete command. It also contains the $n notation,
which refers to a field in the current line.

6. sort command
The sort command rearranges lines in a file in a specific order. It doesn’t modify the
actual file and only prints the result as Terminal outputs
By default, this command will sort the lines in alphabetical order, from A to Z. To
modify the sorting, use these options:
 -o – redirects the command outputs to another file.
 -r – reverses the sorting order to descending.
 -n – sorts the file numerically.
 -k – reorders data in a specific field.

7. cut command
The cut command retrieves sections from a file and prints the result as Terminal
outputs. Here’s the syntax:
cut [option] [file]

Instead of a file, you can use data from standard input. To determine how the
command sections the line, use the following options:
 -f – selects a specific field.
 -b – cuts the line by a specified byte size.
 -c – sections the line using a specified character.
 -d – separates lines based on delimiters.
You can combine these options, use a range, and specify multiple values. For
example, this command extracts the third to fifth field from a comma-separated list
8. diff command
The diff command compares two files’ content and outputs the differences. It is used
to alter a program without modifying the code. Here’s the general format:
diff [option] file1 file2

Below are some acceptable options:


 -c – displays the difference between two files in a context form.
 -u – shows the output without redundant information.
 -i – makes the diff command case insensitive

9. find command
Use the find command to search for files within a specific directory. Here’s the
syntax:
find [option] [path] [expression]

For example, to find a file called file1.txt within the directory folder and its
subdirectories, use this command

10. su command
The su command lets you run a program in the Linux shell as a different user. It is
useful to connect via SSH while the root user is disabled. Here’s the syntax:
su [options] [username [argument]]

Without any option or argument, this command runs through root and prompts you
to use the sudo privileges temporarily. Some options are:
 -p – keeps the same shell environment, consisting of HOME, SHELL, USER, and
LOGNAME.
 -s – lets you specify another shell environment to run.
 -l – runs a login script to switch users. It requires you to enter the user’s
password. For whoami command:
11. uname command
The uname or unix name command prints information about your machine, including
its hardware, system name, and Linux kernel. Here’s the basic syntax:
uname [option]

While you can use it without an option, add the following to modify the command:
 -a – prints all the system information.
 -s – outputs the kernel name.
 -n – shows the system’s node hostname.

12. hostname command


Run the hostname command to display the system’s hostname. Here’s the syntax:
hostname [option]

You can run it without an option or use the following:


 -a – displays the hostname’s alias.
 -A – shows the machine’s Fully Qualified Domain Name (FQDN).
 -i – outputs the machine’s IP address.

13. ifconfig command


The ifconfig command lets you list and configure your system’s network interface. In
newer Linux distros, it is equivalent to the ip command. Here’s the basic syntax:
ifconfig [interface] [option]

Running it without arguments displays information about all network interfaces in


your system. To check a specific interface, add its name as an argument without an
option. For a more specific task, use the following options:
 –s – summarizes the network interfaces and their configuration. This option
goes before the interface name.
 up and down – enables and disables a network interface.
 inet and inet6 – assigns an IPv4 and IPv6 address to a network interface.
 netmask – specifies the subnet mask to use with an IPv4 address.
14. netstat command
The netstat command is used to display your system’s network information, like
sockets and routing. Here’s the command syntax:
netstat [option]

Use various options to modify the displayed information. Some common ones are:
 -a – displays listening and closed sockets.
 -t – shows TCP connections.
 -u – lists UDP connections.
 -r – displays routing tables.

15. nslookup command


The nslookup command queries a DNS server to find out the domain associated with
an IP address and vice versa. Here’s the syntax:
nslookup [options] domain-or-ip [server]

If you don’t specify the DNS server to use, nslookup will use the default resolver from
your system or internet service provider. This command supports various options,
with some commonly used ones being:
 -type= – queries specific information, like the IP address type or MX record.
 -port= – sets the DNS server’s port number for the query.
 -retry= – repeats the query a specific number of times upon failure.
 -debug – enables the debug mode to provide more information about the
query.

16. history command


Enter history to list previously executed commands. It lets you reuse the commands
without rewriting them. To use it, enter this syntax with sudo privileges:
history [option] To rerun a specific utility, enter an exclamation
mark (!) followed by the command’s list number. For example,
use the following to rerun the 255th command:
!255

This command supports many options, such as:


 -c – clears the history list.
 -d offset – deletes the history entry at the OFFSET
position.
 -a – appends history lines.
17. echo command
The echo command displays a line of text as a standard output.
Here’s the basic command syntax:
echo [option] [string]

You might also like