Linux grant root privileges to user

How to Add a User and Grant Root Privileges on Ubuntu 14.04

It’s just one simple command to add a user. In this case, we’re adding a user called mynewuser:

First you will be prompted to enter the user’s password (twice); do this step. Next you’ll be prompted to enter in the user’s information. This step is not required, and pressing enter fills the field with the default information:

Adding user `mynewuser’ .
Adding new group `mynewuser’ (1001) .
Adding new user `mynewuser’ (1001) with group `mynewuser’ .
Creating home directory `/home/mynewuser’ .
Copying files from `/etc/skel’ .
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for mynewuser
Enter the new value, or press ENTER for the default
Full Name []: User
Room Number []:
Work Phone []:
Home Phone []:
Other []:

When prompted with the following question, enter Y then hit enter to continue.

Is the information correct? [Y/n] Y

Step 2: Grant Root Privileges to the User

# User privilege specification
root ALL=(ALL:ALL) ALL

In this case, we’re granting root privileges to the user mynewuser. Add the following below that code:

Then exit and save the file with the key commands Ctrl-x, Y, enter.

If you’ve followed the instruction above correctly, then you should now have a user setup by the name of mynewuser which can use sudo to run commands as root!

When a standard Cloud VPS is not enough, Liquid Web’s Dedicated Servers are a dream come true. Liquid Web’s server outmatches the competition on performance and support. Check out how our Dedicated Servers can skyrocket your site’s performance.

About the Author: J. Mays

As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you’ll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!

Refer a Friend

Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business

Источник

How to Add a User and Grant Root Privileges on Ubuntu 16.04

Ubuntu 16.04 LTS provides you the ability to add a user for anyone who plans on accessing your server. Creating a user is a basic setup but an important and critical one for your server security. In this tutorial, we will create a user and grant administrative access, known as root, to your trusted user.

How to Add a User and Grant Root Privileges on Ubuntu 16.04

Preflight Check

  1. We will need to open a terminal and log in as the root user.
  2. We will be working as that root user on a Linux Ubuntu 16.04 LTS server

Creating a User with Root Privileges

Create a username for your new user, in my example my new user is Tom:

You’ll then be prompted to enter a password for this user. We recommend using a strong password because malicious bots are programmed to guess simple passwords. If you need a secure password, this third-party password generator can assist with creating one.

~# adduser tom Adding user `tom' . Adding new group `tom' (1002) . Adding new user `tom' (1002) with group `tom' . Creating home directory `/home/tom' . Copying files from `/etc/skel' . Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully

Usernames should be lowercase and avoid special characters. If you receive the error below, alter the username. ~# adduser Tom adduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable. Use the `—force-badname’ option to relax this check or reconfigure NAME_REGEX.

Читайте также:  Http proxy setting in linux

Next, a text prompt will appear asking us to enter in info about your new user. Entering this information is subjective and is not required. This info can be skipped if needed by pressing enter in each field. We suggest adding in as much info as needed to track usage.

Enter the new value or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []:

Lastly, the system will ask you to review the information for accuracy. Enter Y to continue to our next step.

Is the information correct? [Y/n]

Step 2: Grant Root Privileges

Assigning root access to a user is to grant the user the highest privilege on our system so caution is advised. Once out user Tom is added, he can make changes to the entire system as a whole, so it’s critical to only allow this access to users who need it. After this, Tom will be able to execute commands using the sudo option which is normally reserved for the root user.

Step 3: Verify New User

As root, you can switch to your new user with the su — command and then test to see if your new user has root privileges.

If the user has properly been granted root access the command below will show tom in the list.

That’s it! We have added a user and then granted that user root privileges on an Ubuntu 16.04 LTS server.

Get Started Today!

Would you like to learn more about setting up a new Ubuntu server? Give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Experienced Hosting advisors to learn how you can take advantage of these techniques right away!

About the Author: Alison Gray

Alison Gray is currently an IT Project Manager at Liquid Web and has been with Liquid Web for nearly 10 years. In 2015, She earned her Bachelor’s Degree in Media and Information from Michigan State University. In her free time, she loves spending time with her girlfriend and 3 kids. You can usually find her at a basketball court or some sort of sporting event. If the weather’s right, she loves being outside in the yard finding some sort of yard work to do.

Refer a Friend

Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business

Источник

How To Add a User and Grant Root Privileges on Ubuntu 18.04

Adding a user and granting that user root privileges is one of the many tasks of a system admin. Once a user has been added and granted root privileges they’ll be able to login to your Ubuntu VPS and perform vital functions for the upkeep of the system. Afterward, they’ll be able to use sudo before commands to perform elevated tasks. In this quick tutorial, we’ll show you how to add a new user and grant root permissions.

Читайте также:  Windows or linux web server

How To Add a User and Grant Root Privileges on Ubuntu 18.04

Preflight

  • These instructions are intended specifically for adding a user on Ubuntu 18.04 LTS.
  • We’ll be working from a Liquid Web Core Managed Ubuntu 18.04 LTS server, and I’ll be logged in as root.

Step 1: Add the Username

In my example, I’ll be adding my cat’s name, Tom, using the adduser command. Replace tom with your desired username. During this time, the system will also ask of me details from my user. Feel free to skip these details by pressing enter and eventually it asks us to confirm that the info is correct, leading us to a new user added.

