01. File Management and Manipulation
Overview¶
This document covers essential Linux commands used for:
-
Navigating directories
-
Managing files and folders
-
Viewing and modifying content
These are foundational for system administration, scripting, and cybersecurity tasks.
Directory Navigation¶
pwd — Present Working Directory¶
Explanation
Displays the full path of your current working directory.
cd — Change Directory¶
Explanation
Moves from the current directory to another specified directory.
Move Up Directory Levels¶
Explanation
-
..→ move up one level -
../..→ move up two levels -
Continue pattern as needed
Special Navigation Paths¶
- Takes you to the home directory
- Takes you to the root directory
Listing Directory Contents¶
ls — List Files¶
Explanation
Displays files and directories in the current location.
ls -l — Detailed List¶
Shows
-
File type (file/directory)
-
Permissions
-
Number of links
-
Owner and group
-
File size
-
Last modified date
-
File name
ls -a — Show Hidden Files¶
Explanation
Includes hidden files (those starting with .)
ls -la — Detailed + Hidden¶
Explanation
Combines -l and -a for full visibility.
ls -lh — Human Readable Sizes¶
Explanation
Displays sizes in KB, MB, GB instead of bytes.
ls -lR — Recursive Listing¶
Explanation
Lists all files and subdirectories recursively.
File Handling¶
touch — Create File¶
Explanation
Creates an empty file if it does not exist.
file — Identify File Type¶
Examples Output
-
ASCII text
-
ELF binary
-
Shell script
Check Multiple Files¶
Viewing and Writing Content¶
echo — Print Text¶
Write to File (Overwrite)¶
Explanation
>overwrites existing content
Append to File¶
Explanation
>>adds content without deleting existing data
cat — View File Content¶
Create File Using cat¶
(Type content → Press CTRL + D to save)
Copy File Content¶
Append Using cat¶
Directory Management¶
mkdir — Create Directory¶
File and Directory Operations¶
cp — Copy Files¶
Explanation
Copies a file to another location.
mv — Move or Rename¶
Move File¶
Rename File¶
rm — Remove File¶
rmdir — Remove Empty Directory¶
rm -r — Remove Directory Recursively¶
rm -rf — Force Remove¶
Important Warning
-
Deletes files/directories without confirmation
-
Use carefully, especially in production or pentesting environments
System Information¶
whatis — Command Description¶
Explanation
Displays a short description of a command.
Important Notes¶
-
Linux is case-sensitive
-
Always verify paths before deletion
-
Use
lsbefore running destructive commands -
Prefer backups (
cp) before modifying files
Summary Table¶
| Command | Purpose |
|---|---|
pwd |
Show current directory |
ls |
List files |
cd |
Change directory |
touch |
Create file |
cat |
View file content |
echo |
Print/write text |
mkdir |
Create directory |
cp |
Copy files |
mv |
Move/Rename files |
rm |
Delete file |
rmdir |
Delete empty directory |
file |
Identify file type |
whatis |
Show command description |
Conclusion¶
These commands are the core foundation of Linux usage. They are heavily used in:
-
Shell scripting
-
DevOps workflows
-
Cybersecurity and penetration testing
Mastering them improves speed, efficiency, and control over any Linux-based environment.