Disk Management In Operating System

Image
 Disk Management  Disk is a secondary storage device that is used to store data.  The external devices such as hard disk, magnetic disks and floppy disks stores data in the sectors.  These devices provide the data to user programs by means of I/O requests.  Disk Management is an important function of operating system and includes disk buffering and management of swap area and disk cache.  Disk Structure  Disks provide a means to store a large amount of information for modern computer.  A disk is usually divided into tracks, cylinder and sectors.  Below fig shows the various components of a disk system.  Data is stored on a series of magnetic disks called platters. These disks are connected by a common spindle that spins at very high speed (some spindle rotate at speeds of 3600 revolutions per minute).  The two surfaces of a platter are covered with a magnetic material similar to that on a magnetic tape. Information is recorded mag...

Filters in Linux Operating System

 FILTERS 

A filter is a program that reads data from the output of another program or the standard input, processes it in some way, and sends the processed data to standard output or to another program. 



There are many filters that are available in linux. 

'wc' Command 

'wc' stands for 'word count'. The 'wc' command counts the 'lines' , 'words' and 'characters' in a specified file. 

Syntax : wc [options]  [filename] 
[user1 @linux-mac user1] $ wc names 
   1          5          22            names 

Option                  Purpose 
          
-c          Prints only the character count 

-w         Prints only the word count 

 -l           Prints only the line count 

'sort' Command 

The sort command arranges the output alphabetically. 

Syntax : sort [options]  [filename] 

For example : Create a file called 'names' with the following names : 

Shaffi 

Candy 

Ritu 

Anubhav 

      [user1 @linux-mac user1] $ sort names 

The output is : 

Anubhav 

Candy 

Ritu 

Shaffi 

'sort is a very powerful command having many options. 

'tail' Command 

The 'tail' command prints the last 'n' lines of a specified file. 

Syntax : tail [no. of lines]  [filename] 

[user1 @linux-mac user1] $ tail - 2 names 

Ritu 

Anubhav 

The 'head' command is similar to the 'tail' command. It prints the first 'n' lines of the file. 

'finger' Command 

Syntax : finger [options] [user] 

Linux is a multi - user system. That means more than one person can be logged in at any given time. 

The finger command provides a lot of information about the users. 

[user1 @linux-mac user1] $ finger 

'find' Command 

'Find' command search for the files or directories that match a given pattern. 

Syntax : find [path] [expression] 

[user1 @linux-mac user1] $ find/home/john-name "l*" 
This will show all the fields and directories starting with name L 

'diff' Command 

The 'diff' command is used to find the difference between two files. This command displays the lines which are different. 

Syntax : diff [first file name] [second file name] 

For example : there are 2 files - test and exam. 
 
Test contain         "This is my test file" 

Exam contain      "This is my exam file" 
 
    [user1 @linux-mac user1] $ diff test exam 
   
Output : 

1c1 

<This is my test file 

-------

>This is my exam file 

'comm' Command 

Syntax : comm. [first filename] [second filename] 

This command compares two files 

E.G. First file name temp1 contains 

A

B

C

D

Second file temp2 contain 

A

B

X

Y

                    [user1 @linux-mac user1] $ comm temp1 temp2 

Output : 

                           A

                           B

C

D

                 X

                 Y

The 'comm' is the file comparison program which expects 2 file name as an input. It process the files received as input and display 3 column output. The 1st column gives the lines that are unique in the 1st file The 2nd column gives the lines that are unique in the 2nd file. 

The 3rd column gives all lines that are common to all the files. 

The 'TR' Command 

This command is used to transfer or remove consecutive repeating characters from the characters in the input received by it. 

Syntax : tr [options] [character to be looked for] [character to be translated into] 

         [user1 @linux-mac user1] $ tr a-z A-Z 

hello 

HELLO 

'Cut' Command 

The cut command is a filter that is used to vertically cut across columns to extract entire columns or specific number of characters. 

Syntax : CUT[OPTIONS] [FILENAME] 

[user1 @linux_max user1]$ cat>>data 

charles 24 3243 

carlton 22 442 

tony 26 333 

[user1 @linux_max user1]$ cut -d " " - f1,3<data  

charles 3243 

carlton 442 

tony 333 

        [user1@linux_max user1]$

At the command prompt type the following ;

         [user1 @linux_max user1]$ cut-3]<data 

your screen would look like this ;

         [user1 @linux_max user1]$ cut-3]<data 

cha

car

ton

[user1 @linux_max user1]$

In above fig delimiter '' space has been specified and the first three character are selected from the file. 

'Paste' Command : 

The paste command works as the inverse of cut command. It is used to merge lines of files. 

Syntax : PASTE[OPTIONS] [FILENAME] 

For example : create a file named data : 

[user1 @linux_max user1]$cat>>data 

charles 

carlton 

tony 

Now create a file named data1 : 

cha

car

ton

AT THE COMMAND PROMPT TYPE THE FOLLOWING : 

[user1 @linux_max user1]$cat data 

charles 

carlton 

tony 

[user1 @linux_max user1]$cat data 

cha 

car

ton 

[user1 @linux_max user1]$ paste -d: data data1 

charles:char

carlton:car

tony:ton

[user1 @linux_max user1]$

Using 'Pipes' : 

Often we use output of one program as an input to another.we do so by using redirection operators >>. 

Another and better method of performing the same is by a mechanism called 'pipes'. Pipe connects output of program to input of another program this concept is that of pipeline that connects two water tanks. 

AT THE COMMAND PROMPT TYPE THE FOLLOWING :

[user1 @linux_max user1]$ 1s/more 

The more command is a filter for paging through next one screen at a time. I he output of 1s is piped to more the more program ensures that we get the output one page at a time. 

https://youtube.com/channel/UCLZqVRZUkuXIlST8BteqTig

This is the link of my YouTube please visit at this link and if you like it don't forget to like, share and subscribe the channel.

Comments

  1. Your content is good but intent writing is not understandable so please improve this and I am from Quora

    ReplyDelete

Post a Comment

Popular posts from this blog

Disk Management In Operating System

Text Editor in Linux Operating System

You must know about Adventure sports