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)/DesktopThe 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?
4 Answers
The command you were looking for is whoami.
You're probably just looking for cd ~/Desktop.
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
who is the command for you which is a shortform for whoami