Friday, May 3, 2024
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 53929  / 2 Years ago, wed, september 7, 2022, 10:25:49

For example, what would it mean to say:




cd ~/mydirectory



More From » command-line

 Answers
5

~ is a shortcut for the home directory, so



cd ~/mydirectory 


Will move to mydirectory if there is such a directory in your home folder, otherwise it will throw a directory does not exist error.



Example:



enter image description here



Your home directory is located at /home/<username>.



Trivia: This is why the default bash prompt has a tilde in it like this user@host:~$. The tilde indicates that you are currently in your home directory. If you move somewhere else, for example into /etc it will show user@host:/etc$.


[#27108] Thursday, September 8, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
suitman

Total Points: 487
Total Questions: 105
Total Answers: 98

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
;