Page 211 - DCAP602_NETWORK_OPERATING_SYSTEMS_I
P. 211

Unit 11: User Accounts




          11.1.4 How to Delete users?                                                           notes

          The userdel command is used to remove the user’s record from the /etc/passwd and /etc/
          shadow used in the login process. The command has a single argument, the username.
          [root@bigboy tmp]# userdel paul
          There is also an optional -r switch that additionally removes all the contents of the user’s home
          directory. Use this option with care. The data in a user’s directory can often be important even
          after the person has left your company.

          [root@bigboy tmp]# userdel -r paul
          11.1.5 How to tell the groups to which a user Belongs?

          Use the groups command with the username as the argument.

          [root@bigboy root]# groups paul
          paul : parents
          [root@bigboy root]#

          11.1.6 How to change the ownership of a file?

          You can change the ownership of a file with the chown command. The first argument is the
          desired username and group ownership for the file separated by a colon (:) followed by the
          filename. In the next example we change the ownership of the file named text.txt from being
          owned by user root and group root to being owned by user testuser in the group users:

          [root@bigboy tmp]# ll test.txt
          -rw-r--r--  1 root root 0 Nov 17 22:14 test.txt
          [root@bigboy tmp]# chown testuser:users test.txt
          [root@bigboy tmp]# ll test.txt
          -rw-r--r--  1 testuser users 0 Nov 17 22:14 test.txt
          [root@bigboy tmp]#
               !

             Caution    You can also use the chown command with the -r switch for it to doe recursive
             searches down into directories to change permissions.

          11.1.7 using sudo

          If a server needs to be administered by a number of people it is normally not a good idea for them
          all to use the root account. This is because it becomes difficult to determine exactly who did what,
          when and where if everyone logs in with the same credentials. The sudo utility was designed to
          overcome this difficulty.
          The sudo utility allows users defined in the /etc/sudoers configuration file to have temporary
          access to run commands they would not normally be able to due to file permission restrictions.
          The  commands  can  be  run  as  user  “root”  or  as  any  other  user  defined  in  the  /etc/sudoers
          configuration file. The privileged command you want to run must first begin with the word sudo
          followed by the command’s regular syntax.
          When  running  the  command  with  the  sudo  prefix,  you  will  be  prompted  for  your  regular
          password before it is executed. You may run other privileged commands using sudo within a



                                           LoveLy professionaL university                                   205
   206   207   208   209   210   211   212   213   214   215   216