Linux File Basics
File System Structure
Linux file system is organized hierarchically, starting from the root directory /
. Understanding this structure is crucial for effective file management.
graph TD
A[/ Root Directory] --> B[/bin System Binaries]
A --> C[/etc Configuration Files]
A --> D[/home User Directories]
A --> E[/var Variable Data]
Linux File Types
Linux supports multiple file types, each serving different purposes:
File Type |
Symbol |
Description |
Regular File |
- |
Standard data files |
Directory |
d |
Contains other files and directories |
Symbolic Link |
l |
Pointer to another file |
Block Device |
b |
Hardware block devices |
Character Device |
c |
Hardware character devices |
File Permissions
File permissions control access and actions on files:
## Check file permissions
ls -l example.txt
## Output: -rw-r--r-- 1 user group 1024 Jan 1 12:00 example.txt
Permission modes include:
- Read (r)
- Write (w)
- Execute (x)
Creating and Managing Files
## Create a new file
touch newfile.txt
## Copy file
cp sourcefile.txt destination.txt
## Move/Rename file
mv oldfile.txt newfile.txt
## Delete file
rm unwantedfile.txt
Executing Files
## Make file executable
chmod +x script.sh
## Execute script
./script.sh