chmod
A command that changes a file's permission bits, using either octal digits or symbolic changes.
In more detail
chmod +x adds execute permission so a script can be run as a program, and chmod 644 sets read and write for the owner and read for everyone else. Only the owner or root may change a file's permissions.
Examples
chmod +x dynamic.py makes an inventory script executable so Ansible runs it instead of parsing it.In playbooks, the mode argument of the file and copy modules sets permissions idempotently.chmod +x script.shchmod 600 secret.txtchmod 640 report sets the whole mode; chmod g+w report only adds group write. Only the file's owner or root can change a mode. Always check the owning group too, because the same mode on the wrong group grants the wrong people access.Related terms
- file permissions — Rules on each file saying which user and group own it and who may read, write or run it.
- inventory script — An executable program that prints the inventory as JSON when Ansible runs it with --list, and one host's variables with --host.
- symbolic mode — A chmod permission change written as who, operator and rights, such as u+x or go-w.
- numeric mode — A permission setting written as three digits, one each for owner, group and others, where read is 4, write 2 and execute 1.
- execute permission — The permission that lets a file be run as a program, or lets you enter a directory.
- file mode — The set of permission bits stored with each file that says what the owner, the group and everyone else may do with it.
- octal mode — Writing a file mode as base-8 digits, one per class, where each digit is the sum of read 4, write 2 and execute 1.
Taught in
- Dynamic Inventory — Ansible Configuration Management at Scale
- Shebangs, Permissions And Three Ways To Run — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- kube-bench: Ten Failures On A Fresh Cluster — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Seccomp: Which Syscalls A Container May Make — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Backup Architectures: 3-2-1, Immutability & Air-Gaps — Cybersecurity Fundamentals, GRC & Cryptography
- Reading And Setting A File Mode — Linux Fundamentals & Systems Administration
- Logins, su, sudo And SSH Between Hosts — Red Hat Certified System Administrator (EX200) Exam Prep
- Privileged Access: sudo Rules In Drop-In Files — Red Hat Certified System Administrator (EX200) Exam Prep
- Diagnosing Permission Problems — Red Hat Certified System Administrator (EX200) Exam Prep
- SELinux Contexts: Labels, restorecon And Rules That Last — Red Hat Certified System Administrator (EX200) Exam Prep
- The Upload That Ran: Mount Options, Swap And Network Shares — CompTIA Linux+ (XK0-006) Exam Prep
- A Server Nobody Can Find: Addresses, Routes And Names On Both Families — CompTIA Linux+ (XK0-006) Exam Prep
- Works On My Laptop: Images, Containers, Volumes And Networks — CompTIA Linux+ (XK0-006) Exam Prep
- The Pager Command That Opened A Root Shell: sudo, su And Least Privilege — CompTIA Linux+ (XK0-006) Exam Prep
- Root Over SSH From Anywhere: Keys, sshd, setuid Files And Attributes — CompTIA Linux+ (XK0-006) Exam Prep
- Forbidden, With Perfect Permissions: Paths, ACL Masks And SELinux Denials — CompTIA Linux+ (XK0-006) Exam Prep
- Three PBQs Against The Clock: A Performance-Based Mock On Both Families — CompTIA Linux+ (XK0-006) Exam Prep
- Ninety Minutes, Five Domains: The Full Mock And The Week Before The Exam — CompTIA Linux+ (XK0-006) Exam Prep
- Drill: People, Passwords And sudo From The Vault — RHCE in Ansible (EX294): Automate Red Hat Systems