Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Does any configuration file exist for virtual console, when a user logins in it which is read and executed ?

My requirement: To execute some shell commands when a user logins using the virtual console.

share|improve this question

2 Answers 2

If any user logs in using bash, the commands in /etc/profile are executed. There you can check if the login was from a virtual console (and not from a terminal after logging in the GUI) and take action based on that.

You can e.g test on $TERM equalling linux, or on not having $WINDOWID.

If you need this only for some users, you can put the actions in their ~/.bash_login as well, but you would have to trust them not to change that part of that file after logging in. With /etc/profile you don't normally have that problem (and if the user has root access there is little you can do anyway). But you can have the action check for the id of the user logging in and take action or not based on that.

share|improve this answer
up vote 0 down vote accepted

Putting the configuration in ~/.bash_profile works. Another option is putting the configuration in ~/.profile, but this file will be ignored if ~/.bash_profile file already exists in the filesystem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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