OSfff (2)
OSfff (2)
IV SEMESTER
Laboratory Manual
Session 2024-25
Page 1
Faculty of Engineering & Technology
Subject Name : OS Laboratory
Subject Code : 303105252
B.Tech CSE Year 2nd Semester 4th
CERTIFICATE
TABLE OF CONTENT
DESCRIPTION:
pwd prints the full pathname of the current working directory.
SYNTAX:
Pwd
OUTPUT:
2. cd:
Change Directory
DESCRIPTION:
It allows you to change your working directory. You use it to move around within the hierarchy of your
file system.
SYNTAX:
cd directory_name
OUTPUT:
3. cd .. :
DESCRIPTION:
Move up one directory from present directory we use cd .. command.
SYNTAX:
cd ..
OUTPUT:
4. ls :
list all the files and directories
DESCRIPTION:
To list all files and folders in the current directory in the column format we use ls command.
SYNTAX:
ls [options]
OUTPUT:
5. mkdir:
MakeDirectory
DESCRIPTION:
mkdir stands for "make directory". The mkdir command allows you to create directories from within the terminal.
SYNTAX:
mkdir filename
OUTPUT:
6. head
DESCRIPTION:
head, by default, prints the first 10 lines of each FILE to standard output.
SYNTAX:
head directory_name
OUTPUT:
7. tail:
DESCRIPTION:
tail is a command which prints the last few number of lines (10 lines by default) of a certain file, then
terminates.
SYNTAX:
tail directory_name
OUTPUT:
8. mv :
Moving (and Renaming) Files
DESCRIPTION:
The mv commands are equivalent to the copy-paste and cut-paste commands in Windows. But since Linux
doesn’t really have a command for renaming files, we also use the mv command to rename files and folders.
SYNTAX: mv
mv source destination(OR mv oldname newname)
OUTPUT:
9. rmdir :
Remove Directory
DESCRIPTION:
If the specified directory does exist, rmdir removes or delete it. More than one directory may be specified
when calling rmdir.
SYNTAX:
rmdir directory
OUTPUT:
10. cp :
Copy Files
DESCRIPTION:
The cp command is used to make copy of files and directories.
SYNTAX:
cp source destination
OUTPUT:
11. rm:
Romove Directory
DESCRIPTION:
The rm command deletes files and directories. But we need to caution because deleted files and directories cannot
be recovered.
SYNTAX:
rm directory_name
OUTPUT:
12. echo:
DESCRIPTION:
Display text on the screen.
OUTPUT:
13. clear:
DESCRIPTION:
Used to clear the screen
SYNTAX: clear
OUTPUT:
14. date :
DESCRIPTION:
display current date and time.
SYNTEX: date
OUTPUT:
15. cat:
DESCRIPTION:
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display content of the
file, copy the content of one file to another file, and more.
OUTPUT:
16. touch:
DESCRIPTION:
create a new empty file
SYNTEX:
touch file_name
OUTPUT:
17. tar:
DESCRIPTION:
The tar command in Linux is used to create and extract archived files. We can extract multiple different archive files using
the tar command. To create an archive, we use the -c parameter, and to extract an archive, we use the -x parameter.
SYNTEX:
tar -cvf filename.tar file1 file2
tar -xvf filename.tar
OUTPUT:
18. whoami:
DESCRIPTION:
The whoami command in Linux returns the current user’s username. It stands for “who am I?” and it’s often used to determine
the current user’s identity in shell scripts or the terminal.
SYNTEX:
whoami
OUTPUT:
19. man:
DESCRIPTION:
The man command in Linux is used to display the manual page for a specific command. It provides detailed information about
the command, including its syntax, options, and examples.
SYNTEX:
man command_name
OUTPUT:
20. FREE:
DESCRIPTION:
Displays RAM details in Linux machine.
SYNTEX:
free
OUTPUT:
21. grep:
DESCRIPTION:
The grep command is a powerful and versatile text search tool in Linux and Unix-based operating systems. It can search for
specific patterns or strings in one or more files and filter the output of other commands.
SYNTEX:
any_command_with_output | grep “string”
OUTPUT:
22. sort:
DESCRIPTION:
The sort command is used to sort lines in a text file or standard input in Linux and Unix-based operating systems. It can be used
to sort lines in ascending or descending order and to perform other sorting operations.
SYNTEX:
sort filename
OUTPUT:
23. alias:
DESCRIPTION:
We have some commands that we run very frequently while using the terminal. It could be rm -r or ls -l, or it could be something
longer like tar -xvzf. So it’s a time we need to create an alias. In simple terms, it’s another name for a command that we’ve
defined.
SYNTEX:
alias newName=”command”
OUTPUT:
24. passwd:
DESCRIPTION:
The passwd command lets you set the password for our own account, or if you have the permissions, set the password for other
accounts.
SYNTEX:
passwd
OUTPUT:
25. ps:
DESCRIPTION:
The ps command summarizes the status of all running processes in your Linux system at a specific time. Unlike top and htop, it
doesn’t update the information automatically.
SYNTEX:
ps
OUTPUT:
PRACTICAL NO: 2
Aim: Study the basics of shell programming.
What is a Shell? An Operating is made of many components, but its two prime components
are –
• Kernel
• Shell
A Kernel is at the nucleus of a computer. It makes the communication between the hardware
and software possible. While the Kernel is the innermost part of an operating system, a shell
is the outermost one.
A shell in a Linux operating system takes input from you in the form of commands, processes
it, and then gives an output. It is the interface through which a user works on the programs,
commands, and scripts. A shell is accessed by a terminal which runs it.
When you run the terminal, the Shell issues a command prompt (usually $), where you can
type your input, which is then executed when you hit the Enter key. The output or the result
is thereafter displayed on the terminal.
The Shell wraps around the delicate interior of an Operating system protecting it from
accidental damage. Hence the name Shell.
Types of Shell
There are two main shells in Linux:
1. The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:
• POSIX shell also is known as sh
• Korn Shell also knew as sh
• Bourne Again Shell also knew as bash (most popular)
What is Shell Scripting?
Shell scripting is writing a series of command for the shell to execute. It can combine lengthy
and repetitive sequences of commands into a single and simple script, which can be stored
and executed anytime. This reduces the effort required by the end user.
1. Adding a comment
Praveen kashyap
AIM:- Finding out biggest number from given three numbers supplied as
command line arguments.
PRACTICAL 9
AIM:- Write a program for process creation using C. (Use of gcc compiler).
PRACTICAL 12