How is tilde used in commands?

QuestionsQuestions8 SkillsProBasic Files OperationsAug, 22 2025
0122

The tilde ~ can be used in commands to represent the current user's home directory. Here are a few examples:

  1. Navigating to the home directory:

    cd ~
  2. Accessing a file in the home directory:

    cat ~/file.txt
  3. Creating a directory in the home directory:

    mkdir ~/new_directory
  4. 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.

0 Comments

no data
Be the first to share your comment!