Login Items / Auto Start when Login

Dear All

What is the best way to launch a Script on the login ?

I have some rclone mounts ie some .sh files that I want to start when the machine logs in


Do you mean login of a user, or when the system boots?

You can do either, but, the methods are vastly different based on what you actually want.

Lovely !

I was thinking as a user ?

But both would be educational :slight_smile:

Dear Auke,

Am I right by making a profile.d folder and placing the scripts in there ? For scripts when the user logs in ?

They are called systemd units.

You can create user systemd unit using

mkdir  -p ~/.config/systemd/user/

here there is an example of a unit:

$ cat ~/.config/systemd/user/example1.service 
Description=Example description



Then enable it to run when you login

systemctl --user enable example.service

if you want to execute a user script when the system boots then

sudo mkdir -p /etc/systemd/system/

and the service unit is

$ cat /etc/systemd/system/example2.service 
Description=Example 2



to enable run:

sudo systemctl enable example2.service

you can find more information searching for systemd units.

Or the traditional way

adding your scripts to ~/.bashrc

Perfect !

Thank you guys for confirming nice and easy to follow