0% found this document useful (0 votes)
35 views9 pages

OS Lab 03

Uploaded by

Rai Bilal Sultan
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)
35 views9 pages

OS Lab 03

Uploaded by

Rai Bilal Sultan
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/ 9

OPERATING SYSTEM

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.

Plagiarism: Plagiarism cases will be dealt with strictly. If found


plagiarized, both the involved parties will be awarded zero marks in the
assignment, all of the remaining assignments, or even an F grade in the
course. Copying from the internet is the easiest way to get caught!

Deadline: The deadlines to submit the assignment are hard. Late


submission with marks deduction will be accepted according to the course
policy shared by the instructor. Correct and timely submission of the
assignment is the responsibility of every student; hence no relaxation will
be given to anyone.

Tip: For timely completion of the assignment, start as early as possible.


Furthermore, work smartly - as some of the problems can be solved using
smarter logic.
1. Note: Follow the given instructions to the letter, failing to do so will
result in a zero.
Lab - 3: Linux Basic Commands:
In the previous lab we learnt how to install Linux operating system using Virtualization software. As a first
step we will learn Linux commands. We are going to look at some of basic BASH shell commands. Most
of them works fine in other shells (Korn, CSH, TCSH) as well.

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.

Fig: User prompt in Ubuntu 20.04 Linux

user@pointlinux :~ $ is called user prompt. it consist of four elements


1) User Name: Name of current login user (user)
2) Machine Name: Name of machine (pointlinux)
3) Current Path: This is path where currently user is in.
(~ shows users is login at home directory)
4) Sign: $ shows user can only perform limited commands.
it replaces with # sign when login as root user. root user can execute all commands.

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.

Elementary Directory Commands

The elementary commonly used directory commands are ls, cd, mkdir, pwd and rmdir, and most elementary
file commands includes cat, cp, mv, and rm.

Exploring the File Hierarchy

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.

Options -a Display all the files, and subdirectories, including


hidden files.
-l Display detailed information about each file, and
directory.
-r Display files in the reverse order.

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

cd Used to Change your current directory to another directory.

cd / Move to root directory

cd .. Move to one directory backward

cd {dir-name} To change to any sub-directory under the current directory.

Example:
What have you observed in the execution of above commands?

3). mkdir Command:

Command Description

mkdir {dir-name} Creates a new directory.


{dir-name} specifies the name of the new directory. If the name
doesn’t begin with a slash, the new directory is created as a
subdirectory of the current working directory.
If the name begins with a slash, the name defines the path from
the root directory to the new directory.

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.

How would you go to the directory books?

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)

4). rmdir Command:

Command Description

rmdir {dir-name} Delete a Directory (if it is empty)


rmdir will only work if the directory you are trying to remove
does not contain any file. So first remove all files from the
directory.

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:

Show Simulation results after performing the following tasks by using


suitable commands in Linux
1) Verify that you are in your home directory.
2) Make the directory adir using the command: mkdir adir if problem occurs, use sudo mkdir adir and
then give password.
3) List the files in the current directory to verify that the directory adir has beenmade correctly.
4) Change directories to adir.
5) Verify that you have succeeded in moving to the adir directory.
6) Make the following directory hierarchy:

books

math physics computer

trigonometrycalculus quantum classical nuclear

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----------------------------------------------------------------

You might also like