Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 21 '12 at 8:45

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 4 down vote accepted

The command you were looking for is whoami.

share|improve this answer
    
Cool, thanks this was useful! –  Mantas Aug 20 '12 at 12:32

See Here

[max@localhost ~]$ echo $USER

max

This will print the name of the user who currently logged in the terminal

[max@localhost ~]$ su -

Password:

[root@localhost ~]# echo $USER

root

share|improve this answer

who is the command for you which is a shortform for whoami

share|improve this answer
2  
who 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. –  max Aug 23 '12 at 11:01

You're probably just looking for cd ~/Desktop.

share|improve this answer
    
Thank you very much sir, was silly to miss that! –  Mantas Aug 20 '12 at 12:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.