Example Output:
Adding user `tom’ .
Adding new group `tom’ (1001) .
Adding new user `tom’ (1001) with group `tom’ .
Creating home directory `/home/tom’ .
Copying files from `/etc/skel’ .
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for tom
Enter the new value, or press ENTER for the default
Full Name []: Tom
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y

Step 2: Grant Root Privileges to the User

The command above leads us to the /etc/sudoers.tmp file, where we can view the following code: # User privilege specification
root ALL=(ALL:ALL) ALL

After the root user line, you will add in your new user with the same format for us to grant admin privileges.

Once you’ve added the permission, save and exit the file by using the following process. (In Ubuntu 18.04, nano is the default editor, so we need to use the ctrl+x, y keystrokes to save and exit the file.)

hold `ctrl` and press `x`. At the prompt, press `y` and then hit `enter` to save and exit the file.

Step 3: Verify User Has Privileges

If you’ve followed the instructions correctly then this user will be able to run commands like, update, using the sudo:

Want to do admin tasks through a control panel? Check out our servers that come with cPanel. We offer assisted migrations and 24/7 support making it effortless to switch to Liquid Web!

About the Author: Justin Palmer

Justin Palmer is a professional application developer with Liquid Web

Refer a Friend

Join our mailing list to receive news, tips, strategies, and inspiration you need to grow your business

Источник

How can I permanently grant root access to a user? [duplicate]

I’ve been searching for the answer to this but all I find is «It’s not a good idea» or «We don’t recommend it» and some work around solution is given. I am a new, yes. There is a good chance I could break stuff, I know. I am happy to break my OS and format it many times if it comes to that but restrictions of ANY kind on my OS enrage me. I want to be able to break stuff if I want, then learn how I broke it and how to fix it. I want the safety locks off. Please tell me how to grant a user absolute authorisation.

6 Answers 6

To give the user «foo» unlimited passwordless access to root privileges via the sudo command, edit /etc/sudoers and add the line:

See sudo(8) and sudoers(5) for more information.

As was suggested elsewhere, if you know how to use vi then it’s a good idea to use visudo to edit /etc/sudoers .

jdthood gave you an excelent tip. read this short article to find out more about the /etc/sudoers tricks :D. linuxg.net/understanding-etcsudoers-file

It is not you who is being restricted (as long as you can sudo or login as root on the command-line), but it is rather every single application you run that is being restricted.

Читайте также:  Linux black screen fix

If you give yourself root privileges, every application you run also gains complete power over your computer. That is the restriction, and saying you don’t want any restrictions placed over you is like saying you do not want to lock your bike or your door, for it places a restriction upon yourself.

I am amazed no one as of yet has tried to offer you that insight.

This is exactly what I was trying to go for with my comment on another answer. The reason for the restriction by the Ubuntu devs is not because they think all users are inept; if that were the case, sudo would be disabled too. It’s about giving the user the power to selectively give applications more privileges. and keeping the «bad ones» (be they buggy or malicious) from messing everything up à la Windows XP.

@IchimitchHamono You have root access? Sudo access? You have unrestricted access then. If that isn’t what you EXPECT it to be, that’s your lack of understanding and inability to learn. I bet money, that just like Android/iOS, you’ll have to «Root» or «Jailbreak» before you’ll get unfettered access on a Steam Box — Linux OR Windows. If typing «sudo», or learning how to edit /etc/sudoers, is too much restriction for you. You won’t enjoy your future. Don’t like it? Build your own OS — or find a Distro that doesn’t have Sudo (or similar) installed.

@IchimitchHamono: by your own admission, you are new to this. That’s completely fine. I even think your question is valid, and interesting. However, your sheer disinterest in finding out why it’s not a good idea to actually do this, finding out why you only find posts saying «we don’t recommend» it, astonishes me.

Linux, and by extension, UNIX, was designed from the get-go as a multi-user operating system, fit for use in networks. Restricting user access is a logical implication of that design. As such, it is deeply embedded in the whole OS and applications that use it. Out of interest, what did you end up doing? Somehow allowing root to log in in a graphical environment?

Being a noob, you should better use visudo instead of editting /etc/sudoers on your own, at least because:

  1. It checks that no one is using the /etc/sudoers file at the same time.
  2. When you have finished, it checks the file for making sure it’s fine.

ok, this comes from my hacker days of trying everything in the system to see what it did.

There is a file /etc/passwd that famously holds passwords (or a marker to signify shadow passwords).

In that file, you will see something like this:

root. 0:0::/:/usr/bin/ksh daemon. 1:1::/etc: bin. 2:2::/bin: sys. 3:3::/usr/sys: adm. 4:4::/var/adm: uucp. 5:5::/usr/lib/uucp: guest. 100:100::/home/guest: nobody. 4294967294:4294967294::/: lpd. 9:4294967294::/: lp:*:11:11::/var/spool/lp:/bin/false invscout:*:200:1::/var/adm/invscout:/usr/bin/ksh nuucp:*:6:5:uucp login user:/var/spool/uucppublic:/usr/sbin/uucp/uucico paul. 201:1::/home/paul:/usr/bin/ksh jdoe:*:202:1:John Doe:/home/jdoe:/usr/bin/ksh 

the two sections that are interest to us are the numbers in position 3 and 4. the first one is the user ID, the second is the group. Notice that in this installation (and most installations) the values for root are both 0

If you use su or sudo to edit this file, and change the numbers on your user ID to be the same as root, then you will become root. (also, you will not be able to use rmuser on your ID, as it is now considered essential to the system)

Источник

Оцените статью
Adblock
detector