Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

Copying file from other user's directory with '-p' switch should reserve the permission as per the man page.

I am copying /etc/passwd to my home directory with -p switch but the permissions aren't preserved as follows:-

ijoin@stream:~$ ls -l /etc/passwd
-rw-r--r-- 1 root root 1813 Sep 25 08:58 /etc/passwd
ijoin@stream:~$ cp --preserve /etc/passwd .
ijoin@stream:~$ ls -l passwd 
-rw-r--r-- 1 ijoin ijoin 1813 Sep 25 08:58 passwd

I am doing something wrong?

share|improve this question
up vote 4 down vote accepted

You're logged in as ijohn and copying a file owned by root. cp command can not work around Linux's security machinery - your user is not allowed to create files owned by root or change ownersip of files to root. Doing so would be a security problem.

If you need to copy files owned by other users, do so using sudo:

sudo cp --preserve /etc/passwd

Here's a good explanation I found on

the -p argument works for all users in the constraint of that users abilities on the system. generally non-root users will be able to preserve ownership of their files that they own and are owned by a group that the specific non-root user belongs to. they cannot preserve ownership of files owned by other users (albeit, there may be ways around this depending on the suid, guid, and sticky bits). root can preserve the ownership of files owned by different users, because root has full system priveledges. but joe_schmoe can not preserve the ownership of files owned by root or files owned by billy, etc. depending on where the file will be copied to, joe_schmoe can only preserve file ownership of files owned by joe_schmoe and owned by a group joe_schmoe belongs to.

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.