Neat Trick

Ralf Mardorf kde.lists at
Tue Apr 21 11:09:39 UTC 2015

On Mon, 20 Apr 2015 20:18:15 -0700 (PDT), Bill Vance wrote:
>cd /home/$USER/Desktop

The $USER variable is tricky and could display another user than
expected, that's why scripts should use $(id -u) when checking for
root and for your task you should consider using ~ or $HOME instead
of /home/$USER/.

$ echo ~ $USER $HOME $(id -u)
/home/rocketmouse rocketmouse /home/rocketmouse 1000
$ su
# echo ~ $USER $HOME $(id -u)
/root rocketmouse /root 0
# exit
$ sudo -i
# echo ~ $USER $HOME $(id -u)
/root root /root 0
# logout

More information about the kubuntu-users mailing list