You are not logged in.

#1 2010-03-25 13:36:39

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Permission Denied when changing directories

So my friend brought over his external hard drive and I plugged it in and typed "sudo mount /dev/sdd1 /mnt/" as I normally do.
It seemed to mount just fine, but when I typed in "cd /mnt/" I got a permission denied.
I had to log in as root to CD there as well as do any other commands.

I have never seen this before, can someone explain why it happened? Was it something special with the drive or did I do something wrong?

Offline

#2 2010-03-25 13:55:07

ruffedgz
Member
From: Michigan
Registered: 2009-07-23
Posts: 54

Re: Permission Denied when changing directories

It could be the drive itself that has 'root:root' as the uid:gid for it. To check, all you have to do is after mounting the drive, you check who is the owner of the files in /mnt with:

sudo ls -l /mnt/

From that you can see if the files are owned by root.

Depending on the type of file system you are mounting (adfs,  affs,  autofs, etc...), you can add options to set the uid and gid of the mounted drive to yourself. You will have to check the man page on 'mount' (look for FILESYSTEM SPECIFIC MOUNT OPTIONS in the mount manpage) to see if the file type can use this but I find this command might work on a lot of file types:

sudo mount -t fat -o uid=12345,gid=12345 /dev/sdd1 /mnt

See if this helps a bit.

Last edited by ruffedgz (2010-03-25 13:55:30)


Arch linux i686 | Dell XPS m1530 | Intel Core 2 Duo 2 GHz | 3 GB RAM | 250GB HDD

Offline

#3 2010-03-25 15:13:40

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: Permission Denied when changing directories

The files could be root or even a different user id. What is the file system on the disk?

Offline

#4 2010-03-25 15:24:28

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: Permission Denied when changing directories

I will create a directory to mount the drive, for example, /mnt/drive/, and try to use it instead of /mnt/.

Offline

#5 2010-03-25 15:29:49

Dethredic
Member
Registered: 2009-01-24
Posts: 361
Website

Re: Permission Denied when changing directories

it was a ntfs drive.

Offline

#6 2010-03-25 15:34:34

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: Permission Denied when changing directories

I think NTFS defaults to mounting as root. You can specify the user via the options. 'man mount.ntfs-3g' is your friend.

Offline

#7 2010-03-25 15:38:18

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: Permission Denied when changing directories

cd requires execute permissions on a directory. Verify for yourself:

cd ~
mkdir -m 660 test
cd test # permission denied
ls test # works fine! (ls only requires _read_ privileges)
rmdir test

M*cr*s*ft: Who needs quality when you have marketing?

Offline

Board footer

Powered by FluxBB