LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-25-2004, 04:47 PM   #1
Jake_da_Snake
LQ Newbie
 
Registered: Jan 2004
Posts: 23

Rep: Reputation: 15
Mounting Windows NT shared folders for individual users


I am using redhat 9.0 and suse 8.2. I am trying to mount windows NT shared folders on start up. I have four users. I used the following line on fstab.
//windowsNt/shared /linux/mount smbfs username=username,password=password 0 0
It works but it mounts the folders on start up for all users. I only want 2 of my users to be able to mount windows NT shared folders.
Is there a fstab file for individual users, or any other way to mount shared folders for specified users?\
 
Old 02-25-2004, 06:46 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I'm assuming that you want to allow 2 linux users to be able to access the samba NTFS share. Look up in man mount. There are options listed for smb mounts. The option that you want to add is gid=xxx. Make a new group for that purpose of sharing the NTFS share, and make those two users members of that group. You can enter the group name instead of the gid number in the fstab entry. Remember to make the new group before you add the gid= option.
 
Old 02-26-2004, 08:40 PM   #3
Jake_da_Snake
LQ Newbie
 
Registered: Jan 2004
Posts: 23

Original Poster
Rep: Reputation: 15
Did that, and it didn't work. But it's a neat feauture though.
What I want to acheive is to mount NT shared folders for 2 users only. For instance I have four users. user1, user2, user3, and user4. I want the shared folders to be mounted when user1 and user2 log in, but I dont want it to be mounted when user3,4 log in.
What I thought I could do was to put them in .bash_profile or .bashrc of specific user, so they'd run everytime that user logged on. had no luck on that yet. I dont think that's possible anyway. A start-up file or something for individual users is pretty much what I had in mind.
 
Old 02-26-2004, 09:57 PM   #4
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
well i dont think that putting the mount command in the user .bashrc file would not work....It should if you give it the right options like:
. mount -t smbfs .........

put this somewhere in your .bashrc and i think it should work.
bettre still you could put the entry in fstab and then just do a mount in .bashrc.
play around with it...i am sure this would work...oh only if i had a windows network to test this out....but i am much more happy without one...
 
Old 02-26-2004, 11:35 PM   #5
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
yup...putting a script in .bashrc will work.i wrote this script:
Code:
#!/bin/bash
iam=`whoami`
if [ $iam = rmanocha ];then
        mount /dev/hda3 2>/dev/null
fi
and put in /etc/profile
and it works just fine...if the dev is already mounted then the error message will go to /dev/null else...it will mount this device.
I havent figured out how to umount it when i log out but i guess you can look into that.
hope this helped.
 
Old 02-27-2004, 11:19 PM   #6
Jake_da_Snake
LQ Newbie
 
Registered: Jan 2004
Posts: 23

Original Poster
Rep: Reputation: 15
That looks like a great idea, but I'm bot very familiar with linux scripting, so if
you could be a little more specific, that would be great.

code:
#!/bin/bash
iam=`whoami`
if [ $iam = rmanocha ];then
mount /dev/hda3 2>/dev/null
fi


code:
#!/bin/bash:::: I suppose thiz 2 lines just should be there?

iam=`whoami` :::: I have no idea what this line does

[ $iam = rmanocha ] :::same goes for this line.

Assuming that I have 3 users. linuxuser1, linuxuser2 and linuxuser3. How would I mount
windows nt shared folders for linuxuser1?

eventhough I was trying to avoid fstab I put the following line in fstab just to see
what would happen.
//windowsNT/shared /shared smbfs username=username,password=password,noauto

then I used the .bashrc to mount that folder for linuxuser1

code:
#!/bin/bash
iam=`whoami`
if [ $iam = rmanocha ];then
mount /shared 2>/dev/null
fi
no luck
I couldn't even mount that from command prompt. I had to log on as root first.

Please Advice.
By the way I think u can unmount devices when u log out by using .bashlogout.
 
Old 02-28-2004, 02:12 AM   #7
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
Quote:
Originally posted by Jake_da_Snake
code:
#!/bin/bash:::: I suppose thiz 2 lines just should be there?
This line has to be there since it is telling that bash will be used for interpreting this program(if you use other shells then you should look into those.

Quote:
iam=`whoami` :::: I have no idea what this line does
the whoami command basically tells you which user is running the current session...so like my user name under my linux box is rmanocha...so if i type whoami on the command line...i get back rmanocha.I store this value in a variable called iam.the "`" you see around the command is only to tell bash that you are supposed to execute this command.This is how i store who is using the current session into a variable..i could have probably used this in the if statement too but i am like that.

Quote:
if[ $iam = rmanocha ];then :::same goes for this line.
This line is basically like any other if statment in C/C++/JAVA etc.i am only checking who is the current user....my current user name is stored in iam and then i compare the value in i am with rmanocha(the user who should be able to mount the share).If this statement is true...that is if iam holds 'rmanocha' then go onto the next statement else just finish the program.

Quote:
Assuming that I have 3 users. linuxuser1, linuxuser2 and linuxuser3. How would I mount
windows nt shared folders for linuxuser1?
all you will have to do is write a if statement with something like this:
Code:
if [ $iam = linuxuser1 || $iam = linuxuser2 || $iam = linuxuser3 ];then
                        mount blah(put whatever it is you want to mount here) > /dev/null
Quote:
eventhough I was trying to avoid fstab I put the following line in fstab just to see
what would happen.
//windowsNT/shared /shared smbfs username=username,password=password,noauto
Even though i dont know much about samba(never really used it too much) i would say that maybe going with smbmount in the file we are writing could be a better solution.anyways...if the above fstab entry is correct...then there is still one problem you will run into.you are saying noauto...which means that this share will not be mounted automatically on boot(well to come to think of it...maybe you dont want to mount it when the machine boots...only when someone logs out...so i guess you can suit yourself). another thing you might want to add to this line is user so your fstab entry should look something like this:
Code:
//windowsNT/shared /shared smbfs username=username,password=password,noauto,user
This migh become easier if you actually look into the docs of smbmount and see if you can mount the shares using that program.

what you should have is this:
Code:
#!/bin/bash
iam=`whoami`
if [ $iam = linuxuser1 ];then
              mount /shared 2>/dev/null
fi
this should mount the shares just fine as described through fstab.the "2>/dev/null' is only to not display any error messages that this program may produce...since .bashrc is executed everytmie a shell will open hence the share might already be mounted when the user opens another shell and this will create a error message from mount.to get rid of that message you put it to /dev/null

hope this helps.let me know if it does.
a good site to learn bash programming is here
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cant get linux to go into windows shared folders kamowa Linux - Networking 4 09-22-2005 12:02 PM
Samba not accessing my Windows Shared folders Felpipe Linux - Networking 3 08-04-2005 08:34 AM
Accessing windows shared folders in linux srivatsava Linux - Networking 1 09-29-2004 03:01 PM
can't see shared printer/files/folders on windows noorania Linux - Networking 0 11-12-2003 06:18 PM
Can't find Windows XP shared folders eRacer Linux - Networking 0 08-13-2002 04:33 PM


All times are GMT -5. The time now is 05:26 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration