Windows attrib equivalent in Linux
Controls who can read, write, or execute a file. Linux uses a more powerful permission model than Windows.
attrib
chmod / chown
chmod / chown
chmod / chown
Overview
What this command does
Controls who can read, write, or execute a file. Linux uses a more powerful permission model than Windows.
Practical tasks
Common use cases
Change file permissions/attributes
Controls who can read, write, or execute a file. Linux uses a more powerful permission model than Windows.
chmod 755 file
rwxr-xr-x (typical for scripts)
chmod 644 file
rw-r--r-- (typical for data files)
chmod +x file
Add execute permission for everyone
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
chmod 444 file.txt
chmod 644 file.txt
chmod +x myscript.sh
./myscript.sh
chown john:john file.txt
chown -R john /var/www/
Walkthrough
Examples with explanations
# Windows: attrib +r file.txt (set read-only)
chmod 444 file.txt # read-only for everyone
chmod 644 file.txt # owner can write, others read-only
# Make a script executable:
chmod +x myscript.sh # allow it to be run
./myscript.sh # then run it like this
# Change ownership:
chown john:john file.txt # set owner to john
chown -R john /var/www/ # recursive ownership change
Reference
Common options and variations
| Command or option | Use |
|---|---|
chmod 755 file | rwxr-xr-x (typical for scripts) |
chmod 644 file | rw-r--r-- (typical for data files) |
chmod +x file | Add execute permission for everyone |
chmod -R 755 dir/ | Apply recursively to a directory |
chown user:group file | Change owner and group |
ls -l | View current permissions |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | chmod / chown |
Same command on this distribution. |
| Fedora | same command | chmod / chown |
Same command on this distribution. |
| Arch | same command | chmod / chown |
Same command on this distribution. |
Important
What to watch out for
Keep learning