Change File Permissions
The chmod command (change mode) modifies file and directory permissions in Linux, controlling who can read, write, or execute files on your system.
Think of chmod like setting locks on doors in a building. You can decide who has keys (permissions) to enter rooms (files), who can rearrange furniture (write), and who can use equipment (execute). IT professionals use it to secure configuration files, make scripts executable, protect sensitive data, set up web server permissions, and control access to shared directories.
Advertisement
[ Insert Google AdSense Banner Code Here ]
Allow shell scripts and programs to run on your system.
Protect private keys, passwords, and configuration files from unauthorized access.
Set proper permissions for web files and directories (Apache, Nginx).
Manage who can read, write, or execute files in shared directories.
ls -l List files with permissions (use this first to see current permissions).
chmod 755 script.sh Make a script executable (owner: rwx, group: r-x, others: r-x).
chmod u+x program Add execute permission for the owner (user).
chmod 600 secret.key Secure a private file (owner: rw-, group: ---, others: ---).
chmod 644 document.txt Standard file permissions (owner: rw-, group: r--, others: r--).
chmod go-w config.conf Remove write permission from group and others.
chmod a+r public.txt Add read permission for all users (user, group, others).
chmod 400 id_rsa Make SSH private key read-only for owner (recommended security).
Never use 777 permissions in production! Using chmod 777 gives everyone full access to read, modify, or execute your files - a major security risk.
Be VERY careful when changing permissions! Incorrect permissions can lock you out of your own files, break programs, or create security vulnerabilities.
Always follow the principle of least privilege: Give only the minimum permissions needed. Use 600 for private files, 644 for regular files, and 755 for executable files and directories.
Practice chmod commands in the interactive terminal below: