I am running a default fedora 15 install. My goal is to have a couple of network drives get mounted right after the user logs in graphically (not via ssh).

The script I want to execute is basically just a bunch of mount commands: sudo mount ...; sudo mount ...; sudo mount ...;.

I used visudo to let the user have NOPASSWD necessary when doing sudo mount.

Where can I put my simple script so that when the user logs in the script will execute?

  • each user would mount a different network drive... this is why I would like this to happen after login and not at the computer startup. – Trevor Boyd Smith Sep 15 '11 at 19:26

Firstly, you should not simply allow unfettered access to mount as the superuser using NOPASSWD. You should instead create appropriate entries in /etc/fstab so that the filesystems can be mounted by unprivileged users.

If you really want to do this (you don't), you can do this in ~/.bash_profile if the users use bash as their shell, otherwise ~/.profile, or in /etc/profile by evalating $EUID.

Again, don't do that. Just add the fstab entries so that an unprivileged user can mount it without elevating.

  • If i put the mount into /etc/fstab, then the user can do on the command line: mount $NETWORK_DRIVE_NAME. I thought the user still needs to do 'sudo mount $NETWORK_DRIVE_NAME`? – Trevor Boyd Smith Sep 15 '11 at 22:55
  • Not if you set the mount options correctly. Check the documentation provided by your filesystem. – Chris Down Sep 15 '11 at 23:28
  • "check the documentation provided by your filesystem" is not low-level enough for me to take a next-action on "how can you make mount not require sudo?"... – Trevor Boyd Smith Sep 16 '11 at 1:05
  • and... there's another question that you forced me to ask... unix.stackexchange.com/questions/20838/… lol. – Trevor Boyd Smith Sep 16 '11 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.