You are viewing an old revision of this post, from January 4, 2018 @ 16:40:10. See below for differences between this version and the current revision.

Centos – Create a Sudo User

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 CentOS, without having to modify your server's sudoers file. If you want to configure sudo for an existing user, simply skip to step 3. Steps to Create a New Sudo User Log in to your server as the root user. ssh root@server_ip_address Use the adduser command to add a new user to your system. Be sure to replace username with the user that you want to create. adduser username Use the passwd command to update the new user's password. passwd username Set and confirm the new user's password at the prompt. A strong password is highly recommended! Use the usermod command to add the user to the wheel group. usermod -aG wheel username By default, on CentOS, members of the wheel group have sudo privileges. Test sudo access on new user account Use the su command to switch to the new user account. su - username As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges. sudo command_to_run For example, you can list the contents of the /root directory, which is normally only accessible to the root user. sudo ls -la /root 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. Output: [sudo] password for username: 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.

Revisions

Revision Differences

January 4, 2018 @ 16:40:10Current Revision
Content
Deleted: The <code>sudo< /code> 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 CentOS, without having to modify your server's <code> sudoers</code> file. If you want to configure sudo for an existing user, simply skip to step 3. Added: 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 CentOS, without having to modify your server's sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.
Deleted: <h2 id="steps-to- create-a-new- sudo-user">Steps to Create a New Sudo User</h2> 
Deleted: <ol> 
 Added: Steps to Create a New Sudo User
Deleted: <li>Log in to your server as the <code>root< /code> user. Added: Log in to your server as the root user.
Deleted: ssh root@<span class="highlight" >server_ip_address</span></li>Added: <strong>ssh root@server_ip_ address</strong>
Deleted: <li>Use the <code>adduser< /code> command to add a new user to your system.Be sure to replace <span class="highlight" >username</span> with the user that you want to create 
 Added: Use the adduser command to add a new user to your system.
 Added: Be sure to replace username with the user that you want to create.
 Added: adduser<strong> username
 Added: </strong>
 Added: Use the passwd command to update the new user's password.
Deleted: adduser <span class="highlight" >username</span>Added: passwd<strong> username</strong>
Deleted: Use the <code>passwd< /code> command to update the new user's password.passwd <span class="highlight" >username</span></li> 
Deleted: <li>&nbsp; 
Deleted: <ul> 
Deleted: <li>Set and confirm the new user's password at the prompt. A strong password is highly recommended! Added: Set and confirm the new user's password at the prompt. A strong password is highly recommended!
Deleted: Set password prompts: 
Deleted: <pre class="code-pre "><code>Changing password for user username. 
Deleted: New password: 
Deleted: Retype new password: 
Deleted: passwd: all authentication tokens updated successfully. 
Deleted: </code></pre> 
Deleted: </li> 
Deleted: </ul> 
Deleted: </li> 
Deleted: <li>Use the <code>usermod< /code> command to add the user to the <code>wheel< /code> group. Added: Use the usermod command to add the user to the wheel group.
Deleted: usermod -aG wheel <span class="highlight" >username</span> Added: usermod<strong> -aG wheel username</strong>
Deleted: By default, on CentOS, members of the <code>wheel< /code> group have sudo privileges.</li> Added: By default, on CentOS, members of the wheel group have sudo privileges.
Deleted: <li>Test sudo access on new user account Added: Test sudo access on new user account
Deleted: <ul> 
Deleted: <li>Use the <code>su< /code> command to switch to the new user account. Added: Use the su command to switch to the new user account.
Deleted: su - <span class="highlight">username 
 Added: su<strong> - username</strong>
Deleted: </span>As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges. Added: As the new user, verify that you can use sudo by prepending "sudo" to the command that you want to run with superuser privileges.
Deleted: sudo <span class="highlight" >command_to_runAdded: sudo<strong> command_to_run</strong>
Deleted: </span><code></code>For example, you can list the contents of the <code>/root< /code> directory, which is normally only accessible to the root user. Added: For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
Deleted: sudo ls -la /root 
 Added: sudo<strong> ls -la /root</strong>
Deleted: <code></code>The first time you use <code>sudo</code> in a session, you will be prompted for the password of the user account. Enter the password to proceed. Added: 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.
Unchanged: Output:Unchanged: Output:
Deleted: <pre class="code-pre "><code>[sudo] password for username: Added: [sudo] password for username:
Deleted: </code></pre> 
Deleted: 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.</li> Added: 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.
Deleted: </ul> 
Deleted: </li> 
Deleted: </ol> 

Note: Spaces may be added to comparison text to allow better line wrapping.

2 Responses to “Centos – Create a Sudo User”

  1. Deloras Kukauskas 04/03/2018 at 10:06 am #

    Hello! Would you mind if I share your blog with my zynga group? There’s a lot of people that I think would really enjoy your content. Please let me know. Thanks

Leave a Reply