Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Executing the following command on a CentOS 5 box

sudo cp file1  file2

gives me the following error:

Sorry user my_username is not allowed to execute '/bin/cp file1 file2' as root on site_name.com

How can root access not be enough? Any help is appreciated.

share|improve this question
    
Are you on shared hosting? –  Anonymous May 23 '11 at 22:57
5  
sudo is more than just "giving you root access". It has fine grained controls that let you restrict commands the user can run, as you've noticed here. –  Anonymous May 23 '11 at 23:01
    
Sounds like limited sudo permissions in your /etc/sudoers file. If you don't control your sudo configuration you're not going to be able to do anything about this. sudo can be configured to allow only specific commands to be run with escalated privileges, which appears to be the case here... see man sudoers or google "sudo configuration" for more details. –  Anonymous May 23 '11 at 23:04
add comment

migrated from stackoverflow.com May 23 '11 at 23:58

This question came from our site for professional and enthusiast programmers.

3 Answers

How is your sudoers file set up? This command doesn't say that root can't cp, but instead you aren't allowed to use cp AS root.

You should have: my_username ALL=(ALL) ALL in the sudoers file

share|improve this answer
    
Adding the line you've suggested to the sudoers file is overly lenient, and defeats one of the primary purposes of sudo: restricting which commands may be run with the privileges of another user. OP should read and understand man sudoers, and (assuming she/he has control over it) make adjustments wisely. –  Eli Heady May 27 '11 at 20:45
add comment

You might want to try running sudo -l, which will give you a listing of what permissions you have, according to the local sudo configuration. Eg: on my Macbook, I get:

: cez@rhk; sudo -l
Password:
Matching Defaults entries for cez on this host:
    env_reset, env_keep+=BLOCKSIZE, env_keep+="COLORFGBG COLORTERM", env_keep+=__CF_USER_TEXT_ENCODING,
    env_keep+="CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE", env_keep+="LC_MESSAGES LC_MONETARY LC_NUMERIC
    LC_TIME", env_keep+="LINES COLUMNS", env_keep+=LSCOLORS, env_keep+=SSH_AUTH_SOCK, env_keep+=TZ,
    env_keep+="DISPLAY XAUTHORIZATION XAUTHORITY", env_keep+="EDITOR VISUAL"

User cez may run the following commands on this host:
    (ALL) ALL
: cez@rhk; 

The (ALL) ALL part means that my user can run any commands as any user (AFAICS).

share|improve this answer
add comment

sudo does not implicitly give you root access.

I would take a look in /etc/sudoers

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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