How to find the username in Bash?
12,419
Solution 1
The command you were looking for is whoami
.
Solution 2
You're probably just looking for cd ~/Desktop
.
Related videos on Youtube
Author by
jokerdino
I am part of the team behind developing Unity Tweak Tool. http://about.me/jokerdino Fake edit to test stuff.
Updated on September 18, 2022Comments
-
jokerdino over 1 year
I'm starting out on some Linux bash scripting and I'm trying to get the username so I can
cd
to that user's Desktop:cd /home/$(user I'm currently using)/Desktop
The code should be similar to the above to my understanding. What kind of terminal command would return just the name of the user I'm using?
-
max over 11 yearswho is not short form for whoami
who
shows who are all logged on the system(means in tty1,tty2 and so on)whoami
means who is currently using the system (who is running this command, it always shows your name only because you are running this command, if other person run this command then it will show his name) It always print single name.