home directory is created from /etc/skel/, this includes default .bashrc and .profile
/etc/skel/.bashrc
Create/remove alias (b.bashrc)
alias extip='curl icanhazip.com'
unalias
Variables
in caps
no spaces near =
HELLO="Hello World"
echo $HELLO
Execution
df -h
watch df- h –>every 2s
Numbers
expr
* is nor for multiplying (* wildcard operator) so use: \*
let <variable>
tar
To extract a .tgz file
tar -xvzf /path/to/yourfile.tgz
To different directory
tar -xvzf /path/to/yourfile.tgz -C /path/where/to/extract/
if
if [ $MYNUM -eq 200 ]
then
else
fi
case
#!/bin/bash
echo "what is favorite color?"
echo "1 - Black"
echo "2 - Red"
echo "3 - White"
echo "4 - Blue"
read color;
case $color in
1) echo "Night is Black";;
2) echo "Blood is Red";;
3) echo "Snow is White";;
4) echo "Sky is Blue";;
*) echo "no relevant!";;
esac
while
#!/bin/bash
mika=1
while [ $mika -le 10 ]
do
echo $mika
mika=$(( $mika + 1))
spleep 0.5
done
File/Directory Exists?
File
if [ -f ~/myfile ]
Directory
if [ -d ~/myfolder ]
Universal update scripts (<>distros)
#!/bin/bash
cd /etc
## testing arch based
if [ -d /etc/pacman.d ]
then
## Run arch update cmd
sudo pacman -Syu
fi
## Testing debian-based
if [ -d /etc/apt ]
then
## Run arch update cmd
sudo apt-get update && sudo apt-get dist-upgrade -y
fi
sendEmail -f <fromEmail> -t <toEmail> -u "This is the subject" -m "This is the message" -s smtp.googlemail.com:587 -xu <user> x -xp <password> -o tls=yes