[nmglug] change permissions on USB drive

brianokeefe okeefe at cybermesa.com
Fri Oct 12 11:55:24 PDT 2007


Gary Sandine wrote:
> 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
>
>   
I changed the permissions as per Nick but I would, of course, like them 
to be permanent so I checked out Andres method.
Here's what I now have pre-Andres:
debian:/media# ls -l
total 12
lrwxrwxrwx 1 root root    6 2007-10-03 07:56 cdrom -> cdrom0
drwxr-xr-x 2 root root 4096 2007-10-03 07:56 cdrom0
drwxrwxrwx 3 root root 4096 2007-10-12 12:31 disk
lrwxrwxrwx 1 root root    7 2007-10-03 07:57 floppy -> floppy0
drwxr-xr-x 2 root root 4096 2007-10-03 07:57 floppy0

I can see /media/sda3, the USB drive, in a file manager but not as 
above. when I try Andres commands with "disk" I get:
debian:/media# grep sda3 /etc/sda3
grep: /etc/sda3: No such file or directory
debian:/media# grep sda3 /etc/fstab
debian:/media# pmount sda3
Error: device /dev/sda3 is already mounted to /media/disk
debian:/media# ls -ld /media/disk/sda3
ls: /media/disk/sda3: No such file or directory
debian:/media# pmount disk
Error: invalid device /media/disk (must be in /dev/)
debian:/media# cd /dev
debian:/dev# ls
adb      hvc2     mixer  ram7        tty13  tty34  tty55           vcs
audio    hvc3     net    ram8        tty14  tty35  tty56           vcs1
bus      hvc4     null   ram9        tty15  tty36  tty57           vcs2
cdrom    hvc5     nvram  random      tty16  tty37  tty58           vcs3
cdrw     hvc6     pmu    rtc         tty17  tty38  tty59           vcs4
console  hvc7     port   sda         tty18  tty39  tty6            vcs5
core     initctl  ppp    sda1        tty19  tty4   tty60           vcs6
disk     input    psaux  sda3        tty2   tty40  tty61           vcs7
dri      kmem     ptmx   sequencer   tty20  tty41  tty62           vcsa
dsp      kmsg     pts    sequencer2  tty21  tty42  tty63           vcsa1
dvd      log      ram0   shm         tty22  tty43  tty7            vcsa2
fb0      loop     ram1   snapshot    tty23  tty44  tty8            vcsa3
fd       loop0    ram10  snd         tty24  tty45  tty9            vcsa4
fd0      loop1    ram11  sndstat     tty25  tty46  ttyS0           vcsa5
full     loop2    ram12  stderr      tty26  tty47  ttyS1           vcsa6
hda      loop3    ram13  stdin       tty27  tty48  urandom         vcsa7
hda1     loop4    ram14  stdout      tty28  tty49  usbdev1.1_ep00  xconsole
hda2     loop5    ram15  tty         tty29  tty5   usbdev1.1_ep81  zero
hda3     loop6    ram2   tty0        tty3   tty50  usbdev1.2_ep00
hda4     loop7    ram3   tty1        tty30  tty51  usbdev1.2_ep81
hdc      MAKEDEV  ram4   tty10       tty31  tty52  usbdev1.5_ep00
hvc0     mapper   ram5   tty11       tty32  tty53  usbdev1.5_ep02
hvc1     mem      ram6   tty12       tty33  tty54  usbdev1.5_ep81
debian:/dev# pmount disk
Error: /dev/disk is not a block device
debian:/dev# pmount disk/sda3
Error: could not determine real path of the device: No such file or 
directory
debian:/dev#

I'm learning something though!
thanks!




More information about the nmglug mailing list