Linux / Unix Shell Script: Get Current User Name
You can get the current user name in a Linux or Unix shell script by using the whoami command or by accessing the $USER environment variable.
Here’s an example using the whoami command:
#!/bin/bashcurrent_user=$(whoami)
echo "The current user is: $current_user"And here’s an example using the $USER environment variable:
#!/bin/bashcurrent_user=$USER
echo "The current user is: $current_user"Both of these methods will return the username of the user running the script.
n(Clonazepam)