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?
2 Answers
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.
super doer
... it allows you to run a command as the superuser. This is the needed elevated access to make system-wide changes. Outside the elevated access you can only make local changes to your personal environment, or any common space made available by thesuperuser
access.pseudo
command for a program to invoke a system command as if a user had typed in the command - it was a pseudo user. The original bearded Unix boys picked up the sound of it (sue-doe) and realized it also could be SuperUser DO - so it became sudo, pronounced same as pseudo. It was a very useful joke. But that was many moons ago. Now the n00bs (that is, everybody born too late to remember watching the first moon landing live along with the rest of the world) use it. It is fun to remember the history of these things