Results 1 to 6 of 6

Thread: Permission Denied when trying to copy my home directory

  1. #1
    Join Date
    Mar 2011
    Location
    South Dakota
    Beans
    1,132
    Distro
    Ubuntu 13.10 Saucy Salamander

    Question Permission Denied when trying to copy my home directory

    Running Ubuntu 10.04

    I logged into (sudo?) (root?) using:

    Code:
     sudo -s
    and then entering my password.

    I navigated into the home folder and viewed the long listing of it's contents using:

    Code:
    root@host:~# cd /home; ls -l
    total 4
    drwxr-xr-x 65 uname uname 4096 2011-05-22 17:14 uname
    I attempted to copy the contents of my home directory named "uname" into a folder on my external usb drive which is located at < /media/Lacie/Backup >

    So I'm in my home directory

    Code:
     above
    and I run:

    Code:
    cp -R uname /media/Lacie/Backup
    And I got the following response:

    Code:
    root@host:/home# cp -R shine /media/Lacie/Backup
    cp: cannot stat `uname/.gvfs': Permission denied
    I was logged in as root. Why would it not allow me to copy the directory?

    Any ideas on what I'm doing wrong here and how I can get this done?

    Thanks in advance

    Last edited by ClientAlive; May 22nd, 2011 at 11:47 PM.
    “ The best method for accelerating a computer is the one that boosts it by 9.8 m/s2. ”
    - Anonymous

  2. #2
    Join Date
    Jan 2009
    Location
    Flanders
    Beans
    Hidden!

    Re: Permission Denied when trying to copy my home directory

    first: copying everything as root will mess up your permissions. You will not be able to put it back in original state. There is some flag you could use with the cp command to keep the owner and permissions, but you should look in the help for it. Anyway, it is better to use a backuptool like Deja-dup.

    second: It is possible for a file to have rights like 000. That means nobody can write it, even not the owner. But, the owner and root can always change the rights. It's an extra layer of security, not against attacks, but against the stupidity of the user. Check out the permissions with

    Code:
    ls -l blablabla/shine.gvfs
    and change it with

    Code:
    chmod a+x blablabla/shine.gvfs

  3. #3
    Join Date
    Mar 2011
    Location
    South Dakota
    Beans
    1,132
    Distro
    Ubuntu 13.10 Saucy Salamander

    Arrow Re: Permission Denied when trying to copy my home directory

    Quote Originally Posted by sanderd17 View Post
    . . . not against attacks, but against the stupidity of the user.

    LMAO

    I think I can relate to that one.


    Quote Originally Posted by sanderd17 View Post
    first: copying everything as root will mess up your permissions. You will not be able to put it back in original state. There is some flag you could use with the cp command to keep the owner and permissions, but you should look in the help for it. Anyway, it is better to use a backuptool like Deja-dup.

    second: It is possible for a file to have rights like 000. That means nobody can write it, even not the owner. But, the owner and root can always change the rights. It's an extra layer of security, not against attacks, but against the stupidity of the user. Check out the permissions with

    Code:
    ls -l blablabla/shine.gvfs
    and change it with

    Code:
    chmod a+x blablabla/shine.gvfs

    Thanks. I'll look into that. Wish me luck.

    “ The best method for accelerating a computer is the one that boosts it by 9.8 m/s2. ”
    - Anonymous

  4. #4
    Join Date
    Mar 2011
    Location
    South Dakota
    Beans
    1,132
    Distro
    Ubuntu 13.10 Saucy Salamander

    Arrow Re: Permission Denied when trying to copy my home directory

    ok.

    So I navigate back into my home directory; and, logged in as root, I run:

    Code:
     cp -Rpiv uname /media/Lacie/Backup
    It copies it over fine; but, after I look at the

    Code:
    ls -la
    in both the original and the copy I see one important different. In the original there is one, single directory named ".." (or "dot dot"), which is owned by root, all the rest are owned by "uname". However, in the copy this is changed to "uname" (both owner and group owner) for that directory. I assume whatever else inside it that was owned by root is also now changed.

    Here is what it says in the man page for the -p option with the cp command:

    -p same as --preserve=mode,ownership,timestamps

    --preserve[=ATTR_LIST]
    preserve the specified attributes (default: mode,ownership,time‐
    stamps), if possible additional attributes: context, links,
    xattr, all

    I would have thought that using that -p option as one of my optoins would have caused the ownerships to stay the same. The only thing I can think of is maybe bash reads these options in a certain order and if I don't list them in the right order they don't get done correctly?

    What's going on with this?
    Last edited by ClientAlive; May 23rd, 2011 at 01:41 AM.
    “ The best method for accelerating a computer is the one that boosts it by 9.8 m/s2. ”
    - Anonymous

  5. #5
    Join Date
    Sep 2010
    Beans
    898

    Re: Permission Denied when trying to copy my home directory

    I normally use the -a (archive) when copying files, whether as root or another user. That preserves permissions and dates.

    Code:
    $ cp -a from-path to-path
    It's normal to get an error when attempting to copy the ~/.gvfs directory. I think it's safe to ignore the error. Or you can use rsync instead of cp, and use the parameter to exclude .gvfs.

  6. #6
    Join Date
    Mar 2011
    Location
    South Dakota
    Beans
    1,132
    Distro
    Ubuntu 13.10 Saucy Salamander

    Arrow Re: Permission Denied when trying to copy my home directory

    Quote Originally Posted by Dave_L View Post
    I normally use the -a (archive) when copying files, whether as root or another user. That preserves permissions and dates.

    Code:
    $ cp -a from-path to-path
    It's normal to get an error when attempting to copy the ~/.gvfs directory. I think it's safe to ignore the error. Or you can use rsync instead of cp, and use the parameter to exclude .gvfs.

    Right on. Just trying to get more comfortable using he command line - doing stuff. I was just reading about rsync. From what I read I thought it was more to do with incremental backups. Maybe I just didn't catch all of what they were talking about. Havta look at it again I guess.

    Thanks
    “ The best method for accelerating a computer is the one that boosts it by 9.8 m/s2. ”
    - Anonymous

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •