0

I have created a user in my Centos VPS. But with the new user I can not create, modify files in any folder (for example /var/www/ or /etc/nginx/conf.d/), even though I have added the new user to the wheel group. (My explanation might be wrong since my knowledge of linux is very low.)

How can I configure this user to work as if it were root?

First I created the user

$ useradd mynewuser
$ passwd mynewuser

Then I added root privileges:

$ usermod -G wheel mynewuser  
$ vi /etc/pam.d/su

# Uncommented this line  
auth            required        pam_wheel.so use_uid

$ visudo
mynewuser ALL=(ALL) ALL

1 Answers1

1

You have to use commands su or sudo. Just adding user to group wheel or adding in sudoers is not enough.

The su command switches to the root user – when you execute it with no additional options. You will have to enter the root account’s password. This isn’t all the su command does. You can use it to switch to any user account. If you execute the su john, you will be prompted to enter john’s password and the shell will switch to john’s user account. Once you're done running commands in the root shell, you should type exit to leave the root shell and go back to limited-privileges mode.

sudo runs a single command with root privileges. When you execute sudo command, the system prompts you for your current user account's password before running command as the root user.

More you can find in this answer about difference between su and sudo.

taliezin
  • 9,275
  • Thanks. Just one more question. Does it means that to create a folder I always have to run: "sudo mkdir name"? I'm using Capistrano and some tasks that don't use sudo cause errors. (like "mkdir name") – Ricardo Castañeda May 02 '15 at 05:00
  • Yes, you do if you want it to be created with root permissions. – taliezin May 02 '15 at 07:52