0

I execute a command on boot, before logging in, by adding it to my

/etc/lightdm/lightdm.conf.d/50-ubuntu.conf

file under [SeatDefaults].

The program executes but is unable to locate a necessary file in my home directory, which makes sense as it doesn't know which home directory to look in.

So, where can I put the file so the script is able to locate it? What is the value of ~ when the program is running?

This is a reformulation of Start Synergy client with SSL before login Ubuntu 16.04 LTS, in the hope of this question being easier to answer.

cygnus_x1
  • 102
Atnas
  • 105
  • I guess It should be /root . – Ravexina Sep 24 '17 at 17:57
  • Oh, just /root instead of /home/root? – Atnas Sep 24 '17 at 18:05
  • Depends on the user running the shell and the environment. Some shells , chron for example, it is unset. Because it is ambiguous I highly advise you use the full path in scripts. If you call it more than once, set a variable. – Panther Sep 24 '17 at 18:26
  • 1
    @Atnas, root's home directory is /root, not /home/root because historically it was typical to have /home on a separate disk and/or filesystem so if you needed to boot into rescue mode with no other filesystems mounted, root's home directory needed to be in the root filesystem. – psusi Sep 25 '17 at 00:30

1 Answers1

1

It would be easier just to manually specify the absolute path (using no relative symbols like ~) for the script.

Instead of declaring the location as ~/path/to/program.sh, make it /home/username/path/to/program/sh.


Edit: If you don't have the ability to change the defined path, the ~ location is /root by default. You can move your script to this path with

sudo mv ~/path/to/program.sh /root/
dessert
  • 39,982
cygnus_x1
  • 102
  • I'm not defining the path myself, but running a piece of software that looks for it's settings in the home directory, so this won't work. Can I edit my question to make this clearer? – Atnas Sep 24 '17 at 18:02
  • Ah okay then it is most likely /root (not /home/root -- the default is different for the root account) -- as you can see for yourself by running echo $HOME as root – cygnus_x1 Sep 24 '17 at 18:06
  • 1
    @Atnas Sure you can edit your question, please do so! – dessert Sep 24 '17 at 18:13
  • 1
    I will test this on my machine tomorrow, and accept the answer if it works. – Atnas Sep 24 '17 at 18:45