Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. # How To Create a Sudo User on Ubuntu
  2. The sudo command provides a mechanism for granting administrator privileges, ordinarily only available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server's sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.
  3.  
  4. Steps to Create a New Sudo User
  5. Log in to your server as the root user.
  6. ```
  7. ssh root@server_ip_address
  8. ```
  9. Use the adduser command to add a new user to your system.
  10.  
  11. Be sure to replace username with the user that you want to create.
  12. ```
  13. adduser username
  14. ```
  15. Set and confirm the new user's password at the prompt. A strong password is highly recommended!
  16. ```
  17. Set password prompts:
  18. Enter new UNIX password:
  19. Retype new UNIX password:
  20. passwd: password updated successfully
  21. ```
  22. Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.
  23. ```
  24. User information prompts:
  25. Changing the user information for username
  26. Enter the new value, or press ENTER for the default
  27. Full Name []:
  28. Room Number []:
  29. Work Phone []:
  30. Home Phone []:
  31. Other []:
  32. Is the information correct? [Y/n]
  33. ```
  34. Use the usermod command to add the user to the sudo group.
  35. ```
  36. usermod -aG sudo username
  37. ```
  38. By default, on Ubuntu, members of the sudo group have sudo privileges.
  39.  
  40. Test sudo access on new user account
  41.  
  42. Use the su command to switch to the new user account.
  43. ```
  44. su - username
  45. ```
  46. As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
  47. ```
  48. sudo command_to_run
  49. ```
  50. For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
  51. ```
  52. sudo ls -la /root
  53. ```
  54. The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed.
  55.  
  56. Output:
  57. [sudo] password for username:
  58. If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement