LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 07-27-2012, 12:49 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,125

Rep: Reputation: 46
/etc/profile: does it get executed each time a user logins?


Hi:
What's asked.
 
Old 07-27-2012, 01:04 AM   #2
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 2,434

Rep: Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867
yes, see the Shell initialization files in the bash guide.

Last edited by ponce; 07-27-2012 at 01:20 AM.
 
Old 07-27-2012, 01:06 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
That depends on how the user logs in ([non-]interactive / [non-]login).

Have a look at the INVOCATION section in the bash man page for the details.
 
Old 07-27-2012, 01:22 AM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,125

Original Poster
Rep: Reputation: 46
[To druuna:
I login as an interactive login shell. I first turn on the machine, after a while the system prompts me to enter username and password (console). Then I press Alt-F2 and am prompted again. All these are interactive login shells, I think.
]

Then, each time a user logs in a console /etc/profile executes. In /etc/profile I have writen:

( setsid /kbd_monitor /dev/input/event1 </dev/null &>/tmp/input.log & )

When profile is executed the first time after booting, no problem. But if I afterwards login in another console as a regular user, I get;

Bash: /tmp/input.log: permission denied

Where can I put the above line so that I don't have to type it every time I boot?
 
Old 07-27-2012, 01:33 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by stf92 View Post
[To druuna:
I login as an interactive login shell. I first turn on the machine, after a while the system prompts me to enter username and password (console). Then I press Alt-F2 and am prompted again. All these are interactive login shells, I think.
]

Then, each time a user logs in a console /etc/profile executes. In /etc/profile I have writen:

( setsid /kbd_monitor /dev/input/event1 </dev/null &>/tmp/input.log & )

When profile is executed the first time after booting, no problem. But if I afterwards login in another console as a regular user, I get;

Bash: /tmp/input.log: permission denied

Where can I put the above line so that I don't have to type it every time I boot?
This does describe an interactive login shell and thus /etc/profile is used. But....

After the first user logs in, /tmp/input.log exists and is owned by that user. Because of that a second (third...) user will not be able to use/create /tmp/input.log.

The UID should already be known at this point, try changing &>/tmp/input.log & to &>/tmp/input.${UID}.log &. I'm not sure what happens if the same user logs in twice (or more). You might need to check if the file already exists and skip the entire command if so (I do assume that /tmp is cleaned when (re)booting).

To be honest; I'm not sure if that command needs to go in /etc/profile. I'm not familiar with what that command does, maybe you can put it in ~/.profile instead and store the log file in the users home directory?

Last edited by druuna; 07-27-2012 at 01:34 AM.
 
Old 07-27-2012, 01:46 AM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,125

Original Poster
Rep: Reputation: 46
Yes, I think I'll put it in ~/.profile, but create it in /tmp. This way the file will be owned by a regular user and root will be able to write to it.

kbd_monitor simple watches the keyboard and receives a signal each time a key is pressed. It then measures the time intervals between successive keystrokes. When I wake in the morning, I go to the machine, look into input.log and can determine the time when I went to bed. Really simple. The thing is that I am constantly change console. One time I am in VT3 and the next time I may be in VT5 or VT1, root's console.
 
Old 07-27-2012, 02:18 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by stf92 View Post
Yes, I think I'll put it in ~/.profile, but create it in /tmp. This way the file will be owned by a regular user and root will be able to write to it.

kbd_monitor simple watches the keyboard and receives a signal each time a key is pressed.
Wouldn't it be a better idea to just start this command once, at boot time?

I'm not a Slackware user, but I do believe it uses the /etc/rc.local file. Why not put it in there?
 
1 members found this post helpful.
Old 07-27-2012, 02:56 AM   #8
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,125

Original Poster
Rep: Reputation: 46
You are right. But I've already put it in there and it doesn't get executed. ps doesn't find it. However I have there other commands, like hdparm, and these get executed.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
.profile not being executed when running xbmc-live schneidz Linux - General 0 03-28-2011 03:00 PM
Problem getting user logins and guest users to work at the same time using Samba juliushibert Linux - Server 0 07-20-2010 06:28 AM
/etc/profile not getting executed on RHEL5 box kk2202 Red Hat 1 09-29-2009 07:21 AM
/etc/profile executed twice after login sureshlohith Linux - Newbie 11 05-10-2009 09:54 PM
Gnome multiple logins/shared profile djmurf Linux - General 2 11-30-2002 12:00 PM


All times are GMT -5. The time now is 03:52 PM.

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