LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-02-2020, 03:50 PM   #1
silverlining
Member
 
Registered: Jan 2020
Location: Oregon, U.S.A.
Distribution: Slackware64 ver 15.0
Posts: 99

Rep: Reputation: 19
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.
 
Old 02-02-2020, 04:14 PM   #2
perbh
Member
 
Registered: May 2008
Location: Republic of Texas
Posts: 393

Rep: Reputation: 81
Because thunar itself runs as root.
 
1 members found this post helpful.
Old 02-02-2020, 04:31 PM   #3
Skaendo
Senior Member
 
Registered: Dec 2014
Location: West Texas, USA
Distribution: Slackware64-14.2
Posts: 1,445

Rep: Reputation: Disabled
Could it be that you are trying to mount/unmount to /tmp which is owned by root?

You might want to make a mount directory like /media/usb-stick and set the permissions for your user then mount to that.
 
Old 02-02-2020, 04:37 PM   #4
silverlining
Member
 
Registered: Jan 2020
Location: Oregon, U.S.A.
Distribution: Slackware64 ver 15.0
Posts: 99

Original Poster
Rep: Reputation: 19
@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.
 
Old 02-02-2020, 04:39 PM   #5
BigTig
Member
 
Registered: Aug 2015
Posts: 61

Rep: Reputation: Disabled
In order for users to mount stuff, don't you have to set that in fstab?
e.g. /dev/sdc1 /media/phone vfat rw,noauto,user 0 0
 
Old 02-02-2020, 04:45 PM   #6
Skaendo
Senior Member
 
Registered: Dec 2014
Location: West Texas, USA
Distribution: Slackware64-14.2
Posts: 1,445

Rep: Reputation: Disabled
I just tried on current and it says:

Quote:
mount: /media/usb-stick: must be superuser to use mount
 
Old 02-02-2020, 04:48 PM   #7
silverlining
Member
 
Registered: Jan 2020
Location: Oregon, U.S.A.
Distribution: Slackware64 ver 15.0
Posts: 99

Original Poster
Rep: Reputation: 19
@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.
 
Old 02-02-2020, 04:57 PM   #8
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Personally I modify /etc/fstab to mount all partitions that I want mounted (as user) on boot up. My fstab looks like this:

Code:
/dev/sda4        swap             swap        defaults         0   0
/dev/sdb4        swap             swap        defaults         0   0
/dev/sda1        /                ext4        defaults         1   1
/dev/sda2        /home            ext4        defaults         1   2
/dev/sda3        /home/vtel57/vtel57_storage ext4        defaults         1   2
/dev/sdc2        /home/vtel57/vtel57_common vfat        fmask=111,dmask=000 1   0
#/dev/cdrom      /mnt/cdrom       auto        noauto,owner,ro,comment=x-gvfs-show 0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
/dev/sdj4        /mnt/zip	  vfat	      noauto,rw,user,nosuid,sync,mode=0777	
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
tmpfs            /dev/shm         tmpfs       defaults         0   0
I also have a Thunar plugin that auto-mounts (with user access) external media; usb devices, for example.

How to set up your fstab.

Hope that helps.
 
1 members found this post helpful.
Old 02-02-2020, 05:00 PM   #9
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162Reputation: 1162
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.
 
1 members found this post helpful.
Old 02-02-2020, 05:15 PM   #10
silverlining
Member
 
Registered: Jan 2020
Location: Oregon, U.S.A.
Distribution: Slackware64 ver 15.0
Posts: 99

Original Poster
Rep: Reputation: 19
@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.
 
Old 02-02-2020, 05:26 PM   #11
BigTig
Member
 
Registered: Aug 2015
Posts: 61

Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by silverlining View Post
@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:

UUID="0130-68A5" /media/usb vfat rw,noauto,user 0 0

Hope that helps.


Hope that helps.
 
Old 02-02-2020, 05:32 PM   #12
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Quote:
Originally Posted by silverlining View Post
@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.

Luck with it!

~Eric
 
Old 02-02-2020, 05:37 PM   #13
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
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.
 
1 members found this post helpful.
Old 02-02-2020, 05:51 PM   #14
silverlining
Member
 
Registered: Jan 2020
Location: Oregon, U.S.A.
Distribution: Slackware64 ver 15.0
Posts: 99

Original Poster
Rep: Reputation: 19
@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!
 
Old 02-02-2020, 06:30 PM   #15
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Keep at it, @silverlining. You'll be a GNU/Linux whiz in no time.

Catch up with you around here again some time...

~Eric
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ILO: Using Virtual Media with the Command-Line Interface command not working on ILO3 LittleMaster Linux - Server 0 10-31-2017 11:44 AM
[SOLVED] Fedora 11 can not enter GUI but via grub command line it can start normally hh3755 Linux - Newbie 1 11-10-2009 05:27 AM
Su permissions (User A can su to User B, but not User C) Whir47 Linux - Security 1 01-21-2009 03:56 AM
can log in from command line but not from GUI logon screen bezdomny Linux - Desktop 1 07-19-2008 08:11 PM
can not mount a samba drive on command line but see via GUI cricballa Linux - Newbie 9 10-20-2007 08:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration