0% found this document useful (0 votes)
27 views32 pages

Os Practical File

The document provides information about operating system concepts like listing files, creating directories, checking present working directory, changing directory, creating and reading files, sorting files, counting words, displaying word appearances, displaying calendar, sending messages, counting lines, checking disk usage and free space, and searching files. It includes examples of commands and their outputs.

Uploaded by

Sampurna Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views32 pages

Os Practical File

The document provides information about operating system concepts like listing files, creating directories, checking present working directory, changing directory, creating and reading files, sorting files, counting words, displaying word appearances, displaying calendar, sending messages, counting lines, checking disk usage and free space, and searching files. It includes examples of commands and their outputs.

Uploaded by

Sampurna Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 32

DAV INSTITUTE OF MANAGEMENT

PRACTICAL FILE

OF

OPERATING SYSTEM

BCAMN-205

Submitted to: Dr. Kavita Goel Submitted by:

1
INDEX
S.NO. PARTICULAR DATE REMARKS SIGNATURE
1. To list files in current directory

2. To create a new directory

3. To check present working


directory

4. To change directory

5. To create new file

6. To read content of file

7. To create blank file

8. To sort file

9. To count words in file

10. To display appearance of words

2
11. To display calendar of month and
year

S.no Particulars Date Remarks Signature

12. To send message to all users

13. To count words

14. For disk usage space

15. To check disk free space

16. To search particular pattern file

17. To calculate calculator language

18. To view system reference manuals

3
4
Overview of UNIX

The UNIX Operating System: The UNIX system is mainly composed of three
different parts: the kernel, the file system, and the shell.

[The kernel] is that part of the system which manages the resources of whatever
computer system it lives on, to keep track of the disks, tapes, printers, terminals,
communication lines and any other devices. The file system is the organizing
structure for data.

The file system is perhaps the most important part of the UNIX operating
system. The file system goes beyond being a simple repository for data, and
provides the means of organizing the layout of the data storage in complex ways.

The shell is the command interpreter. Although the shell is just a utility program,
and is not properly a part of the system, it is the part that the user sees. The shell
listens to your terminal and translates your requests into actions on the part of the
kernel and the many utility programs.

History of UNIX

UNIX was initially developed at Bell Labs and became operational on a PDP-7 in
1970. Some of the people involved at Bell Labs had also participated in the time-
sharing work being done at MIT's Project MAC. That project led to the
development of first CTSS and then Multics. Although it is common to say that
the original UNIX was a scaled-down version of Multics, the developers of
UNIX actually claimed to be more influenced by CTSS. Nevertheless, UNIX

5
incorporated many ideas from Multics. Work on UNIX at Bell Labs, and later
elsewhere, produced a series of versions of UNIX. The first notable milestone
was porting the UNIX system from the PDP-7 to the PDP-11. This was the first
hint that UNIX would be an operating system for all computers. The next
important milestone was the rewriting of UNIX in the programming language C.
This was an unheard-of strategy at the time. It was generally felt that something
as complex as an operating system, which must deal with time-critical events,
had to be written exclusively in assembly language. The C implementation
demonstrated the advantages of using a high-level language for most if not all of
the system code. Today, virtually all UNIX implementations are written in C.
These early versions of UNIX were popular within Bell Labs. In 1974, the UNIX
system was described in a technical journal for the first time. This creates great
interest in the system. Licenses for UNIX were provided to commercial
institutions as well as universities. The first widely available version outside Bell
Labs was Version 6, in 1976. The follow-on Version 7, released in 1978, is the
ancestor of most modern UNIX systems. The most important of the non-AT&T
systems to be developed was done at the University of California at Berkeley,
called UNIX BSD (Berkeley Software Distribution), running first on PDP and
then VAX machines. AT&T continued to develop and refine the system. By
1982, Bell Labs had combined several AT&T variants of UNIX into a single
system, marketed commercially as UNIX System III. A number of features was
later added to the operating system to produce UNIX System V.

6
FEATURES OF UNIX
1. Multi-user system—Multi-user capability of UNIX allows several users

to use the same computer to perform their tasks. Several terminals


[Keyboards and Monitors] are connected to a single powerful computer
[UNIX server] and each user can work with their terminals.

2. Multi-tasking system—Multitasking is the capability of the operating

system to perform various task simultaneously, i.e. a user can run multiple
tasks concurrently.

3. Programming Facility—UNIX is highly programmable, the UNIX shell

has all the necessary ingredients like conditional and control structures,
etc.

4. Security—UNIX allows sharing of data; every user must have a single

login name and password. So, accessing another user’s data is impossible
without his permission.

5. Portability—UNIX is portable because it is written in a high level

language. So, UNIX can be run on different computers.

6. Communication—UNIX supports communication between different


terminals of the same server as well as between terminals on different
servers. Apart from these features, UNIX has an extensive Tool kit,
exhaustive system calls and Libraries and enhanced GUI (X Window).

7
UNIX Shell:
A UNIX shell is a command-line interpreter or shell that provides a
traditional Unix-like command line user interface. Users direct the
operation of the computer by entering commands as text for a command
line interpreter to execute, or by creating text scripts of one or more such
commands. Users typically interact with a UNIX shell using a terminal
emulator, however, direct operation via serial hardware connections, or
networking session, are common for server systems. All UNIX shells
provide filename wildcarding, piping, here documents, command
substitution, variables and control structures for condition testing and
iteration.
Description of different types of shell

