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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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
linux, or on not having
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.
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.