Answer by Keith Thompson for Environment Variable for Username
As the other answers say, $USER is usually set to the name of the current user account.But at least on my system (Ubuntu 14.04) the $USER environment variable is not set for cron jobs. Instead, you can...
View ArticleAnswer by Byte Commander for Environment Variable for Username
There might be a caveat if you plan to read the $USER environment variable in a command starting with sudo. Bash variable expansion takes place before executing sudo to switch users, that means the...
View ArticleAnswer by Arronical for Environment Variable for Username
The Linux version environment variable to refer to the current user is USER.To get the output you'd like to see use $USER in your command: echo $USERAnd to use it in another string such as a...
View ArticleAnswer by Rinzwind for Environment Variable for Username
$USERwill change it into your username.Examplerinzwind@schijfwereld:~$ echo $USERrinzwindThere are more...~$ cd /tmp:/tmp$ echo $HOME/home/rinzwind:/tmp$ echo $PWD/tmp$ echo $HOSTNAMEschijfwereldTo...
View ArticleEnvironment Variable for Username
What is the Linux equivalent of %username%?I need to run a script on multiple Linux boxes every few days. I made a .sh file, and it works fine. The script deletes some files at a certain path. Problem...
View Article