Ubuntu Hardware Permissions: How to Set Ownership of Drive or Partition (Internal & External Hard Disks)

If you’ve attached an external hard drive for backing up your files, or created a new partition for storage, only to find you don’t have the permissions to use it, you’d be understandably frustrated. But it’s actually quite easy to remedy by simply running a command in the terminal in the form of:

sudo chown -R username:username /partition/mount-point

Note that the above isn’t the actual command you’ll be using, as you’ll need to replace each instance of username with your actual username, and also determine your mount-point, which is not the device name (eg: /dev/sdb1).

To find the mount-point, run mount in the terminal, and locate the line that corresponds to the drive or partition in question. If you have never named (or set the label for) it, it will probably look something like:

/dev/sdb1 on /media/bf9a2c45-491a-4778-9d76-47832fe38820

If you have set the label with something descriptive, it should like similar to:

/dev/sdb1 on /media/1Tb Pocket Drive

As you can see, your mount-point will look something like /media/bf9a2c45-491a-4778-9d76-47832fe38820 or /media/1Tb Pocket Drive, so all you need to do now is run a command like one of the following, replacing the relevant info with what is appropriate to you:

Note that if your custom label contains spaces (e.g. 1Tb Pocket Drive) , you will need to enclose the entire mount-point path in single quotes, but won’t need them if it’s a single word or multiple words joined by hyphens or underscores.

That’s it – you should now be able to do whatever you want with the drive or partition in question, as you’re now theowner.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

That’s the nicest expo of permissions; e.g. going deeper into finding mountpoint -I’ve so often been stopped by just a little bit of ambiguity – which is like just a little hole in a balloon! – I get the feeling that this is often purposeful i.e. anti-spoonfeed, but misplaced. Anyway, thanks, my brain grasps the permissions deal better now.

OK, I’m actually not sure what the question is. mount will simply show what’s mounted, and the tutorial you were at shows how to set drive permissions. I gather the ext4 partition /dev/sdb1 is your Ubuntu install (on the second physical drive), so you already have access to that, though you can only delete/edit stuff in your home folder without special permissions (in other words, the system owns all but the home folder, and tmp). If you’re trying to set ownership of a removable drive, then it needs to be plugged in while doing so. According to your output, you only have your system drive attached/mounted.

Thankyou for the help about my ext4 partition; I understand what is going on with the ext4 partition better now. I blew up my Ubuntu install and it has taken me a while to repair and get back here to thank you. Your website is the first I returned to so I could start learning some more. Thanks again for all your tips and tricks etc.

Thank you for the tutorial. I solved the problem and I am a bit ahead in Ubuntu. I think that solving the problems are the best way to study a new subject. I gone only through two lessons. Now I
can do a lot with the terminal command. Again, thanks a lot for providing such valuable lessons.

I’m trying to add something to my usr/bin/ directory but my system keeps telling me permission denied. I assume this article is the article is what I’m looking for, but when I type “mount”, I don’t see a /sdb2 option. Is this because I don’t have an external drive? Everything I’m trying to do is on my internal hard drive, so do I have the wrong tutorial?

Stemming from this, when I use the “chown” command, I get the error “chown: cannot access ‘/media/username/Acer type fuseblk/': No such file or directory. (I did replace “username” with mine, so no worries there.)

Oops, NO, actually this is for setting permissions for external drives or partitions other than what your system is on! Last thing you want to mess with is what the system owns on your Ubuntu partition, which is everything but your home folder. All you need to do is become ADMINISTRATOR (or “super user”) just for that current task. You can do this via CLI or GUI… these days you should be able to do this without the need for commands in the terminal so, for example, go into /usr via Nautilus (file manager), then right-click the sub-folder bin and choose “Open as administrator“, in which case you’ll be prompted for your password, and then a new “root” window will open in that folder… then you can simply drag and drop stuff into it, rename things, or create a new folder in it like you would do in your home folder. That should do the trick.

hi. I am running a live cd version of ubuntu 12.10 in an imac. I have a failing internal hard drive in that imac. I am trying to get ownership of that drive so that I can move the files that are on it to an external drive, and try to save whatever data I can. Any suggestions? I tried the above, but I got an error message for the chown -R command.

