Os Practical File
Os Practical File
PRACTICAL FILE
OF
OPERATING SYSTEM
BCAMN-205
1
INDEX
S.NO. PARTICULAR DATE REMARKS SIGNATURE
1. To list files in current directory
4. To change directory
8. To sort file
2
11. To display calendar of month and
year
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
system to perform various task simultaneously, i.e. a user can run multiple
tasks concurrently.
has all the necessary ingredients like conditional and control structures,
etc.
login name and password. So, accessing another user’s data is impossible
without his permission.
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
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.
• 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
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
Output:
15
6).To read the contents of file.
Output:
16
7).To create a blank file.
Syntax: $ touch filename1, filename2
Output:
17
8). To sort a file
Output:
18
9).To count words in a file
Syntax: $ wc filename
Example: $ wc naval.
Output
19
10).To display appearance of words
Output:
20
11).To display calendar of a month and year.
Output:
21
12).To send message to all users
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
26
Output:
Syntax: bc
Input: 2*2
Output:
27
18) To view system reference manuals
Syntax: $ man cd
28
Output:
GREP Command
29
stream of input. It searches for the pattern of text that you specify on the
command line and prints output for you.
This is the basic usage of grep command. It searches for the given string in the specified file.
The below grep command searches for the words like “LINUX”, “Linux”, “linux” case
insensitively.
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,
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
index.html file.
You can use this grep command to display the line number which contains the matched
If we use the –color option, our successful matches will be highlighted for us.
List all the lines of the file /etc/passwd that does not contain specific word “string”.
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.
9. Display all the lines that ends with specified pattern using $
symbol.
List all the lines of /etc/passwd that ends with “bash” word.
The below command will search linux in the “/etc” directory recursively.
This grep command can report the number of times the pattern matches for each file by
32