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

Find Logged-in user's home directory in *-nix

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 $HOME

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


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

Hope you found this post useful. It was published . Please show your love and support by sharing this post.