Why do I need sudo? [duplicate]
This is a question from a rookie just trying to understand how and why things work like they do. Why do I have to use sudo everytime? The second use of sudo in a term session doesn't require a password so it knows I have access to root so why can't I just type 'mkdir directory' without sudo?
sudo
is a security measure to allow the Linux system to be more secure by allowing access to the root
account.
In order to prevent users from accidentally (or maliciously) damaging a Linux system, the root
account was created in order to separate and protect some system actions, like raw filesystem access and editing (or even seeing) critical system and service files.
However, just allowing raw access to root
by way of a password is considered unsafe. Therefore, the account is "disabled" and was moved to more of a virtual role wherein it can only be accessed by either the system itself or any user who has sudo powers, as determined by the /etc/sudoers
config file.
Your sudo
"remembering" your password is a convenience feature more than anything. You don't have root, as much as you've had root recently in the past, therefore the system trusts you. You can, of course, decrease this time or disable this feature altogether, but that seems unnecessary.
If you're using sudo
for something very frequently, it may be worth changing permissions and the like to allow you to not use sudo
, but you need to be careful with this. Changing the permissions for the wrong file can completely destroy your system and prevent you from even booting.
sudo is your way of performing tasks with elevated privileges. The same thing applies to most OSs. Windows, for instance pops up the UAC screen to prompt for administrative rights to perform certain tasks. Being truly logged in as a full root level administrator all the time poses a security risk. sudo gives you the ability to temporarily perform administrative level tasks.
Linux Academy - "sudo"