The Linux file system may seem different from Windows or macOS, but it's straightforward once you understand the basics. This guide covers essential terminal commands for navigating directories, managing files, and understanding the file system structure.
How to Navigate the Linux File System
-
Step 1: Open Terminal
Most file system navigation and management tasks are done through the terminal. Open it by searching for "Terminal" in the application menu.
-
Step 2: Check Your Current Directory
To know your current directory, use the
pwdcommand (print working directory).pwd -
Step 3: List Files and Directories
Use the
lscommand to list files and directories in the current location.ls -
Step 4: Change Directory
Move to a different directory using the
cdcommand.cd /path/to/directoryTo return to your home directory:
cd ~To move up one level in the directory tree:
cd .. -
Step 5: Understand Absolute vs. Relative Paths
An absolute path starts from the root directory (
/), while a relative path is relative to your current location. For example:- Absolute path:
/home/username/Documents - Relative path:
Documents(assuming you are already in/home/username)
- Absolute path:
-
Step 6: Create a Directory
Make a new directory using the
mkdircommand.mkdir new_directory -
Step 7: Remove Files and Directories
Delete a file with the
rmcommand and a directory with thermdircommand.rm filename rmdir directoryname -
Step 8: Copy and Move Files
Copy files or directories using
cpand move them usingmv.cp source destination mv source destination -
Step 9: Change File Permissions
Use
chmodto change file permissions.chmod permissions filename -
Step 10: View File Content
Use
catto display the entire content of a file.cat filename -
Step 11: Edit Files
Use text editors like
nano,vim, orgeditto edit files.nano filename -
Step 12: Find Files
Use
findto search for files in the file system.find / -name filename -
Step 13: Use Wildcards
Use wildcards like
*and?for matching multiple files or characters.ls *.txt # List all files with a .txt extension