0% found this document useful (0 votes)
52 views17 pages

OSP1

Uploaded by

mitaleeextra
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)
52 views17 pages

OSP1

Uploaded by

mitaleeextra
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/ 17

Name: Mitalee Vaghasia

Roll No.: 22BCE190


Practical No.: 1
Subject: Operating Systems

1. who: who command is a tool to print information about users who are currently
logged in.

2. whoami: displays the username of the current user when this command is
invoked.

3. pwd: displays the present working directory.

4. ls: lists the file and directories present inside the current directory.

5. ls --help: gives all the information about the command options using ls

6. ls --l: displays the long view of the files that contains the permissions for that
file wherein the first 3 are for the users, the next 3 are for the groups and the
last 3 are for others or guest users.
7. ls -a: displays all hidden files as well.

8. chmod: command and system call used to change the access permissions of file
system objects (files and directories) sometimes known as mode.
● R-read, w-write, x-execute
● 777 gives permission to all to read, write and execute (rwx).
● 700 gives rwx permission to the user only.
● chmod+x allows the users to execute the file.

9. mkdir: creates a new directory.

10. touch: used to create empty files and can be used when the user doesn’t have
data to store at the time of file creation.

11. cat: used to create the file with content. ctrl+z to stop entering data.
cat >>filename: to append
cat <filename: to take input

12. head: prints the first 10 lines of the specified file.


13. head –n 4: indicates that it will print the first 3 lines of the file.

14. head –c 3: indicates that it will print the first 3 characters of the file.

15. head --help: gives all the information about the command options using head

16. tail: prints data from the file.

17. tail -c 2: prints the last 2 characters from the file.


18. mv: stands for move and is used to move one or more files or directories from
one place to another in a file system like UNIX (p1 to 22BCE190)

19. cp: used to copy files or group of files or directory.

20. cd: to change the directory (Default: goes back to root directory)

21. date: displays the current date

22. cal: displays the calendar of the current month

23. uname: a command-line utility that prints basic information about the
operating system name and system hardware.

24. ps: stands for “ Process Status” and displays information related to the
processes on a system.
25. df: stands for disk free and is used to display information related to file systems
about total space and available space.

26. du: allows a user to gain disk usage information quickly.

27. ulimit: set or displays information about limits on system resources that have
been set.

28. wc: stands for word count.


Output: no. of lines | word count | byte count/no. of chars in file | file name
29. wc --help: gives all the information about the command options using wc

30. rm: stands for remove and is used to remove objects such as files, directories,
symbolic links and so on from the file system like unix.

31. rmdir: to remove directories.

32. read: to take input from the user into the given variable, without specifying the
datatype.

33. echo: to display the given data or the value stored in the given variable.

34. expr: evaluates a given expression and displays its corresponding output. It is
used for:
● Basic operations like addition, subtraction, multiplication, division, and
modulus on integers.
● Evaluating regular expressions, string operations like substring, length
of strings etc.
35. nano filename: opens shell text editor nano where multiple commands can be
written into a file with the extension .sh

ctrl+x

Enter
36. bash ./filename : to execute the set of commands given in the shell file

37. factor: used to print the prime factors of the given numbers, either given from
command line or read from standard input.

38. logname: print user's login name

39. logname --help: gives all the information about the command options using
logname
40. tty: (teletype) prints the file name of the terminal connected to standard input

41. ln: used to create links between 2 files


Soft link- if the original file gets deleted then the link gets deleted too.
Hard link- if the original file gets deleted, the link still remains.
UNIX FILTER COMMANDS

1. sort: used to sort a file, arranging the records in a particular order. By default,
the sort command sorts file assuming the contents are ASCII.
● Ascending order by default.
● Supports numeric, reverse, and case-insensitive sorting.
● Eliminates duplicates and can sort based on specific fields, not just at
the line's start.
● Provides options for sorting by numbers, months, and checking if a file
is sorted.
● Syntax: sort -r -n -nr {filename}
-r Reverse normal order
-n Sort in numeric order
-nr Sort in reverse numerical order
-f Sort upper and lowercase together.
+x Ignores first x fields when sorting.

2. sort --help: gives all the information about the command options using sort
3. pipe(|): lets you send the result of one command to another (output of one cmd
as input to another).

To print line 5 to 10:

4. netstat: gives information about the network to which the device is connected .
5. pg: a long output’s display stops once the screen is full of text.
6. more: when the screen fills up with the output, at the bottom of the screen is
the more prompt, where you can press the spacebar to view more.

7. comm: compares the content of 2 sorted files and provides common elements
in the output form of:
file1-exclusive | file2-exclusive | common-from-file1-and-file2
8. uniq: compares the content of 2 sorted files and provides unique elements in
the output form of:

9. grep: searches a file for a particular pattern of characters, and displays all lines
that contain that pattern. The pattern that is searched in the file is referred to as
the regular expression (grep stands for global search for regular expression and
print out).
Trying it on the following set of data:

10. grep -i: ‘-i’ in the command tells the grep command to ignore any case
sensitivity.
11. grep -c: ‘-c’ outputs the count for the number of occurrences of the matched
pattern in a file.

12. grep -v: invert the match to display output not matching the input pattern
using ‘-v’.

13. grep -n: output with numbers are the matched patterns using ‘-n’. This displays
the specific number count where the matched pattern is in the file.

14. grep -l: to only output the files containing the matched pattern we use ‘-l’

15. grep <searchElement> *: to search from all the files in a directory containing
a certain pattern, we use‘*’. It shows the specific files and the results of the
match.
16. grep -w: to match whole words in a file. Grep by default outputs all the
occurrences of a certain pattern even if it is found in substring. To match whole
words only, we use ‘-w’ flag.
17. grep “^character” filename: used to display all lines that start with the given
character. This command is case sensitive.

18. grep “number$” filename: used to display all lines that end with the given
character. This command is case sensitive.

19. grep -e “keyword1” -e “keyword2” filename: search and display multiple


keyword searches at the same time

20. grep “keyword1” filename1 filename2 filename3…: for keyword searches


from different files at the same time

21. tr: for transforming the upper case to lower case or the other way around
22. tee: used to store the intermediate process in the mentioned file

23. awk: to search through a file for a specific pattern and performs an action
when a match is found
awk ‘{print}’ filename- prints full content of test file
awk ‘/manager/ {print}’ filename- prints the lines with the word “manager”
awk ^manager/ {print}’ filename- prints the lines starting with the word
“manager”
$ awk ‘{print $1,$3}’ filename- to split a line into fields and print out the
content, here, first and third parts of the lines in the file.
NF – outputs the number of fields contained in each record (line)
$NF – prints the last columns
NR – Prints lines along with the line numbers
$0 outputs the entire line.
OFS – Output field separator – used to specify the separator for the output
values.

24. sed: is short for stream editor. It can be used to perform different functions such
as searching, find and replace, insert and delete. It is, however, common for
find and replace and you don’t have to open the file to substitute words.
To print the replaced line only instead of printing all the file content:

25. cut: for cutting out the sections from each line of files and writing the result to
standard output. It can be used to cut parts of a line by byte position, character
and field. • Syntax: • cut OPTION... [FILE]...
Here, -d is stands for delimiter

You might also like