This guide explains how to set file permissions, change ownership, and remove content using chmod
, chown
, and rm
commands.
β Set Permissions on All Directories Under a Folder
Task: Set permissions on all directories under /usr/home/username/server1/
to 755
.
chmod -R 755 /usr/home/username/server1/
-R
: Applies recursively to all files and folders.755
: Grants full access to owner, and read-execute to group and others.
β Remove All Data From a Folder
Task: Remove all files and directories under /usr/home/username/server1/
.
rm -rf /usr/home/username/server1/*
-r
: Recursively removes directories.-f
: Forces deletion without prompting.
β οΈ Caution: Double-check the path before running to avoid accidental data loss.
π€ Set Ownership of All Files and Directories
Task: Set the user and group to example:example
for everything under /home/username/public_html/test/accounts
.
chown -R example:example /home/username/public_html/test/accounts
-R
: Applies recursively.example:example
: Format isuser:group
.
β Summary of Commands
Action | Command |
---|---|
Set permissions to 755 | chmod -R 755 /usr/home/username/server1/ |
Remove all data | rm -rf /usr/home/username/server1/* |
Change owner and group | chown -R example:example /home/username/public_html/test/accounts |
Let me know if you’d like a version tailored for specific user or group setups, or for a cron-based automation.