3

This question already has an answer here:

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?

marked as duplicate by karel, Eric Carvalho, Byte Commander, edwinksl, David Foerster Oct 9 '16 at 8:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    There are some things that would be bad to run as sudo, for instance, making a directory with sudo may make that directory on accessible by the root user. Also, allowing someone to only need to run sudo once, then running every other command in that session as root would likely lead to security risks. – Zalgo Oct 6 '16 at 0:58
  • Sudo is 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 the superuser access. – L. D. James Oct 6 '16 at 1:05
  • sudo has time out set, so that's why first 15 minutes you can type sudo and don't need to put in password again. Sudo in general is necessary for security. Forget Windows - their security model doesn't really provide much security. Unix sudo may seem more annoying but it's more reliable – Sergiy Kolodyazhnyy Oct 6 '16 at 2:38
  • sudo has a long history - it comes from mainframes where they had to use the 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 – SDsolar Aug 14 '17 at 19:02
5

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.

2

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"

Not the answer you're looking for? Browse other questions tagged or ask your own question.