What other directory commands exist?

QuestionsQuestions8 SkillsProDec, 16 2025
0108

That's a great question! Besides pwd, there are several fundamental commands for navigating and managing directories in Linux. Knowing these will make your experience much smoother.

Here are some of the most common and essential directory commands:

  1. ls (list directory contents):

    • Purpose: Lists the files and subdirectories within a directory.
    • Example:
      ls
      ls -l   # long format, provides more details like permissions, owner, size, date
      ls -a   # includes hidden files (starting with a dot)
  2. cd (change directory):

    • Purpose: Allows you to move between different directories.
    • Example:
      cd /home/labex/project  # go to an absolute path
      cd my_folder            # go to a folder inside the current directory
      cd ..                   # go up one level to the parent directory
      cd ~                    # go to your home directory
      cd -                    # go back to the previous directory you were in
  3. mkdir (make directory):

    • Purpose: Creates new directories.
    • Example:
      mkdir new_directory
      mkdir -p path/to/new/directory # creates parent directories if they don't exist
  4. rmdir (remove directory):

    • Purpose: Removes empty directories.
    • Note: This command only works for empty directories. If a directory contains files or other directories, you'll need to use rm -r (remove recursively).
    • Example:
      rmdir empty_directory
  5. cp (copy files and directories):

    • Purpose: Copies files or entire directories.
    • Example:
      cp file.txt new_location/ # copy a file
      cp -r directory_to_copy new_location/ # copy a directory recursively
  6. mv (move or rename files and directories):

    • Purpose: Moves files or directories from one location to another, or renames them.
    • Example:
      mv file.txt new_location/ # move a file
      mv old_name.txt new_name.txt # rename a file
      mv old_dir new_location/ # move a directory

These commands form the backbone of directory management in Linux. You'll use them constantly as you work in the terminal!

Do you want to try out any of these commands or learn more about a specific one?

0 Comments

no data
Be the first to share your comment!