The tilde ~ can be used in commands to represent the current user's home directory. Here are a few examples:
-
Navigating to the home directory:
cd ~ -
Accessing a file in the home directory:
cat ~/file.txt -
Creating a directory in the home directory:
mkdir ~/new_directory -
Copying a file to the home directory:
cp /path/to/file.txt ~/
In these examples, ~ acts as a shortcut to avoid typing the full path to the home directory.
