In Bash, you can get the current user’s username using the whoami command or by accessing the $USER environment variable.
Method 1: Using whoami command
username=$(whoami)
echo $username
Method 2: Using $USER variable
echo $USER
Both methods will return the username of the currently logged-in user. The whoami command is often more reliable, especially if the script is run by a different user.