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:
-
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)
-
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
-
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
-
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
-
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
-
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?