3

Suppose that the machine has two users:

  • Alice (admin)
  • Bob (standard user)

While Bob is logged in, how can Alice modify a root file (Bob does not have this permission even with sudo)?

Alice tried:

$ sudo vim /etc/hosts
[sudo] password for Bob: 
Bob is not in the sudoers file.  This incident will be reported.
  • 1
    This is because Bob is not in the /etc/sudoers file. It just means that the administrator (Alice) does not trust Bob for administrative privileges. – Ramesh Mar 26 '14 at 16:40
13

Use su:

su - alice
sudo vim /etc/hosts

From man su:

   The su command is used to become another user during a login session.
   Invoked without a username, su defaults to becoming the superuser. The
   optional argument - may be used to provide an environment similar to
   what the user would expect had the user logged in directly.

For more information, see

man su

and Wikipedia.

  • It works. Can you add please more information about this solution? Thanks! – Ionică Bizău Mar 26 '14 at 16:43
  • 2
    See man su. su allows the user to log in to others' accounts. en.wikipedia.org/wiki/Su_%28Unix%29 – enedil Mar 26 '14 at 17:14
  • 1
    @enedil don't put additional information into a comment - edit you answer instead. – guntbert Mar 26 '14 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.