builtins
Builtins are commands that are available within the script runtime.
As with bash they do not require an external binary to run, the commands are compiled in to the shell executable.
cd
Change currenty directory
example:
cd /tmp
echo
Similar to bash echo
.
example:
echo hello world
setenv
Similar to csh setenv
.
example:
setenv LOGS_ON true
There are 3 variables that can be set without a value
setenv date
- sets the ${date} var to iso8601 date string, e.g. "2020-12-30"setenv time
- sets the ${time} var to iso8601 time string, e.g. "13:59:30"setenv datetime
- sets the ${datetime} var to iso8601 date string e.g. "2020-12-30T13:59:30"
unsetenv
Similar to csh unsetenv
.
example:
unsetenv LOGS_ON
error
echo
to stderr.
example:
error booting servers
setuid
Set current user id, setuid
takes 1 or 2 numeric arguments, uid
and optionally gid
.
If the script is running as root this changes the processes effective user id, you cannot change back.
example:
setuid 1000 1000
/home/ubuntu/bin/server.sh
runas
Executes a process as a different user, the current process userid is not changed, this can be used as an alternative to /bin/su
if the use is to step down privilidges from root. runas
cannot step up privilidges to root.
example:
runas ubuntu /home/ubuntu/bin/server.sh
exec
Similar to bash exec
but without redirects
exec /sbin/xtomp
spawn
Execute a process in the background, akin to bash's trailing &
example:
spawn /sbin/xtomp
spawn /usr/bin/rsyslog
reexec
Execute a process, if it ever terminates, restart it. This must be the last line of a script, it never returns.
reexec /bin/getty -L tty1 115200 vt100
respawn
Start a process that, if it ever stops, will be restarted.
lxinitd
supports up to 20 services.
example:
respawn /bin/getty -L tty1 115200 vt100
respawn /usr/bin/rsyslog