OK, if you’re using the Live CD for the chown command, then you can’t use your own username, since of course it doesn’t exist. The default username is ubuntu, and the password should be left blank (if not, then it should also be ubuntu). Alternatively, you could try sudo nautilus followed be the drive’s address to open Nautilus in superuser mode and just drag and drop as you please. To get that address, you can first open the partition in Nautilus, Ctrl+L to get the address bar up, then copy that path and paste it into the terminal. See how that goes.

Greek: “can’t access” & “no such file or directory”.
Am I doing something wrong?
Originally I had user rights, but after I deleted some items from my usb flash drive, I don’t, and furthermore the trash bin won’t empty.
Thanx in advance (and sorry for my poor english).

OK, not sure what is going on here, since if your drive is mounted OK, that command should work (assuming you’ve entered the device name and mount point path correctly, of course). And I have to say it is very strange that all was fine until you deleted a few items from that drive! Normal file management tasks like deleting files simply shouldn’t have ANY effect on things like permissions/ownership. Run gksudo nautilus and navigate to the drive and see if you can delete files in its trash folder that way. In some cases it is necessary to hold down the SHIFT key so the deleted folders/files don’t reappear in the same Trash bin. Then also right-click an empty area of the root of that drive and choose Properties, and see if you can change permissions via the Permissions tab. See how that goes.

Thank you for your clear description. Will try it later! Not quite on topic but I cannot find anything when searching. I like dolphin but caja is default. Dolphin mounts my partition as media/winlin but caja mounts as media/username/winlin. I obviously set up my mail when I had only used dolphin to the folders are linked to media/username/…mail. If caja opens a file before that the mail and various other links do not work as the path is now different ie now has the username inserted.
This is driving me nuts and I have no idea to to solve it. Any ideas? PS I would like to keep using dolphin for some things. Thank you

By “unable to access” do you mean you can’t access the device at all, or just can’t delete files off it, etc? Anyway, one thing I can tell you is that VFAT does not support Linux permissions, but there are ways around it (besides formatting the device to NTFS). Google “ubuntu permissions to vfat usb drive” and you will see plenty of others have come across this, and people have offered a wide variety of solutions, like vfat-specific mount commands, and editing fstab. You can then try which ones work for you. All the best.

I am using ubuntu 13.10…Had issues described above…I tried what was outlined in your article…. Did not work for me ….. The “mount” command did show the usb stick that I needed to change… When I entered the command to change …. The terminal window scrolled several lines “change of ownership denied…. But there was a couple folders on the usb stick from a windows system…The was plenty of space on the usb stick and it was not incrypted…. Any suggestions

I’m guessing the stick is formatted as VFAT, as most are. Unfortunately, VFAT does not support Linux permissions, but there are ways around it (besides formatting the device to NTFS). Google “ubuntu permissions to vfat usb drive” and you will see plenty of others have come across this, and people have offered a wide variety of solutions, like vfat-specific mount commands, and editing fstab. You can then try which ones work for you. All the best.

PS: The folders from your Windows system make no difference, as Ubuntu can handle any filesystem thrown at it. Half my portable drives are NTFS, and I have my actual Windows XP partition mounted and moving stuff between filesystems (EXT4 and NTFS) is not a problem. But as you’ve seen, VFAT is a bit of a bugger, as while you can move files about etc between Ubuntu and a USB stick, the permissions issue is another matter.

OK, ignoring the fact your mount point is called “VideoCD” (since you can’t actually write to an optical disc that’s been finalised), the problem seems to be that it is mounted only as RO (read-only) – you need to mount it as RW (read/write). Try:

mount -o rw,remount /media/VideoCD (you’ll probably need to start that off with sudo)

Of course, if it is in fact a finalised disc, then that’s your answer – you can’t do anything to it, since it is understandably mounted only as RO.

this is total bullshit are we still stuck in the dark ages where we type commands I really want to like Linux I really do when Linux quits the command thing I mean this is 2013 lets let Linux start the right and left click thing.

OK, if all that is copied and pasted straight from the terminal, I can see some problems with your initial command: sudo chown -R victor:victor/dev/sda3 on ‘/media/victor/BACK UP ONE ‘

