So, What Is ‘sudo’ Anyhow?

If you’re a new user, you’ll see commands with sudo in them and you’ve gleaned the meaning of what is sudo. The sudo command is a bit more robust than you may know and this article is going to tell you what sudo is. As I’m not actually sure how to format such an article, I’m going to try to smash it to fit my usual style article. This may make for  a fairly short article.

The sudo command stands for ‘superuser do’ and that’s probably how most folks will know it. That is, after all, correct. You use sudo when you want to execute something that requires different privileges than your account has. Most of the time, that means you want to run the command as an administrator with root privileges. 

But, that’s not all that sudo can do. You can also use it to run software as though you were another user on the same machine. Some folks (erroneously, but not without merit) have taken to referring to sudo as ‘substitute user do’. It suits, but it’s not correct.

To be fair, sudo didn’t have those extra features when it was new (~1980). When it was new, it just let you run commands as a superuser – root – and that was it. Perhaps if it had been named today, with the current feature set, those folks would be correct by calling it ‘substitute user do’. As it stands, those people are technically incorrect.

I’ve also written a couple of other sudo-related articles that may interest the reader.

Create A New User With SUDO Privileges In Ubuntu
How To: Use sudo Without A Password

What Is sudo:

The sudo command typically starts a command, such as an installation command. For example, a command like this:

If you try that command without a privileged account, it’ll fail and you won’t be able to install the software. For security sake, your regular user account should operate under the ‘least privilege principle’, meaning your regular account can’t be used to maliciously operate the system.

The sudo command is that safety gap. To use sudo, you must be a member of the sudoers group/have rights to the command and you must know the password. If you have sudo access, you can cause all the harm you want to a system! So, protect those passwords because they are legitimately the keys to the kingdom.

As we learn what is sudo, we might as well learn a few flags that you can use with it. The most important one, as sudo is plenty powerful by itself, is the -u flag. You use that not when you want to operate as root but when you want to use the privileges of another user on the same system. It looks like this:

When you’ve authenticated as sudo, you will not need to enter your password again for some period of time. The most common period of time is 5 minutes. After five minutes of non-use (idle time with no sudo commands) have passed, you will need to authenticate all over again.

If you want to exit early, you just use the -k flag. That resets everything and you’ll need to authenticate the next time you wish to use sudo. Conversely, if you use the -v flag, it will grant you another five minutes of authenticated time, allowing you to extend your sudo session.

There are a few other flags, but those aren’t really used often. Though, if you’re going to enter a lot of commands, you can use sudo -s and open a new shell where you have sudo privileges. That’s useful if you’re going to use a number of commands and don’t want them in your terminal scroll-back.

Closure:

There you have it, you can now answer the question: what is sudo? It’s a handy tool to have and there are uses most people probably never bothered learning. It’s there if you need it and you might as well be familiar with it.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Smash a button!
[Total: 4 Average: 5]

Create A New User With SUDO Privileges In Ubuntu

It’s not unusual to want to create a new user with sudo privileges and it’s actually really easy. This will be just a quick article that explains how. It’s not exactly a complex operation.

This article doesn’t cover other distros! It has only been tested in a couple of Ubuntu derivatives and not all distros come with ‘adduser’. It should probably work if you install ‘adduser’ where available, but that’s entirely untested by me. Give it a shot and let me know in a comment if it works out for you.

You may want a multi-user environment, you may want different logs for different users, you may want some customization with one user, you might want to test things with a separate user, etc… There are tons of reasons for wanting a different account and wanting a new user with sudo privileges.

I shouldn’t need to mention this, but sudo stands for ‘superuser do’. Users that belong to the sudo group are pretty much omnipotent. They can access anything, change anything, and do anything they please. You’ll use sudo to do things like install software or edit system files.

Anyhow, I’ll explain how to create a new user with sudo privileges in this article. It’s a pretty easy task and you shouldn’t have much trouble with this one.

Create New User With SUDO Privileges:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The tool we’ll be starting with is called ‘adduser‘, and the name tells you what it does. With your terminal now open, you start by entering the following to add a new user:

Once you’ve done that, you’ll be asked to type the new user’s password twice, and then you can fill in some additional information for that user. Those steps aren’t necessary, but you will want to add a password for the user – and definitely so because it’s an account that has access to sudo.

Now that you have created a new user, you’ll need to modify that user. The newly created user doesn’t come with sudo access by default, you need to grant it. The tool we’ll be using for this is ‘usermod‘ and the command to make the new account a new user with sudo privileges is:

At this point, you should be able to login and use the newly minted user account. Indeed, you should have a new user account and that new account should have sudo privileges.

CLOSURE:

See? I told you that this wouldn’t be a long or difficult article. If you want a new account and you want that account to have sudo privileges, it’s just a couple of easy commands away. This is yet another article in what’s turning out to be quite a long list of articles.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Smash a button!
[Total: 4 Average: 5]

How To: Use sudo Without A Password

It is possible to use sudo without a password. Doing so is probably a pretty bad idea for most people, but it can be done. Password-less sudo is an option that you have, but it’s one heck of a security risk.

I have pretty good physical security and the risks of someone physically accessing my devices are pretty minimal. There’s no neighbors that can access my WiFi, or anything like that. Because of this, I can, and sometimes do, set up my computers so that I don’t need to use a password when I use sudo.

I feel like I need to make this clear:

If you set it up to use sudo without a password, you’re removing a key security element. If you can use sudo without a password, so can’t someone who’d be doing so with malice aforethought. It’d be even more risky if you did this on a laptop that might get misplaced or stolen.

In short: DO NOT DO THIS (without considering the security implications).

By the way, if you don’t know what sudo is, it stands for “superuser do”. It’s what you use to temporarily elevate your permissions, to read, write, or execute administrative (or otherwise restricted) files. Basically, it turns you into an omnipotent administrator. 

Again, be careful before doing this. If it makes you an omnipotent user, it makes anyone that can access the device an omnipotent user. You have been warned. If you’re comfortable with your physical security, this is an option. It’s an option you should consider only with care and diligence. 

SUDO Without A Password:

     See Also: Generate Complex Passwords

Like so many things, this too starts in the terminal. As always, you can open your terminal with your keyboard, just press CTRL + ALT + T and your default terminal should open. Once it is open, enter the following to open the file with nano:

Arrow button yourself down to the bottom and add the following line:

Where it says “<your_username>” you change it to your username – without the brackets. So, if your username were the same as mine, you’d make a line that looks like:

The ‘kgiii’ is lowercase, and your username will be lowercase. If, for some reason, you don’t actually know your username, you can find it with:

Anyhow, after you’ve added that line, you can save the file. As we’re using nano, you save it by pressing CTRL + X, then Y, and then ENTER

That should get you sorted and you should now be able to use sudo without a password. If you are aware of the security implications, this may just be something you want to do. On the other hand, it’s not exactly taxing to type your password.

Closure:

And, once again, you have another article! I’ve reached the point where I have a small buffer. I could be offline for a few days and articles will still publish themselves. I’m hoping to get even further ahead, so we shall see how it goes.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Smash a button!
[Total: 4 Average: 5]
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.
Zoom to top!