You are viewing an old revision of this post, from January 4, 2018 @ 16:36:03. 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:36:03Current 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: <div data-unique=" steps-to-create-a-new-sudo- user"></div> 
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: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">ssh root@<span class="highlight" >server_ip_address</span></li>Added: <strong>ssh root@server_ip_ address</strong>
Deleted: </ul> 
Deleted: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: </li> 
Deleted: <li>Use the <code>adduser< /code> command to add a new user to your system. Added: Use the adduser command to add a new user to your system.
Deleted: Be sure to replace <span class="highlight" >username</span> with the user that you want to create. Added: Be sure to replace username with the user that you want to create.
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">adduser <span class="highlight" >username</span></li> 
Deleted: </ul> 
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: <ul> 
 Added: adduser<strong> username
 Added: </strong>
Deleted: <li>Use the <code>passwd< /code> command to update the new user's password. Added: Use the passwd command to update the new user's password.
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">passwd <span class="highlight" >username</span></li> 
Deleted: </ul> 
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: </li> 
 Added: passwd<strong> username</strong>
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: <pre class="code-pre "><code></code></pre> 
Deleted: <div class="secondary-code-label " title="Set password prompts:">Set password prompts:</div> 
 Added: Use the usermod command to add the user to the wheel group.
Deleted: <pre class="code-pre "><code>Changing password for user username.Added: usermod<strong> -aG wheel username</strong>
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. 
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">usermod -aG wheel <span class="highlight" >username</span></li> 
Deleted: </ul> 
Deleted: <pre class="code-pre super_user">< code></code></pre> 
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: <pre class="code-pre super_user">< code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">su - <span class="highlight" >username</span></li> 
Deleted: </ul> 
Deleted: <pre class="code-pre super_user">< code></code></pre> 
Deleted: </li> 
 Added: su<strong> - username</strong>
Deleted: <li>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: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">sudo <span class="highlight" >command_to_run</span></li>Added: sudo<strong> command_to_run</strong>
Deleted: </ul> 
Deleted: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: </li> 
Deleted: <li>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: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: <ul class="prefixed"> 
Deleted: <li class="line">sudo ls -la /root</li> Added: sudo<strong> ls -la /root</strong>
Deleted: </ul> 
Deleted: <pre class="code-pre custom_prefix" ><code></code></pre> 
Deleted: </li> 
Deleted: <li>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.
Deleted: <pre class="code-pre "><code></code></pre> 
Deleted: <div class="secondary-code-label " title="Output: ">Output:</div> 
 Added: 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> 
Deleted: <div data-unique=" related-tutorials"></div> 

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