Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

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

Are you on shared hosting? – Anonymous May 23 '11 at 22:57
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

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
not only lenient, but dangerous, and very bad practice. as Eli Heady states, the answer is "man sudoers" – nandoP Jun 3 '14 at 14:55

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
Matching Defaults entries for cez on this host:
    env_reset, env_keep+=BLOCKSIZE, env_keep+="COLORFGBG COLORTERM", env_keep+=__CF_USER_TEXT_ENCODING,
    LC_TIME", env_keep+="LINES COLUMNS", env_keep+=LSCOLORS, env_keep+=SSH_AUTH_SOCK, env_keep+=TZ,

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

sudo does not implicitly give you root access.

I would take a look in /etc/sudoers

share|improve this answer

Your Answer


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.