How to add .service file in Ubuntu? Write the my-server.service file name with the following content: [Unit] Description=Some description about the app. [Service] User=www-data Group=www-data WorkingDirectory=/home/ubuntu ExecStart=/home/ubuntu/my-server Environment="HOST=8080" Environment="PORT=3001" [Install] WantedBy=multi-user.target Add the my-server.service file in the following path: /etc/systemd/system/my-server.service Now you can stop/start/restart the service as follows: $ sudo systemctl start my-server.service $ sudo systemctl stop my-server.service $ sudo systemctl restart my-server.service