Can `~` be used in file paths?

QuestionsQuestions8 SkillsProDec, 17 2025
0122

That's a great question!

Yes, the ~ symbol can absolutely be used in file paths. It's a very convenient shortcut in Linux (and Unix-like systems) that represents the current user's home directory.

For example:

  • If your home directory is /home/labex, then ~/Documents would resolve to /home/labex/Documents.
  • You could use cp ~/my_file.txt . to copy my_file.txt from your home directory to your current directory.
  • Similarly, ls ~/ lists the contents of your home directory, as you saw in the current step.

It's a powerful tool for navigating and referencing files relative to your home directory without having to type out the full path every time.

Does that clarify things for you?

0 Comments

no data
Be the first to share your comment!