🐧 Linux / Shell Scripting
Beginner
What is the difference between / and ~ in Linux?
Answer
/ is the root directory — the top of the entire filesystem hierarchy. All files and directories on the system live under /. ~ is a shell shortcut for the current user's home directory, which is typically /home/username (or /root for the root user). Running cd / takes you to the system root, while cd ~ or just cd takes you to your personal home directory. In scripts, always use $HOME instead of ~ as tilde expansion is not guaranteed in all contexts.