Find Your Way $HOME in Bash

• 1 min read

Today I learned a shorter way to navigate to my home directory while in a Bash terminal. According to this page, when the cd command doesn’t receive any parameters it defaults to $HOME. How convenient is that?! In fact, there are four ways to get to your home directory:

# These are equivalent

cd                  # Defaults to $HOME
cd ~                # Current user's home dir
cd ~$USER           # Given user's home dir
cd /home/$USER/     # Full path

Up until this time I have been using cd ~ exclusively, but now I can switch to cd and knock off two whole characters!

If you enjoyed this tutorial, please consider sponsoring my work on GitHub ðŸĪ—

Be the first to cheers
Now look what you've done 🌋
Stop clicking and run for your life! ðŸ˜ą
Uh oh, I don't think the system can't handle it! ðŸ”Ĩ
Stop it, you're too kind 😄
Thanks for the love! âĪïļ
Thanks, glad you enjoyed it! Care to share?
Hacker News Reddit

×

Recommended Posts ✍ðŸŧ

See All »
• 3 min read
🚅 Next Stop, Yaak
Read Post »
• 3 min read
⛰ïļ 2022 Recap: Getting Physical
Read Post »
• 5 min read
ðŸŠī Home-Grown Web Analytics
Read Post »