How to Find Logged-in User's Home Directory in Linux/Unix?

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

Navigate to the Home Directory and List the Current Directory

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

This post was 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. Please show your love and support by sharing this post.