Linux: Autostarting Commands in bash at Login

Practice



Task: make it so that immediately after a successful login to a Linux OS with the BASH interpreter, the user has specified scripts or commands run automatically. In other words, create a kind of autostart (or autorun) in Linux.

In Bash, this is done using the .bash_login file, located in the user's home directory. The file looks similar to a script, except that it doesn't need a "#!/bin/bash" line and doesn't need to be made executable with chmod +x.

For example, the following .bash_login file will clear the screen and run the "myscript.sh" script right after the user logs in:

.bash_login:
clear
./myscript.sh

You can create your own autostart scenarios following this pattern.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "LINUX operating system"

Terms: LINUX operating system