How do I run a script after login?
- Create a script file, e.g. named my_file.sh , in the /etc/profile. d/ directory.
- Put #!/bin/bash as the first line.
- Write whatever command(s) you want to be executed immediately after logging in, e.g. pgrep udhcpd .
- Mark your file as executable: chmod +x /etc/profile.d/my_file.sh.
How do I get a script to run on startup Ubuntu?
The Ubuntu 20.04 is based on Systemd hence the simplest and recommended way to run a script on startup is to create a Systemd service file and execute any script such as bash, python etc, via this service during the system boot.
How do I run a script after user login authentication in Linux?
- Do you need to display anything in your script, or just to perform something in the background (e.g. send a notification)? You can add a log file where your script's output will be logged: session optional pam_exec.so log=/path/to/logfile /bin/bash /path/to/your/script.sh. ...
- I found this line un my /etc/pam.d/login .
How do I run a Linux script at startup?
There is more than one way to do this.
- Put the command in your crontab file. The crontab file in Linux is a daemon that performs user-edited tasks at specific times and events. ...
- Put a script containing the command in your /etc directory. Create a script such as "startup.sh" using your favorite text editor. ...
- Edit the /rc.