[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to change ownership of subdirectories under /media



Hi,

On Sat, May 03, 2025 at 06:22:45AM -0400, Haines Brown wrote:
> I want to enable a user to copy files to a USB key mounted on a directory 
> under /media. 

Are you talking about the automatic mounting under /media of a user's
removable media devices (USB keys etc) under a desktop environment, or
manual mounting that you are doing with "the "mount" command and/or the
/etc/fstab file, possibly outside of a desktop environment?

> I can change the ownership of that directory to that of the user, but 
> when I mount the the key on it the ownsrhip reverts to root.

The reason why I ask the above is that under a mainstream Linux desktop
environment you problem doesn't really exist - the current user's media
will be mounted under /media/$USER/<something> and owned by them. The
only way you should experience the problem you're describing in that
circumstances is if you are trying to do file operations on the
removable media as a user OTHER than the one logged in to the desktop
environment.

However if you are manually as root using the "mount" command to mount
something under /media then yes by default the mount point is usually
going to be owned by root.

If the filesystem on the media supports Linux permissions then you could
change the ownership of the root of it after it is mounted.

If the filesystem doesn't support Linux permissions, like the common
range of Microsoft filesystems like fat, exfat, vfat etc that are often
seen on removable media, then you would need to specify the desired
owner/group in the mount options either on the "mount" command line or
in the options field in fstab.

If your question has not by now been answered by this and other
responses you've received, please post a transcription of your exact set
of steps including full command output, "ls -la" of the mount point
directory before and after your mount, contents of your /etc/fstab, and
no censored details.

Thanks,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting


Reply to: