Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an external hard drive connected to my Linux box. I wanted to setup a web server to access files on it, but the permission on all files and directories on the drive are rwx for the owner which is my local login, and the group is the root group.

I need the files readable by the apache user, I was trying to set all files to be chmod a+rwx -R *, but this doesn't do anything (gives no errors, just has no effect.) I tried changing the group using chgrp to my user group, but that won't work either, it gives me errors that I lack permission even when I run all those commands as sudo!

What's up with this hard drive??? sudo chmod a+rwx * should work on anything, right?

share|improve this question

4 Answers 4

up vote 11 down vote accepted

Check the filesystem type it's using first with df -T:

sys@p:~$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
ext3          ext3    19222656   1050948  17195164   6% /
tmpfs        tmpfs     1684988         0   1684988   0% /lib/init/rw
udev         tmpfs       10240        64     10176   1% /dev
tmpfs        tmpfs     1684988         0   1684988   0% /dev/shm

If it's mounted on /mnt/external for example you will see that in the far right column. You can see the filesystem type in the second column. If it's NTFS, you'll want NTFS-3G (probably already installed, if not sudo apt-get install ntfs-config then gksu ntfs-config). Linux already has FAT support for read & write although they do not support permissions.

If you want an NTFS partition mounted with ownership applied to a specific user/group, specify it in the mount switches:

mount -o uid=username,gid=groupname /dev/sdc /path/to/mount

If you change to ext3 as suggested above, you can use chown:

chown -R user *
chown -R user .
share|improve this answer

As Kim said, you'll only get Unix permissions and ownership on a Unix filesystem. ext3 is a good candidate.

If you must use this drive without reformatting, you can do it with options to the mount command that specify the owner, group, and/or read/write permissions. These options affect all files on the drive (see John T's answer for how to determine the FSTYPE):

# list files as owned by X, use numerical UID as found in /etc/passwd
$ mount -t <FSTYPE> -o uid=X /dev/?? /path/to/mount/point

# list files as owned by group Y, use numerical GID found in /etc/passwd
$ mount -t <FSTYPE> -o gid=Y /dev/?? /path/to/mount/point

# list files as accessible per umask 
#   (022 gives rwx permissions to owner, r-x permissions to everyone else)
$ mount -t <FSTYPE> -o umask=022 /dev/?? /path/to/mount/point

# combine all of the above:
$ mount -t <FSTYPE> -o uid=X,gid=Y,umask=022 /dev/?? /path/to/mount/point
share|improve this answer

It's probably formatted as FAT, which doesn't support file permissions. Use ext3 instead.

share|improve this answer

I did this and it worked:

sudo umount /dev/sda3 /media/windows1
sudo umount /dev/sda5 /media/windows2

and then

sudo mount -o rwx /dev/sda3 /media/windows1
sudo mount -o rwx /dev/sda5 /media/windows2

Note that I am Using Ubuntu 11.10 and sda3 is my Windows C:, sda5 is G:.

share|improve this answer

Your Answer

 
discard

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.