Readonly
Encyclopedia
Unix Readonly Shell Command
The unix readonly commandCommand (computing)
In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell....
is used for writing a unix Shell script
Shell script
A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...
that uses variables. This command allows the programmer to set a variable stored in the Shell (computing)
Shell (computing)
A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...
's variable list. This command sets a specified shell variable to not be changeable. After this is done it is not possible to alter that variable. This is done for storing the UUID of the logged in user of a shell, and can be used for making sure the variable never gets changed by another command.
Example
An example of a shell script that would use this would beusername="johnsmith"
readonly username
# ... call insecure function
username="root" # this doesn't work
# continue regular code
Example
In most shells such as Bash (Unix shell), the readonly command is built-in and not in the users path. This can be determined by running the following command in your unix shell:whereis readonly