I have an executable file say myserver
. I always run it by appending ./
infront of file name in debian 10 terminal. e.g. ./myserver
. I am wondering if there are other ways to execute/run this file apart from using ./
.
Note: file
commands shows the following information about my file.
file myserver
myserver: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=82wr8_Xx7EP7lh6rXfs4/w6MXLU_08grWoInEvoEg/im3xy25cSUGiNkWCWC6M/1IjwBIGip3ebxtcXy09u, stripped
I want to run this file automatically at boot since i am tired of typing ./myserver
in the terminal every times my machine reboots. Since it is binary file and not a service, so i setup a system service using systemd
with the following contents.
[Unit]
Description=myserver
After=network-online.target
[Service]
ExecStart=./myserver
WorkingDirectory=/home/sahar
StandardOutput=inherit
StandardError=inherit
Restart=always
User=sahar
[Install]
WantedBy=multi-user.target
However i am getting the following error.
● myserver.service - myserver
Loaded: bad-setting (Reason: Unit myserver.service has a bad unit file setting.)
Active: inactive (dead)
systemd[1]: /etc/systemd/system/myserver.service:6: Neither a valid executable name nor an absolute path: ./myserver
systemd[1]: myserver.service: Unit configuration has fatal error, unit will not be started.
Does this error means I can not execute the file now using ./
? I have tried it with bash myserver
and sh myserver
but no luck.
Any solution is appreciated.
Regards, Sahar
In Linux . refers to the current directory you are working in. ./name_of_some_program
gives the relative path to that program. You can check your current/present working directory with pwd
command.
If your current working directory is /home/machine and you have a file in that directory you wanna execute. Let the name of that file be A. You give the path of that file to shell. You can either do ./A
or /home/machine/A
. The latter is called absolute path.
So, in systemd
service file you need to mention absolute path not relative.
Give the value of absolute path to Execstart
key.