For many of us, the days following the fresh install of a new Linux distribution are like starting your life over. It's a time for new beginning – new choices for programs, new configurations, new icons. You have a clean slate, and it's time to explore the possibilities the unknown distro brings with it.
Naturally, you jump on your computer, open up a terminal window, and start throwing out sudo apt-get install commands left and right to play with new applications. But wait: Error messages start flying back saying that you profile is not included as a sudoer.
Well, not exactly. If the first time you attempt to operate as root on a recently installed system and the system spouts back something about your profile not having sufficient privileges to carry out the task, it means that you properly installed the distro.
The fact is that you (probably) do not want to be operating as supervisor all the time. It can be dangerous, and far too often it leads to system meltdowns at the worst possible times. While not having to insert a password before any administrative task can be helpful a lot of the time, using root as a primary account leaves your computer exposed to user stupidity – and plain dumb mistakes happen to the best of us.
Ok, so you don't want to be root all the time, but you obviously need to be able to carry out administrative tasks from time to time – like when you want to do something as simple as installing a new program. So how do you add your profile to the sudoer file?
It's actually very easy. First, open up a terminal window (probably the one that yelled at you for having insufficient privileges in the first place). For this tutorial let's pretend your username is alpha, so every time you see alpha substitute in your general user profile. Go ahead and type is “su” on the first line and hit enter. You will be prompted for your password – go ahead and supply it.
Next, you need to give yourself permission to edit the sudoers file. Type
Then click enter again. Now you can go in and add yourself to the list. Type
And then go ahead and click enter again. Congratulations, you're now on the list. Before we leave, we want to reset the permissions of the sudoer file by typing
chmod -w /etc/sudoers
Click enter again, type “exit”, press enter again, and then type “exit” one more time to leave the terminal window. And that's it! Your profile has now been added to the list of those with administrative privileges.
While it is not a difficult procedure, it is one that is easily forgotten. Once you have given yourself sudo privileges you can give them to other Linux users as well, whether you have multiple profiles set up for other users on your computer or even different profiles for different tasks.
Edit: A number of people have responded to this post raising very justified concerns about configuring sudo in this manner. While it is perfectly safe if you are careful about every change you make, a mistake in configuring sudo can lead to bad problems down the line. As a safeguard, many people prefer editing the sudo file through the visudo command, which, if sudo has not yet been configured, must be accessed when logged in as root. To do so, login as root, open a terminal and type:
At the bottom of the new series of characters is a line that reads:
To enable a user full access to sudo, simply type:
Press Ctrl+X to exit the program and click Y to save a backup buffer file on your way out just in case things go wrong.
Two ways to address the same problem – This method simply provides a failsafe.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.