Friday, July 31, 2020

UNIX SHELL COMMAND - PART 2



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: $ data

Command display date / time  (only admin can change this time / date)



Command 2:  $ cal  month  year

Note: Month will be (1 - 12)  | Year will be (1 - 9999)

Example: 
                $ cal  1998        Display calendar of 1998       
                $ cal  9 2005     Display calendar of September 2005    
                $ cal  1752        Basic Year / Starting Year
                $ cal  9 1752     Basic Year / Starting Year   


Command 3: $ cat > filename

Used to create a new file

Example:

               $ cat  > a1    File is created named a1.




Command 4: $ cat filename

Display content of file

Example:

               $ cat a1    Display content of file a1



Command 5: $ sort  -r  filename

Used for sorting ,  -r show reverse order sorting

Example:

             $ sort  -r  a1         (sort   by Z to A)  Descending order

             $ sort a1               (sort by A to Z)   Ascending order



Command 6: $ sort a1 > a1

Output of a1 redirect to a1 file



Command 7: $ cat a1

Display content of a1 file



Command 8: $ cat a1  a2

Display content of a1 file  & a2 file



Command 9: $ cat a1  >  a2

Used to copy a1 file to a2 file    i.e. (a1=a2)



Command 10: $ cat a1  a2 >  a3

Used to copy a1 and a2 into a3 file   i.e (a3 = a1 + a2)



Command 11: $ cat a1 , a2 >> a3

Used to append content of a3 file  i.e (a3 = a1 + a2 + a3)

Example:

                $ cat a2 , a1 >> a3

                $ cat a1 , a2 >> a2

                $ cat a1 >> a2



Command 12: $ man command name

Used to show online help

Example: 

                $ man who



Command 13: $ mkdir

Used for creating new directory.


Note : Unix use round robin algorithm for scheduling it is also known as time sharing.

Example : 

 If there are three process


In the above diagram first time slice is provide to a than b and than c this is also known as context switching.In this mechanism scheduler is any software who schedule the process. These scheduling process come in priority queue.

Note : Let we understand about directory in UNIX


Above represent the simple directory tree which represent root from root to current user.It is an pictorial representation. It is like  ( . /. . / jay / T3)
Here ,
             ( . ) means       / user / jay    (current directory)
             ( . . ) means     / user             (Parent directory)
Note: Parent of root directory is root. By default , we always start with current directory


Command 14: $ cd  directory name

Used for changing directory.

Example:

                $ cd T3

                $ cd . / T3

                $ cd  / user / jay / T3

                $ cd . . / . . / user / jay / T3

                $ cd . / jay / T3

                $ cd . . / user / jay / T3

                $ cd . . /. . /. . / user / jay / T3

                $ cd  . / . . / jay / T3

Note : All above commands are same regarding changing directory.



Command 15: $ cp  Source file    Target file

Used for copy any file from source directory to destination directory.

Example:

               $ cp     / user / jay / T1      / user / jay / T3 / m   [OR]    $ cp    . . / T1     . / m

         



Command 16: $ mv  Source file    Target file

Used for move or rename file source to target.

Example:

               $ mv     / user / jay / T1      / user / jay / T3 / m   [OR]    $ mv    . . / T1     . / T3 / m



Command 17: $ rmdir  Directory Name

Used for removing directory.

Example:

                $ rmdir T3


Command 17: $ rm  file(s)

Used for removing files.

Example: 

               $ rm  m        (It will remove m from jay directory by searching)

Note :

             $ rm *  ( For matching with all )

             $ rm * . *  ( For removing all files )



Command 18: $ rm  -i   ab*

ab* means file name start with ab and end with any.

-i  If we write -i than it will ask (are you sure [Y , N])


Command 19: $ rm  -r   Directory Name

-r is used for deleting directory

Example:

            $ rm -r T3    This command will delete whole tree of T3.





Command 20: $ wc  -lwc   File Name

Used for forward counting

l -   Line

w - Word

c -  Char

Example:

                $ wc -lwc ab1             Output like : 5  6  52   ( line=5, word=6, char=52)

                $ wc  -l  ab1                Output like : 5    ( line=5)

                $ wc  -wl  ab1             Output like : 6  5  ( word=6, line=5)















Wednesday, July 22, 2020

LOGICAL FILE SYSTEM IN UNIX




The above diagram show the hierarchy of logical file system of Unix operating system. There are so many directory in file system ( / ) show the root directory and user , etc , bin , dev , mnt are directories. We know directory is a collection of file. Here each directory is used for some specified work such as:

USRE : This directory maintain user identification. Number of user show in this directory. such as U1 U2 , BIN etc.

ETC : This directory maintain / store system admin related utilities or files.

BIN : This directory maintain general commands.

DEV : This directory maintain / store device drivers.

MNT : This directory is used for mounting means user mount other temporary file system such as CD-ROM ,DVD ,FLOPPY DISKETTE DRIVE etc.

Note : When user is created the admin allocate one directory and user work on that directory.


Saturday, July 18, 2020

KNOW HOW TO LOGIN USER IN UNIX




UNIX is a multi user Operating System.

Here we will talk about shell programming, through which we can run many commands. For this, first we have to login through login and password.

Example :

Login : shailu
Password : ******

After login sh program will run and we get $ (dollar). If we want to logout then we press (ctrl + d). After successful logout again we get

Login : 
Password : 

Note : No of shall = No of current login user ( That means the more users login, the more shall be given. )

Command 1 : $ who

who command tells how many users are currently logged in.

OUTPUT : This command will display suppose.


Name of user           Name of terminal
       raj                               tty05
       raja                             tty07
       raj                               tty10
       anil                             tty11

Note : 

If one user login in different system in different time period then the shell provided is different.