Log in to your server as the root user.
ssh root@server_ip_addressUse 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 usernameSet and confirm the new user's password at the prompt. A strong password is highly recommended!
Set password prompts:Follow the prompts to set the new user's information. It is fine to accept the defaults to leave all of this information blank.
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
User information prompts:Use the usermod command to add the user to the sudo group.
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
usermod -aG sudo usernameBy default, on Ubuntu, members of the sudo group have sudo privileges.
Test sudo access on new user account
Use the su command to switch to the new user account.
su - usernameAs 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_runFor example, you can list the contents of the /root directory, which is normally only accessible to the root user.
sudo ls -la /rootThe 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.
Không có nhận xét nào:
Đăng nhận xét