How to set permissions so that I can read and write to another partition?

140,800

Solution 1

What I would do is the following:

Assuming you have both partitions mounted with the names part1 and part2, you will be the only one using them and you want total free control over them, I would do this:

sudo chmod 777 /media/part1 - This would give all permissions (Read, Write, Execute) to you within the part1 partition.

sudo chmod 777 /media/part2 - This would give all permissions (Read, Write, Execute) to you within the part2 partition.

The permissions (in this case 777) are as follow:

7 - Full (Read, Write & Execute)
6 - read and write
5 - read and execute
4 - read only
3 - write and execute
2 - write only
1 - execute only
0 - none

The first 7 (Starting from the Left) is for the owner, the 2nd is for the group where the owner resides. The last 7 is for other groups. Basically like this you can copy anything you want in the partitions and if you ever need to take the HDD out and connect it to another computer with Ubuntu you will not have any problems with permissions. At least in my case it saves me time because I tend to have 1 or 2 hard drives that hold movies, music and similar stuff and I move them around from PC to PC.

Just to add, if you do not know where the partitions are mounted, you can always open Disk Utility and in the information about the hard drive it will tell you where it is mounted. Remember that you need to apply this to the partition AFTER it has been mounted.

Solution 2

Instead of changing all file permissions, like Luis Alvarado suggested, it would be better to change the file owner - thus keeping the executable bit on any binary and script files that previously had it.

So, assuming your partition is mounted as /media/something and your username is johndoe, you can run

sudo chown -R johndoe:johndoe /media/something

to change the owner and owning group of /media/something (and all files and directories it contains, hence the -R for 'recursive') to johndoe.

This way, all files will retain their permissions, but since you will be the owner of /media/something, you will be able to write to it and change any file permissions, in case you ever need to.

Solution 3

Change permission

 sudo chmod -R a+rwx /path/of/folder

Solution 4

I had the same problem and solved it by running nautilus as root, right click on the partition, properties, and changed the permissions (or owner if necessary).

If nautilus is not installed:

sudo apt-get nautilus
Share:
140,800

Related videos on Youtube

hassan dusti
Author by

hassan dusti

Updated on September 18, 2022

Comments

  • hassan dusti
    hassan dusti over 1 year

    I m using Ubuntu 12.04 and i have to partitions part1 and part2, both are ext4. I want to transfer media files to and from them freely through programs.

  • hassan dusti
    hassan dusti almost 12 years
    So what should be the output from the command "sudo mount /a"? My output was "mount: can't find /a in /etc/fstab or /etc/mtab".
  • Deepak Verma
    Deepak Verma almost 12 years
    I'm sorry, I don't know how I did that, but I meant "-a", not "/a". It just means to mount everything in fstab, and is a good way to test for errors. I'll correct my post.
  • Deepak Verma
    Deepak Verma almost 12 years
    I always avoid a mode like 777, mainly because it is often hard to read due to the terminal colors that alert you to it being world writable. If he's the only user, then using 755 accomplish the same thing and be easier to read with normal colors
  • Luis Alvarado
    Luis Alvarado almost 12 years
    I agree with you on that. Specially folders.
  • n.st
    n.st over 10 years
    Why even change the permissions when you can just chown it to the current user?
  • Luis Alvarado
    Luis Alvarado over 10 years
    Hi n.st the reason is that in all cases I have tried, doing a chown did not actually give the needed permissions. It did change the owner to the current one but the files and folders still had wrong permissions and so the user could not write to the unit.
  • Fabby
    Fabby almost 5 years
    That is exactly the same as what the accepted answer does too, just using different syntax than you. 777 is the same as rwx.
  • Quidam
    Quidam about 4 years
    Alternatively chmod +rwx could replace the chmod 777.
  • Quidam
    Quidam about 4 years
    @MartyFried Change your terminal color. It could be dangerous to not be able to read fully.
  • Deepak Verma
    Deepak Verma about 4 years
    @Quidam: It's also dangerous to set files to R/W for the world. Changing terminal colors is not very easy, since there are many different terminal programs that might be used, both locally and remote. I just use chown, and it always works.
  • Deepak Verma
    Deepak Verma about 4 years
    RE: chown. You need to chown for the directory before mounting, then do it for the folder and files in that directory after mounting to have it work correctly.