2

I am trying to save my files on my Hard Drive that has a crashed OS. I created a Bootable USB with Ubuntu and successfully booted.

I can see my folders, but I can't actually open them because I don't have permission.

I tried to do this:

sudo chmod 777 -R Pictures

Where Pictures is the name of the folder I want to change permissions to.

All I want to be able to do is to copy the folders & files from my Hard Drive to my USB drive.

How do I do that?

  • did you use the entire path to the folder? (/media//home//Pictures)? Also, I usually put -R before the permission numbers. – mchid Dec 18 '14 at 21:28
  • @mchid Yep I did. Also, the recursive portion of the command works (i.e. something happens on all the files in the folder). The issue is that the permissions don't seem to be changed after the operation has finished. – marcamillion Dec 18 '14 at 21:47

3 Answers3

1

Running from a live DVD, if you cannot cd into the folder because of "permission denied" you can use the following command to login as root:

sudo su

Logging in as root is not typically recommended and should only be done as a last resort and not just to be lazy! You can use the following command to log out of root:

exit
mchid
  • 43,546
  • 8
  • 97
  • 150
  • I tried both of these, and when I try to CD into the folder I just changed permissions of it still says "Permission Denied". I also noticed that beside some of the files it says chmod: changing permissions '/path/to/Pictures/some-picture.jpg': Read-only file system. So not sure if that means that the chown and chmod is failing, but I see that message on both commands. – marcamillion Dec 18 '14 at 21:41
  • 1
    @marcamillion if that is the case, use the command sudo su first and then try to cd into the folder. – mchid Dec 18 '14 at 21:43
  • When I do ls -l, the Pictures folder looks like this: drwx---------- 1 501 dialout 161 Jul 14 04:43 Pictures. Not sure if that helps any. – marcamillion Dec 18 '14 at 21:44
  • you mean like sudo su cd Pictures? Or sudo su chmod...? I tried the sudo su cd and it said No passwd entry for user 'cd'. – marcamillion Dec 18 '14 at 21:45
  • 1
    no, run the command sudo su press enter and then run the cd command – mchid Dec 18 '14 at 21:46
  • the command sudo su will log you in as root – mchid Dec 18 '14 at 21:47
  • Sweet. That works. But then how do I then now copy everything from there to my USB drive from the GUI interface? Or should I just do it via the command line? Not sure how to access the external USB drive from the command line, ideas? – marcamillion Dec 18 '14 at 21:49
  • Ok I got it, simply using cp -R /path/to/folder-I-want-to-copy /path/to/destination. Can you update the question with the sudo su suggestion, and I will accept it. Thanks! – marcamillion Dec 18 '14 at 21:54
  • Use sudo nautilus to open nautilus with root permission – mchid Dec 18 '14 at 21:54
  • should be a way to mount it (read only) to be visible to a regular user, probably don't need everything in RBF06's answer though – Xen2050 Dec 18 '14 at 21:58
  • @Xen2050 sudo mount -o remount,rw /dev/sdaX /media/drivename replacing sdax with the drive and drivename with the actual drivename – mchid Dec 18 '14 at 22:00
  • @Xen2050 http://askubuntu.com/a/175742/167115 – mchid Dec 18 '14 at 22:01
  • 2
    Thanks, I know the read only part, but the heart of marcamillion's problem is his drive is mounting so he can't see it. He just wants to back up files, not touching them and it may be a FAT FS that would ignore chmod permissions anyway. Something wrong in the mounting it appears. BUT he's running live anyway, and if running as root works that's good enough. – Xen2050 Dec 18 '14 at 22:05
1

I think you only need the mount option uid=[youruserid]

In a terminal you can type echo $UID or id -u to find out your user id.

If the drive's fs is fat, ntfs, cd-rom, udf, and a few others uid=value will "Set the owner and group of all files" to whose id is specified.

If the partition's already mounted (mount to see it & what device it is, or blkid) you might be able to just use

sudo mount -o remount,uid=[youruserid] /dev/[device] [mountpoint]

where [device] is the "sda1" or "sdc2" or whatever the right drive is, and [mountpoint] is the folder it's mounted to (with full path, often /media/something or similar.
(read [device] and [mountpoint] from the above mount or blkid commands)

Using sudo mount -o remount,uid=[youruserid] /dev/[device] alone might work, definitely works if there's an fstab entry for it.

Xen2050
  • 8,705
  • 1
    remount is more flexible... I just tried a test, as long as the device is only mounted in one place (only mounted once) a remount doesn't need the mount point, "remembers" it since it's already mounted - Or maybe that's only if it's in fstab... – Xen2050 Dec 18 '14 at 22:36
0

It probably has to do with how the drive is mounted. If the drive is not mounted with proper ownership, you wont be able to access it. unmount the drive with umount. Then mount it again with the proper permissions: Lets say your UID is 1000 and the drive is a FAT partition then your mount statement should look a bit like this

sudo mount -t vfat /dev/sdwhateveryourdriveis ~/mnt -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

This options flag (-o) should set the proper permissions for the directories on your drive. use the dmask and fmask values above and you your UID for uid

RBF06
  • 101