Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
|
11-12-2002, 02:42 AM
|
#1
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Rep:
|
Scripts
Is there a way to run a script when a user logs in and when they log out?
|
|
|
11-12-2002, 02:49 AM
|
#2
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
login
/home/user/.bashrc
logout
/home/user/.bash_logout
|
|
|
11-12-2002, 07:54 AM
|
#3
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Original Poster
Rep:
|
"/home/user/.bashrc" works, but every time I click on a new terminal window in the X Manager it runs the script, giving me an error that the partitions are already mounted. (basically when I log in with my user I want to mount two partitions, I would use the "auto" switch in my fstab, but it would give it root permissions, no r/w access).
|
|
|
11-12-2002, 08:13 AM
|
#4
|
Member
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334
Rep:
|
The right place is fstab, but to have permissons you should use chmod, try chmod 777 _mount_point_ ....
If you just don't wanna see the error add to your line a 2> /dev/null ... ( not a very wise choise )
|
|
|
11-12-2002, 11:50 AM
|
#5
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
or you could check to see if they are already mounted in your script
I can't see why they just can't stay mounted though.
As Vladkrak says set the permissions on the files and folders
you should make the permissions 770 or 774 whatever you need, and create a group for users that should have access
Last edited by DavidPhillips; 11-12-2002 at 11:54 AM.
|
|
|
11-12-2002, 12:29 PM
|
#6
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Original Poster
Rep:
|
I did this, as soon as they are automounted by fstab, only root has r/w permissions. I verified this by doing a search on the web on fstab. So, how would I check to see if they are mounted in the script? Or is there a script that ONLY runs when the user logs in?
|
|
|
11-12-2002, 12:38 PM
|
#7
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
that is what file permissions is for
if you had to use mount to set file permissions it would not be a nice world at all
chmod is a program for setting file permissions
you can give the owner, user, and other permissions for read, write, and execute
chown is for setting the owner and group of a file.
|
|
|
11-12-2002, 12:41 PM
|
#8
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Original Poster
Rep:
|
Again, I tried this, as soon as it's mounted it changes the permissions and ownership to root. In fact I'll try it right now and repost if it works or not. After all, stranger things have happened.
|
|
|
11-12-2002, 12:53 PM
|
#9
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
what filesystem is on the partition?
|
|
|
11-12-2002, 12:58 PM
|
#10
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Original Poster
Rep:
|
vfat
|
|
|
11-12-2002, 01:12 PM
|
#11
|
Member
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334
Rep:
|
There shouldn't have problems to change permissons, as Dave just said, but if you wan't to take the other way, just add to your script something like:
mount | grep hdx > /dev/null
if [ $? == 1 ] ; then
(your mount line)
fi
ps hdx is the name of your partition ....
|
|
|
11-12-2002, 01:25 PM
|
#12
|
Member
Registered: Aug 2002
Location: Hickville, TN
Distribution: Gentoo > current. Have used: Red Hat 7.3, 9, Gentoo 1.4
Posts: 400
Original Poster
Rep:
|
Ohhh, pretty code! What does it mean?
|
|
|
11-12-2002, 01:26 PM
|
#13
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
I should have guessed,
use fstab to mount it like this for full permissions, adjust as needed
/dev/hda1 /win32 vfat exec,dev,suid,rw,conv=auto,uid=99,gid=99,umask=0 0 0
|
|
|
11-12-2002, 01:31 PM
|
#14
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
note that uid is set to nobody
also umask is sort of a reversed chmod
umask=007 is like chmod 770
|
|
|
11-12-2002, 01:36 PM
|
#15
|
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163
Rep:
|
vladkrack's code will check for the drive using mount ( your drive is represented as hdx )
|
|
|
All times are GMT -5. The time now is 11:07 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|