You are on page 1of 2

shell variables

shell variable can only be created by shell process


When the shell process is creating some variables then subsequence process
will not be able to use that variable

To print all environmental variable that have been set

#env or #printenv

To set environment variable


#export NAME="whoami"
or
NAME="whoami"
export NAME

TO know the value of variables


echo $NAME //(NAME is variable)
if you want to use variables type
# $NAME

----------------------------------------------------
[root@localhost ~]# ps -e | grep bash
3420 pts/0 00:00:00 bash
[root@localhost ~]# terminator
bash: terminator: command not found...
^C
[root@localhost ~]# bash
[root@localhost ~]# ps -e | grep bash
3420 pts/0 00:00:00 bash
4301 pts/0 00:00:00 bash
[root@localhost ~]# pstree -s -p 4301
systemd(1)───sshd(1150)───sshd(3363)───sshd(3413)───bash(3420)───bash(4301)───pstre
e(4326)
[root@localhost ~]# echo $NAME
whoami
[root@localhost ~]#
[root@localhost ~]# unset NAME // to unset the value of variables

shell variable
NAME="pwd" // not use export keyword
set //to see all configured shell variables
[root@localhost ~]# set
[root@localhost ~]# set |less
[root@localhost ~]# set |grep nameok
nameok=pwd

to get the value of shell variable is the same $nameok


also use unset to remove
use {}to acess valiable
${NAME} to avoid ambiguities

ALIASE
the purpose of aliase is to indicate some string with some other name
[root@localhost ~]# alias cl=clear
to remove alias
unalias cl

to make persistence configuration of alias,env variable and shell variable


use .bashrc
to execute you may use
#source .bashrc
one more way to make persistent env variable you have to edit
/etc/environment //used by shell process to create environment variables

PATH VARIABLE
program/command look excutable here
export PATH="$PATH:/home/joakim" //to update the path
or add it in /etc/environment

PS1 upto PS4 variables are used to set prompt

You might also like