If a permission is denied, I can do sudo and get my stuff working in linux. Then what was the use of such access controls if anyone can override them?
问题:
回答1:
Firstly sudo
does not come by default with all distributions. Debian, which Ubuntu and Mint and a ton of other popular distros are based on, does not install sudo
out the box.
As you noticed sudo
elevates your user rights to super user level, but you need to be in sudoers file. Ubuntu adds the account you create during setup by default to the sudoers file. Debian on the other hand, you have to install sudo and configure it yourself.
Another point is that sudo
adds traceability in the system. If you have a bunch of users who should all have super user privileges, rather than giving everyone the root password you add them to the sudoers file, then when somebody changes something that required super user rights you will know who it was.
回答2:
Only people in /etc/sudoers can use sudo, and ideally very very few people (like, one) should have such access in a shard system.
回答3:
As @Leon and @Ben said, you will not have sudo executing permission by default in many distributions. Mostly, system administrator will need to configure user permission depending on their role.
When it comes to personal computer, many distribution let set up for you by default. For example, Ubuntu.
In Fedora, Mint, Debian and many distribution, you will have to configure sudoer file by executing the following command with root permission.
visudo
In sudoer file, you will have to clearly define what permissions would you need. The format is
<username> <username that the rule will apply to>:(<rule applies to which hosts>:<run commands as which user>) <run commands as all groups>