0% found this document useful (0 votes)
27 views

Experiment 2 - Unix

This document contains an instructor manual for a Unix programming lab experiment at SVKM's NMIMS Mukesh Patel School of Technology Management & Engineering. The experiment aims to study different aspects of the Unix/Linux operating system. It includes questions about Unix commands and their usage, the differences between various commands and functions, and the prerequisites and expected outcomes of the experiment.

Uploaded by

Shristi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Experiment 2 - Unix

This document contains an instructor manual for a Unix programming lab experiment at SVKM's NMIMS Mukesh Patel School of Technology Management & Engineering. The experiment aims to study different aspects of the Unix/Linux operating system. It includes questions about Unix commands and their usage, the differences between various commands and functions, and the prerequisites and expected outcomes of the experiment.

Uploaded by

Shristi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

SVKM’s NMIMS

Mukesh Patel School of Technology Management &Engineering Shirpur Campus


Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

Experiment # 2
Name: Raj Patel Rno: B264 Class: B. Tech C.E.

Aim: - To study the different aspects of Unix/Linux operating system

UNIX PROGRAMMING

Q-1 What will the following command do?

a) $ ls [a –d]??

This function searches file name starting with a-d followed by any 2 characters only.

b) $ ls [a –z] [0 -9]

This function searches file name starting with a-z followed by 0-9.

c) $ ls –Rt

1
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

This function is used to show all the directories, sub-directories and files present in the
computer.

d) $ mkdir -m 740 apple

This function is used to create a directory called apple. It assigns 740 permission to the
owner, group and others respectively.

e) $ mkdir -p fruits/delicious/apple

2
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

This function is used to create a directory called fruits with a sub-directory called
delicious inside it. Delicious directory will have a dub-directory called apple.

f) $ touch 07151000 mbacourse.txt

This function is used to create 2 files called 07151000 and mbacourse.txt

g) $ cat mbacourse.txt lawcourse.txt

This function is used to show the contents of the files mbacourse.txt and lawcourse.txt

h) $ rmdir -p fruits/delicious/apple

3
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

This function removes the directory and all its sub directories.

i) $ cp /fruits/delicious/apple/juice.txt college/students

This function is used to copy a file from one location to another.

j) $ rm –r college

This removes the folder named college.

k) $ mv mbacourse.txt management.txt

This command is used to move files from one location to another.

l) $ ln –f juice.txt energy.txt

This command is used to create a hard link or a symbolic link to an existing file or
directory.

m) $ finger Charlesfinger

4
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

This command is a user information lookup command which gives details of all the users
logged in.

Q-2 Explain the difference between the following:

a) Hard and Symbolic links


Hard links and symbolic links are two different methods to refer to a file in the hard
drive. These methods are part of the filesystem that organizes what file is what and
where. A hard link is essentially a synced carbon copy of a file that refers directly to the
inode of a file. Symbolic links on the other hand refer directly to the file which refers to
the inode, a shortcut.

b) Who and finger commands


Who command is a tool print information about users who are currently logged in. who
command only see a real user who logged in. On most Linux distribution, who command
is already installed.
Finger command is a user information lookup command which gives details of all the
users logged in. This tool is generally used by system administrators. It provides details
like login name, user name, idle time, login time, and in some cases their email address
even.

c) Cat and touch commands


Cat command allows us to create single or multiple files, view content of a file,
concatenate files and redirect output in terminal or files.
The touch command is a standard command used in UNIX/Linux operating system
which is used to create, change and modify timestamps of a file.

d) Rm and rmdir commands


rm command is used to remove objects such as files, directories, symbolic links and so
on from the file system like UNIX. To be more precise, rm removes references to objects
from the filesystem, where those objects might have had multiple references.
The rmdir command removes the directory, specified by the Directory parameter, from
the system. The directory must be empty before you can remove it, and you must have
write permission in its parent directory.

Q-3 What is the use of bc command? Explain a few functions that are associated with it.

The bc command allows you to specify an input and output base for operations in decimal, octal,
or hexadecimal. The default is decimal. The command also has a scaling provision for decimal
point notation.

5
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

Q-4 Write the command for the following:

a) To show the contents of the file mbacourse.txt along with line numberings

b) To forcibly remove the file mbacourse.txt from the college directory

6
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

c) To display day, month and year in the format 17 Nov 2017

d) To find the square root of the number 17( the result should be displayed up to five place
of decimals.

e) To remove the empty subdirectories, students and teachers, from the college directory.

Prerequisite:-

7
SVKM’s NMIMS
Mukesh Patel School of Technology Management &Engineering Shirpur Campus
Deparment of Computer Engineering
Instructor Manual Lab Manual Academic Year- 2020-21
Year:-Third Subject:- Unix Programming Semester:- Sixth

- Basic knowledge of unix operating system

Outcome:-
After successful completion of this experiment students will be able to know about

1. What is the difference between directory and file?


A directory is a file the solo job of which is to store the file names and the
related information. All the files, whether ordinary, special, or directory, are
contained in directories.
A file is a smallest unit in which the information is stored.
In Unix there is no difference between a file or directory. Everything is a file
in Unix systems.
2. What is character device and block devices?
There are two main types of devices under all Unix systems, character and
block devices. Character devices are those for which no buffering is
performed, and block devices are those which are accessed through a cache.
Block devices must be random access, but character devices are not required
to be

3. What is mounting and unmount file system?


The mount command mounts a storage device or filesystem, making it
accessible and attaching it to an existing directory structure.
The umount command "unmounts" a mounted filesystem, informing the
system to complete any pending read or write operations, and safely
detaching it.

4. What is the functioning of boot block and inode in unix?


A boot block located in the first few sectors of a file system. The boot block
contains the initial bootstrap program used to load the operating system.
An inode is a data structure in UNIX operating systems that contains
important information pertaining to files within a file system. When a file
system is created in UNIX, a set amount of inodes is created, as well.

You might also like