[nmglug] change permissions on USB drive

Gary Sandine gars at laclinux.com
Fri Oct 12 11:05:50 PDT 2007


On Fri, Oct 12, 2007 at 09:41:50AM -0600, Nick Frost wrote:
> > On Thu, 2007-10-11 at 22:02 -0600, Nick Frost wrote:
> >> chown root:brianokeefe
> >>
> >> chmod 777 disk
> >>
> > I'm confused. Why would we bother changing ownership if we're going to
> > set the permissions to 777 (rwxrwxrwx) ?
> 
>  Correct, there is no need. However, Brian's question was how to
>  change group ownership of a directory (or file) and set
>  permissions thereof.

If this was mentioned, I missed it.... FWIW I think he will find
that, no matter what ownership and permissions he applies to the
mount point, they very well might change once something is actually
mounted there.  In some cases, the permissions will stick if the
chmod/chown/chgrp is done after the device is mounted.  For example:

$ whoami
gars
$ ls -ld /media/sdb1 <--- original perms are 1777
drwxrwxrwt 2 root root 4096 2007-10-12 11:45 /media/sdb1
$ grep sdb1 /etc/fstab
/dev/sdb1 /media/sdb1 auto noauto,users,rw,exec 0 0
$ mount /media/sdb1  <--- ownership and perms change
$ ls -ld /media/sdb1
drwxr-xr-x 11 gars users 4096 1969-12-31 17:00 /media/sdb1
$ umount /media/sdb1
$ ls -ld /media/sdb1
drwxrwxrwt 2 root root 4096 2007-10-12 11:45 /media/sdb1
$ su -
# whoami
root!
# mount /media/sdb1  <--- perms change
# ls -ld /media/sdb1
drwxr-xr-x 11 root root 4096 1969-12-31 17:00 /media/sdb1
# exit
$ su - jane
$ whoami
jane
$ mount /media/sdb1  <--- ownership and perms change
$ ls -ld /media/sdb1
drwxr-xr-x 11 jane users 4096 1969-12-31 17:00 /media/sdb1

Or, without an entry in /etc/fstab and with appropriate programs
installed and configured well enough:

$ whoami
gars
$ ls -ld /media/sdb1  <--- original perms are 1777
drwxrwxrwt 2 root root 4096 2007-10-12 11:51 /media/sdb1
$ grep sdb1 /etc/fstab  <--- no output; no fstab entry for sdb1
$ pmount sdb1  <--- ownership and perms change
$ ls -ld /media/sdb1
drwx------ 11 gars users 4096 1969-12-31 17:00 /media/sdb1

-- 
Gary Sandine <gars at laclinux.com>




More information about the nmglug mailing list