how to set command auto run when start PC- Linux

 To set a command to automatically run when the Linux system starts using systemctl,

you can create a new service file for the command and then enable it.

how to set command auto run when start PC- Linux

  1. Create a new file in the /etc/systemd/system/ directory, for example, filezilla-server.service.
  2. Add the following content to the file, replacing /path/to/command with the actual path to the command you want to run:
------------------------------------------
[Unit]
Description=FileZilla Server

[Service]
ExecStart=/usr/bin/filezilla-server
Restart=always
User=root

[Install]
WantedBy=multi-user.target

--------------------------------------------------------
  1. Run the following command to reload the systemd configuration: sudo systemctl daemon-reload
  2. Start the service with the following command: sudo systemctl start filezilla-server.service
  3. Enable the service to start at boot with: sudo systemctl enable filezilla-server.service

Now the filezilla-server will start automatically on system boot.


This is a Common structure for apply any application

To set a command to automatically run when the Linux system starts, you can create a new service file for the command and then enable it using systemctl, or you can create a new script and add it to the system's init or systemd startup scripts.

  1. Create a new file in the /etc/systemd/system/ directory, for example, mycommand.service.
  2. Add the following content to the file, replacing /path/to/command with the actual path to the command you want to run:
[Unit] Description=My Command [Service] ExecStart=/path/to/command Restart=always User=root [Install] WantedBy=multi-user.target


  1. Run the following command to reload the systemd configuration: sudo systemctl daemon-reload
  2. Start the service with the following command: sudo systemctl start mycommand.service
  3. Enable the service to start at boot with: sudo systemctl enable mycommand.service

Another way to do it is,

  1. Create a new script in the /etc/init.d/ directory, for example, mycommand.
  2. Add the command you want to run in the script.
  3. Make the script executable: sudo chmod +x /etc/init.d/mycommand
  4. Add the script to the system's init or systemd startup scripts: sudo update-rc.d mycommand defaults

Now the command will start automatically on system boot.


Hope you got the solution. you can apply this way for any softwaer auto open on ubuntu if not understand any part then message us we will help you

Thank you


Post a Comment

0 Comments