Linux Classroom notes 31/July/2026

Variables:

  • its store infromation in memory
  • key and value ==> name_varaible and value will be value of the key

rules for Variables:

  • name must be start with letter or “_”
  • contain only letters , “_” and numbers
  • no space bettween key and value
    • name=ram
  • case-sentive
    • Name , name
  • Enviromnent variable use captial & scprit or automation use small letters
    • $JAVA_HOME
    • $java_path

Types of variables:

  • local variable (shell)
  • enviroment variables
  • special variables
  • Array variables
  • read-only variables

local Variables

  • Ex:1
name=ram
age=30
bloodgroup=A-positive

echo "my name is $name and age $age , Blood group is $bloodgroup "
  • Ex:2
image=ubunt

docker pull $image

enviroment variables

  • sudo vi /etc/enviroment This is default enviroment variable
  • export data_value=9090 # this override default values work only when terminal activity
HOME - user directory
USER - current loggined user $(whoami)
PWD - current working dir 

BASIC shell:

  • file extension “.sh“`
  • #!/bin/bash

create file sample.sh and add below cmds

#!/bin/bash

sudo apt-get update 
sudo apt-get install git -y 
  • chmod 755 sample.sh # provide execute permissions
  • sh sample.sh or ./sample.sh

special variables:

  • It is used in scrpits and automation

$0 – name of the scrpit

$1, $2 … positional args pass in script

#!/bin/bash

# file demo.sh 
echo "arg one value $1"
echo "arg one value $3"
  • sh demo.sh 99 567 44

  • $# – number of args passed

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%