πŸ“ Chmod, Chown & Remove Guide (Linux)

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 is user:group.

βœ… Summary of Commands

ActionCommand
Set permissions to 755chmod -R 755 /usr/home/username/server1/
Remove all datarm -rf /usr/home/username/server1/*
Change owner and groupchown -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.

Scroll to Top