You can find the home directory of the logged-in user in a Linux (or Unix) shell in the following ways:

You can navigate to the logged-in user's home directory by using any of the following commands:

cd
cd ~
cd $HOME

Once you're in the home directory, you can simply use the pwd (Print Working Directory) command to list the current working directory:

pwd

#Output the Value of the $HOME Environment Variable

You can simply print the value of the $HOME shell environment variable to output the name of the logged-in user's home directory, for example, like so:

echo $HOME

Published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing.