OS Lab 03
OS Lab 03
LAB-Manual 03
BS-Computer Sciences
Faculty of Computing
Riphah International University Islamabad Campus I-14
Instructions
Submission: Use proper naming convention for your submission file.
Name the submission file as
LabNO_SAPID_Section (e.g. Lab03_23456_CS5)
Submit the file on Moellim within the deadline. Failure to submit
according to the above format would result in deduction of 10% marks.
Submissions on the email will not be accepted.
Linux Terminal
You must have used DOS commands copy, format, dir etc. Similarly Linux has such type of commands but
with different syntax and format. You have to remember these commands because you will be using these
commands frequently, and these commands will become base for your next practice. There is syntax for
each command, using wrong syntax the command will not execute.
Linux come with software that is called Terminal. when you run it, following screen appear with user
prompt in Red Hat Linux.
Now to check which shell you running, run echo $0 command on shell.
Note:- Linux commands are case-sensitive. All standard Linux commands use lower case letters only.
The elementary commonly used directory commands are ls, cd, mkdir, pwd and rmdir, and most elementary
file commands includes cat, cp, mv, and rm.
When you login, there is a special directory associated with your login name called your home directory.
Your home directory is actually your initial current working directory. The simplest way to find out where
in the directory hierarchy your home directory is located is just to use the command pwd straight after you
login.
The pwd command tells you your present working directory.
Note:- Linux commands are case-sensitive. All standard Linux commands use lower case letters only.
Directory Commands:
A request from a programmer, an operator, or a user to Linux operating system asking that a specific
function be performed; for example, a request to list all files in your current directory. Shell
commands operate on files, directories, and various devices – disk, printers, etc.
1). ls Command:
Command Description
ls List the file in the directory, just like dir command in DOS.
Example:
ls and ls -la
ls –a
ls -l
2). cd Command:
In order to move your present working directory away from your home directory to somewhere else in
the directory hierarchy, you use the cd (change directory) command. So, to change directory to the
directory hierarchy’s root directory you would use the command. (Note: Linux directory tree structure is
given in Lab 2).
Command Description
Example:
What have you observed in the execution of above commands?
Command Description
Example:
This command will create a new directory under the home directory.
Though you have created a sub-directory books, but you are still in the home (parent directory) directory as
specified by ~ Sign.
Exercise:
After you move inside lab3 directory. What are you feeling differences between two prompts? Now you are
in lab3 directory, a step down to home. How will you go up?
Exercise:
Create other directory OS under Lab3, and move to OSlab directory.
[shahzad@shahzad ~] cd lab3/os (enter)
Command Description
5). rm Command:
Command Description
rm Remove a file
rm dir/* will remove all files within “dir” directory
Options -iThis option puts the rm command into interactive
mode and prompts you before it removes it
LAB Tasks:
books
Example:
If I’m in directory classical, how would I find where I am? The command used for the purpose is pwd.
Ans: When I entered this command when I was in directory classical the following information was
printed on my screen. The path printed was absolute path.
So when you lost in directory structure you could find the way to your current directory by command pwd.
7) How will you add a directory graphics under the directory computer while you are in physics’ sub-
directory classical?
8) What is difference between rmdir and rm Commands?
--------------------------------------------------------END----------------------------------------------------------------