Bourne shell (sh)


• Original UNIX shell written by Steve Bourne of Bell Labs, which is available on
all UNIX systems.
• Does not have the interactive facilities provided by modern shells. (e.g. C shell
and Korn shell)
• Permits shell scripts to be written and executed.

C shell (csh)
• Provides a C-like language with which to write shell scripts.

8
TC shell (tcsh)
• Available in the public domain.
• Provides all the features of the C shell together with emacs style editing of the
command line. Korn shell (ksh)
• Shell written by David Korn of Bell labs, which is now provided as the standard
shell on UNIX systems.
• It provides all the features of the C and TC shells together with a shell
programming language similar to that of the original Bourne shell.
• It is the most efficient shell.
• use this as your standard interactive shell.

Bourne Again SHell (bash)

• This is a public domain shell written by the Free Software Foundation under their
GNU initiative.
• Widely used within the academic community.
• Provides all the interactive features of the C shell (csh) and the Korn shell (ksh).
• Its programming language for shell scripts is compatible with the Bourne shell
(sh).
• If Bourne shell (sh) is used for shell programming, bash is recommended as a
complete shell environment.

9
10
1). To List files and directory in a system

Syntax: $ Ls

Output

11
2). To Create a new directory

Syntax: $ mkdir Filename

Example: $ mkdir bbacam

Output:

12
3).To know present working directory

Syntax: $ pwd

Output:

13
4).To change the current working directory.
Syntax: $ cd directory name

Example: $ cd bcam1

Output:

14
5).To create a new file

Syntax: $ cat > file name

Example $ cat > naval


Hello
Ctrl +d

Output:

15
6).To read the contents of file.

Syntax: $ cat filename.

Example: $ cat naval.

Output:

16
7).To create a blank file.
Syntax: $ touch filename1, filename2

Example: $ touch naval, naval1.

Output:

17
8). To sort a file

Syntax: sort filename.

Example: sort naval

Output:

18
9).To count words in a file

Syntax: $ wc filename

Example: $ wc naval.

Output

19
10).To display appearance of words

Syntax: $ banner hello

Output:

20
11).To display calendar of a month and year.

Syntax: $ cal 3 1984

Output:

21
12).To send message to all users

Syntax: $ wall message

Example: $ wall hello.

Output :

22
13) To Count number of lines in a file.

Syntax: $ wc –l name

Example: $ wc –l anuj

Output:

23
14) For Disk Usage Space

Syntax: $ du filename

Example: $ du anuj

Output:

24
15) To check disk free space

Syntax: $ df filename

Example: $ df anuj

Output:
25
16) To search particular pattern in file

Syntax: $ grep pP filename

Example: $ grep pP anuj

26
Output:

17) Command to use calculator

Syntax: bc
Input: 2*2
Output:
27
18) To view system reference manuals

Syntax: $ man cd

28
Output:

GREP Command

Grep command in Unix/Linux is a powerful tool that searches for


matching a regular expression against text in a file, multiple files or a

29
stream of input. It searches for the pattern of text that you specify on the
command line and prints output for you.

Options with Grep command are given below:

1. Search for a string “linux” in a file using grep command in unix.

This is the basic usage of grep command. It searches for the given string in the specified file.

grep “linux” index.html

2. Insensitive case search with grep –i

The below grep command searches for the words like “LINUX”, “Linux”, “linux” case
insensitively.

grep -i “linux” index.html

3. Searching for a string in multiple files.

This command will search for "linux" string in multiple files at a time. It searches in all

files with file1.txt, file2.txt and along with different extensions too like file1.html,

file2.php and so on.

grep “linux” file*.*

4. Specifying the search string as a regular expression pattern.

30
It is a very powerful feature and can use as a regular expression with much effectively. In

the below example, it searches for all the pattern that starts with “fast” and ends with

“host” with anything in-between. i.e To search “fast[anything in-between]host” in

index.html file.

grep “fast.*host” index.html

5. Displaying the line numbers.

You can use this grep command to display the line number which contains the matched

string in a file using the -n option

grep -n “word*” file.txt

6. Highlighting the search using grep

If we use the –color option, our successful matches will be highlighted for us.

grep –color “linux” index.html

7. Print the line excluding the pattern using -v option

List all the lines of the file /etc/passwd that does not contain specific word “string”.

grep -v linux /etc/passwd

8. Display all the lines that starts with specified pattern using ^
symbol

31
Bash shell treats carrot symbol (^) as a special character which treat as the beginning of

line. Let’s display the lines which starts with “root” word in the file /etc/passwd.

grep ^root /etc/passwd

9. Display all the lines that ends with specified pattern using $
symbol.

List all the lines of /etc/passwd that ends with “bash” word.

grep bash$ /etc/passwd

10. Search the pattern recursively using -r option

The below command will search linux in the “/etc” directory recursively.

grep -r linux /etc/

11. Counting the lines when words match

This grep command can report the number of times the pattern matches for each file by

using -c (count) option.

grep -c 'test' /home/example/test.txt

32

You might also like