Last update at :2024-01-19,Edit by888u
The Ubuntu system is also a system that many users prefer, so how do we create a new account on the Banwagonhost VPS and grant sudo permissions. This article records how to add or delete a user's sudo permissions on the Ubuntu 20.04 LTS operating system. sudo, short for substitute user do (or superuser do), is a program used in Unix-like operating systems such as BSD, Mac OS X, and GNU/Linux to allow users to run with special privileges in a secure manner Program (usually the system's superuser).
There are many ways to add or remove a user's sudo permissions in a Linux system. This article uses Ubuntu 20.04 as an example, but this should apply to almost all Linux distributions.
Preparation before starting
First of all, you need to connect to the Banwagonhost VPS through SSH. When connecting, we usually use the root account by default and already have sudo permissions. If you are using another account, make sure the account you use has sudo permissions.
Then, we can update the system first (optional):
sudo apt-get update && sudo apt-get upgradeNo matter which method is used below, you need to ensure that the user exists first.
We take the user bandwagonhostnet as an example and create the user first.
After creating the users, use one of the following methods to grant them access to sudo or add them to the sudoers file.
Edit sudoers file directly to modify permissions
The first method, probably also the method that most friends know, is to directly edit the /etc/sudoers file. But usually we do not recommend using this method, because there are too many options in this file, and if we are not familiar with them, it is easy to make mistakes.
Generally speaking, editing the /etc/sudoers file is to grant sudo permissions to a user group, not to grant permissions to individual users. Therefore, it is recommended to give priority to the following two methods to add or remove sudo permissions for a single user.
Modify permissions through usermod command
In order to add sudo permissions to user bandwagonhostnet, we can use the usermod command:
The meaning of this output is that bandwagonhostnet is now a user of the group bandwagonhostnet and sudo, that is, it has sudo permissions.
Use the gpasswd command to modify permissions
In addition to the above commands, we can also use the gpasswd command to give users sudo permissions.
This means that bandwagonhostnet is already a user of the group bandwagonhostnet and sudo, which means that sudo permissions have been successfully granted.
If you need to remove a user's sudo permissions, you can still use the gpasswd command. If bandwagonhostnet abuses access, you can deny permission:
This means that the user bandwagonhostnet is currently only in the group bandwagonhostnet and no longer has sudo permissions.
Recommended discounts/cost-effective packages for bricklayers
Warm reminder: If you have difficulty choosing, just choose the CN2 GIA-E plan in the middle. The quarterly payment is $49.99, and you can switch between up to 12 computer rooms at will.Banwagonhost discount code: BWH3HYATVBJW, discount 6.58%, available everywhere. The table below summarizes more preferential packages for bricklayer removal.
CN2 (cheapest) | 1GB | 1 core | 20GB | 1TB | 1Gbps | DC3 CN2 DC8 ZNET | $49.99/year | Buy |
CN2 | 2GB | 1 core | 40GB | 2TB | 1Gbps | $52.99/half year $99.99/year | Buy | |
CN2 GIA-E (Most recommended) | 1GB | 2 cores | 20GB | 1TB | 2.5Gbps | DC6 CN2 GIA-E DC9 CN2 GIA Japan SoftBank JPOS_1 China Unicom Netherlands EUNL_9 | $49.99/quarter $169.99/year | Buy |
CN2 GIA-E | 2GB | 3 core | 40GB | 2TB | 2.5Gbps | $89.99/quarter $299.99/year | Buy | |
HK | 2GB | 2 cores | 40GB | 0.5TB | 1Gbps | Hong Kong CN2 GIA | $89.99/month $899.99/year | Buy |
HK | 4GB | 4 core | 80GB | 1TB | 1Gbps | $155.99/month $1559.99/year | Buy |
Select a suggestion:
- Getting started: Los Angeles CN2 package, currently the cheapest, optional CN2 GT computer room, the entry-level choice.
- Recommendation: Los Angeles CN2 GIA-E package, affordable, super fast, with many optional computer rooms, and the most cost-effective.
- High-end: Hong Kong CN2 GIA package, the price is higher, but impeccable.
Recommended site searches: cloud server rental, foreign server rental, US vps, external network ip query, registration-free virtual space, space server, Hong Kong's best virtual host, Ministry of Industry and Information Technology website registration, foreign space rental, Wanwang domain name space,
发表评论