[SOLVED] Permissions? User can mount media using GUI but not by command line
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Permissions? User can mount media using GUI but not by command line
(I'm sure this has been asked before but I haven't found yet how to search using all the words in this thread title. If someone could give me a tip, I'd appreciate it.)
My Problem:
I can't find the way to mount media as a regular user at the command line. I know how to do it as root but I want to know the right way to do things and not always use root.
On command-line logged in as user: pete, I first made a directory that had my ownership permissions.
Code:
$ mkdir tmp
$ ls -al tmp
drwxr-xr-x 2 pete users 4096 Feb 2 12:31.
drwx--x--x 29 pete users 4096 Feb 2 12:31.
$ mount /dev/sdc1 tmp
mount: only root can do that
Okay, so go to GUI ($ startx). Now in Xfce, the icon is shown on the desktop for the USB stick and hovering the mouse over it says Volume not mounted yet. I right-click it and choose Mount Volume. Open Terminal Emulator to check mount.
Code:
$ mount
/dev/sdc1 on /run/media/pete/KINGSTON type vfat (rw,nodev,nosuid,uid=1000,gid=100,shortname=mixed,utf8=1,showexec,flush,uhelper=udisks2)
Now try to unmount it.
Code:
$ umount /dev/scc1
unmount: /run/media/pete/KINGSTON: unmount failed: Operation not permitted
$
$ ls -al /run/media/pete
drwxr-x---+ 3 root root 60 Feb 2 12:50 .
drwxr-xr-x 3 root root 60 Feb 2 12:50 ..
drwxr-xr-x 3 pete users 4096 Dec 31 1969 KINGSTON
I see that directory pete was temporarily created with root permissions, so that is why I can't unmount it.
I found something on the Internet that said that the media itself must be mounted with the user information so using information from the successful (GUI) mount, I tried:
Code:
$ mount /dev/sdc1 ~/tmp -o uid=1000 -o gid=100
mount: only root can use "--options" option
Well, that didn't work. So how did Thunar do it while I was logged in as user and how can I do it myself at the command line as user without having to use root? I only use the GUI for a program that needs it.
@Skaendo, the "tmp" that I tried to mount wasn't /tmp, but was one I created myself in the /home/pete/ directory. (I tried other names too.) I thought that should be able to mount anything by the user. I can do everything else with any subdirectory I create there. There must be something about "mount" that I don't know yet.
@BigTig, I think fstab is mostly for mounting automatically at boot. Actually, I've always just used root to mount and anything that's correct on the command line gets mounted. I'm trying to learn how to do it as user, which seems not to have permission.
If I understand correctly, you want to mount external USB media through the command line.
By design the mount command can be executed only as root, even if the user is a member of the disks group.
With respect to your focus, GUI file managers use gvfs to auto-mount devices.
To mount manually from the command line I think you are looking for /usr/bin/gvfs-mount.
The location of the external USB mount point is determined by udev. The default is to a private directory, but can be changed to a shared location. I have the following on my systems:
Code:
# Where to mount removable devices.
# 0: Mount to a private directory ([/var]/run/media/$USER/$UUID)
# 1: Mount to a shared directory (/media/$UUID)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"
On my systems external USB devices mount to /media/$UUID.
@vtel57, I put the line in fstab, but it still doesn't work for me.
@upnort, I tried replacing "mount" with "/usr/bin/gvfs-mount" and it replied with "Error mounting location: volume doesn't implement mount". I will read up about gvfs, which I was not aware of. Thank you.
@BigTig, I think fstab is mostly for mounting automatically at boot. Actually, I've always just used root to mount and anything that's correct on the command line gets mounted. I'm trying to learn how to do it as user, which seems not to have permission.
According to the man page:
"The file fstab contains descriptive information about the filesystems the system can mount. "
and
"The fourth field (fs_mntops).
This field describes the mount options associated with the filesystem.
user allow a user to mount"
I set a line in fstab like this to mount a usb stick:
@vtel57, I put the line in fstab, but it still doesn't work for me.
Well, @upnort is correct when he stated:
Quote:
By design the mount command can be executed only as root
If what you're trying to accomplish is to mount an external device such as USB stick, or camera, phone, etc., I would definitely recommend Thunar Volman (linked in my previous post). When properly configured Volman will auto-mount anything you plug into that machine.
Anyway, don't want to create confusion for you with everyone else who's giving you good assistance, so I'll sit back a bit and continue to read this thread as it progresses.
Oh, and by the way, I may not have made this clear, but if you want to use fstab to set up mounting for certain partitions, you MUST mount those partitions in your own /home directory somewhere in order to access with RWE privileges. See my vfat common partition in the fstab above: it's mounted in my own /home directory. This way, once it's mounted, I can access it as user; not required to be root.
@vtel57, I used the same information as you did for your sdc2 device and that gave me rw permission to a USB stick mounted in tmp in my home directory. fstab mounted it when I booted up. I still can't mount or unmount but now I know that is because mount is only for root to use. This sure helps me, though. Thanks.
I still want to become acquainted with gvfs, as @upnort mentioned. Thanks to everyone!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.