First, there is no space after victor:victor – you’ve put it as victor:victor/dev/sda3, which is bound to cause problems. Secondly, instead of putting your mount point – ‘/media/victor/BACK UP ONE’ – you’ve put /dev/sda3 on ‘/media/victor/BACK UP ONE ‘ – that /dev/sda3 on (and space after it) is not needed, and can only result in failure. And lastly, notice the space at the end of the mount point? That of course will also end in failure – the computer won’t correct typos or remove characters you accidentally entered, so you need to be extremely careful you’ve entered something that isn’t gibberish to the computer. ‘/media/victor/BACK UP ONE ‘ instead of ‘/media/victor/BACK UP ONE’ would have been enough to make this fail, as you have a partition with the former name and not the latter with that extra space.

Thanks admin though i could not still make it despite taking note of your earlier instructions. However, i decided to format the partitions to NTFS file systems and now i can add and delete files from them though i don’t know the consequences with regards to this. Please can you advice if at all its safe to keep my document in this partitions when they are in this file format system and if at all i stand a chance of loosing any of them or not being able to perform certain actions as a result of this file format system.
Please note that when i look at the disc permission this is what i get ” The permission of BACH UP ONE could not be determined ” though if i open the disc and check the properties from agen by righ clicking and moving down to select properties i get the details that i am the owner and that i have the permission to access and delete files.
Please advise.

Hi. While NTFS is vastly inferior to *journaling* filesystems like EXT3, and especially so compared to EXT4, it is safe to use in Linux. In fact, when I first installed Ubuntu in 2006, the NTFS support was already fantastic, and errors transferring files between NTFS and EXT3 were almost unheard of. The only reason I would personally format a drive to NTFS is if I wanted to share files with friends on the Windows PCs. For your own backups, etc, I really would recommend the next drive you get to set up as EXT4, and just nut through the permissions issue (hopefully you don’t have to worry too much about this in the future – most people don’t have as much trouble as you did). All you’d then need to do is reclaim the reserved space via: https://ubuntugenius.wordpress.com/2012/01/10/how-to-reclaim-reserved-space-on-ext4-partitions-external-hard-drives-in-ubuntu/.

Well, not really, as while I had a few readers suggest I should add a donate button, as they would have gladly donated, in the 2 or 3 months since I did, I’ve yet to receive a single donation. Still, it’s done, and just took some time, and my PayPal account being suspended for a few days while they did a background check (to prevent money-laundering, apparently) – that coincided with a few quiet days on eBay, so I didn’t have to explain anything to customers who were trying to pay. Cheers

Ok Genius. I read the rest and it’s not addressed. :)
I’m running crouton (minimal ubuntu) on a chromebook.
I installed software to legally watch my dvd movies and an external dvd
I can play movies but I have to do chmod 777 /dev/sr0 every time.
I tried following the directions here and changing ownership of th mount point.

sudo chown -R julia:julia /var/hosts/media/removable/DRIVE

I tried it first without the movie name “DRIVE” (confusing name in this context)
the error I get is:

chown cannot access ‘/var…/DRIVE’ no such file or directory
or
chown cannot access ‘/var…/removable’ no such file or directory

If I remove the DVD from the drive, the external DVD drive no longer shows up in mount list

also and maybe important, fstab is empty.
I think things are getting mounted by some other mechanism.

I did this
sudo chown -R fiowak:fiowak /media/fiowak/3c2cb145-3dec-4101-9dc0-b7d40c351ed6
But it said
changing ownership of ‘/media/fiowak/3c2cb145-3dec-4101-9dc0-b7d40c351ed6/ldlinux.sys’: Operation not permitted

OK, I’m not too versed in ldlinux.sys, but the file has the immutable attribute set, which prevents it from being deleted or overwritten. ldlinux.sys is the bootloader file used in SYSLINUX and ISOLINUX (used for booting Linux off of FAT32 and ISO9660 filesystems, respectively). It is loaded into memory by the BIOS on bootup. The loader then parses the configuration file (syslinux.cfg or isolinux.cfg) to know which kernel to launch, along with parameters to be passed to it. So, if this is just a backup drive, not a boot drive with OS (though it seems it was at one point), then I guess it would be safe to delete the file. I’d look for more info on that, or if worse comes to worse wipe it with the Partition Editor.