Action disabled: recent
linux:bash
Table of Contents
Bash
Bash is a Unix shell and command language distributed as default with Linux.
Colour the prompt
The prompt is defined by the variable PS1
.
To set a colour for the prompt, when logged as user, save in /home/.bashrc
, the following:
# colour prompt for user PS1="\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ " export PS1
where 1;32m
means light green colour while 0m
disables the colouring.
Note that non-printing character must be encapsulated between \[\033[
and \]
.
To set a colour for the prompt, when logged as root, save in /root/.bashrc
(create it if doesn't exist), the following:
# colour prompt for admin PS1="\[\033[1;31m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ " export PS1
Path variable
The PATH
variable is a list of directories in which are looking for the commands used with the shell.
To append a directory, save in /home/.bashrc
, the following:
PATH=$PATH:new/path/directory export PATH
linux/bash.txt · Last modified: 2023/05/28 16:07 by 127.0.0.1