readonly
shell builtinLinux/Unix
The readonly command is one of the most frequently used commands in Linux/Unix-like operating systems. readonly Mark variables or functions as read-only
Quick Reference
Command Name:
readonly
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
readonly [options] [arguments]
Common Use Cases
Syntax
readonly [options] [name[=value] ...]
Options
Option | Description |
---|---|
-a |
Each name refers to an indexed array variable |
-A |
Each name refers to an associative array variable (Bash 4+) |
-f |
Each name refers to a shell function |
-p |
Display a list of all readonly variables or functions |
-- |
End option processing |
Examples
How to Use These Examples
The examples below show common ways to use the readonly
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.