Tuesday, August 25, 2020

UNIX COMMAND & SECURITY SYSTEM PART - 4

 


Security system in Multi user system

First we talk about the security system of file.

Security system of file means no other user are otherwise to access the file of another user.

Let we understand command:

Command : $  ls  -l

Here :

 ls  - same as dir command in dos

-l  - for log listing of file.

Output of Command [ $  ls  -l ]

_rwxr_xr_x  3  amit  staff  411  datetime   a1

drwxr_xr_x  2  amit  staff  411  datetime   a2

---------          ----           ---------        ---------

DETAILS:

MODE OF FILE Such as:

_rwxr_xr_x

drwxr_xr_x 

NUMBER OF LINK Such as:

3

2

OWNER Such as:

amit

amit  

GROUP Such as:

staff  

staff  

SIZE OF FILE Such as:

411

411

COMMAND Such as:

datetime   

datetime   

FILE NAME Such as:

a1

a1


NOTE:

_rwxr_xr_x  3  amit  staff  411  datetime   a1

drwxr_xr_x  2  amit  staff  411  datetime   a2

Here:  _  Means ordinary files

            d  Means directory

            b  Means block read file (Such as: HDD , CDROM , Secondary Device)

            c  Means character read file (Such as: modem , printer etc). These files are also called device driver files. They are available in dev directory.

Suppose:

 


Note: Each file must have their Owner and Group. as above figure show.


SYMBOL                MEANING                                 NUMERICAL VALUE
      _                         No Permission                                           φ
      r                         Only read is Permitted                             4
      w                        Only write is Permitted                            2    
      x                         Only Execution is Permitted                    1                        

Form above it is clear that the numerical value of maximum number of permission is not more than ( 0 + 4 + 2 + 1 ) =7  for any owner , group and others of a file.

Detail information is given in the figure given below 👇


If we have any file than we can do following things such as :


Note: Maximum Possible Permissions are : 7 7 7

Example:

  


NOTE ABOUT GROUP:

Suppose we have three groups:

STAFF             ACCOUNTS                STORE        Group name                

amit                       amit                              raj

ajay                        anil                              raja

raja                        sumit                           ajay

  -                               -                                  -

  -                               -                                  -

Only administrator can create a group.

Only administrator can create user / login and associate to some group.



Friday, August 21, 2020

UNIX SHELL COMMAND & PIPELINING PART 3



In this article we discuss about some basic command of UNIX.These commands are very useful for operating or managing UNIX file system.

 Command 1: $ pg filename

Command is used to display constant page wise 

Example : $ pg +2  ab1

here ,  +2 for display next two pages

            -3 for display previous three pages

             q for quit


 Command 2: $ head  -n filename

 Command is used to display from header

where , n is any integer

Example : $ head -10 abc

Detail      : It will display 10 lines from header (Top)


 Command 3: $ tail  -n filename

 Command is used to display from tail (Bottom)

where , n is any integer

Example : $ tail -10  abc

Detail      : It display 10 line from bottom


 Command 4: $ file  file(s)

 Command is used to show file type.

Example : $ file  *

Detail      : Display all type of files    *|All


 Command 5: $ grep  option  string  file(s)

 Command is used for filter

Example : $ grep  amit  *

Detail      : Search amit in current directory

Example : $ grep  " Shailu"  ab*

                : $ grep  -in   amit   ab2

Detail     : where   -in  -optional [ignore] , amit - string   , ab2 - filename


CONCEPT:

If we want to run more than one command in one statement then we use pipeline concept. In pipeline output of one pipe is input of another pipe. It is represented by ( | ).

 Command 6: $ who | wc -l

Command first display all login / active users than count number of user.

Example:



 Command 7: $ who | grep   amit  |  wc  -l

 Command first display all login / active users than search 'amit' user and than count number of 'amit' user.

Example:




 Command 8: $ who | grep amit  >  aa

 Command first display all login / active users than search user name 'amit' and than save / copy it in 'aa' file.


 Command 9: $ who | grep amit | tee  aa  | wc  -l

 When we apply two operation in same field than we use tee command , like here 'amit' is save in 'aa' and also find number of 'amit ''.



 Command 10: $ file  * .c | wc  -l

Command first search those file name whose extension is ( .c ) and then show how many number of file of ( .c ) extension.


 Command 11: $ ls  -l  *c | wc  -l

 Command is used to show file.


 Command 12: If  we have any file abc and we don't know how many lines in that file and we want to display the constant of line number 26 to 75 than write the command.

$ head  -75 abc | tail -49 abc

 



 Command 13: $ PS

 Command is used to show how many process are running.

Example : command will show output such as

       PID                                   PPID                                           

 (ProcessId)                  Parent ProcessId                Terminal              Command

     3128                                 2456                                 tt02                           sh

     4132                                 4562                                 tt05                           ps

     5235                                 5632                                 tt03                          who

        -                                        -                                       -                                -                              


Note: SYSTEM CALLS
 fork ( )  :  Used to creating a process in memory
 Exet ( )  : Used to terminate any process
 Exec ( )  : Used to execute any process
 wait ( )   : wait

 Command 14: $ kill  -9  processno

This command is used  for forcefully termination.