Practical Folder Management
Creating and Removing Directories
Directory Creation Commands
## Create a single directory
$ mkdir projects
## Create multiple directories
$ mkdir -p work/frontend/src
## Create directories with specific permissions
$ mkdir -m 755 shared_folder
Directory Removal Techniques
## Remove an empty directory
$ rmdir documents
## Remove directory and its contents
$ rm -r old_project
## Remove directory forcefully
$ rm -rf temporary_files
Copying and Moving Directories
Directory Manipulation Commands
Command |
Function |
Example |
cp |
Copy directories |
cp -r source_dir destination_dir |
mv |
Move/Rename directories |
mv old_name new_name |
Advanced Copying Strategies
## Preserve metadata while copying
$ cp -rp source_directory destination
## Interactive copy with confirmation
$ cp -ri documents/ backup/
Searching and Locating Directories
graph LR
A[Search Methods] --> B[find]
A --> C[locate]
A --> D[whereis]
Search Command Examples
## Find directories by name
$ find / -type d -name "project*"
## Find directories modified in last 7 days
$ find /home -type d -mtime -7
## Locate directories quickly
$ locate -b '\project'
Permissions and Ownership Management
Changing Directory Permissions
## Change directory permissions
$ chmod 755 project_folder
## Change ownership
$ chown user:group directory_name
Permission Types
Permission |
Numeric Value |
Meaning |
r (Read) |
4 |
View directory contents |
w (Write) |
2 |
Create/delete files |
x (Execute) |
1 |
Access directory |
Disk Usage and Management
## Check directory size
$ du -sh project_folder
## List disk usage
$ df -h
LabEx Practice Environment
LabEx provides an interactive platform for learners to experiment with these folder management techniques, offering a safe and comprehensive learning experience in Linux directory operations.