lucasmontanheiro / shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shell

Basic

01 Hello World

To edit a file in shell, hit

nano helloworld.sh

To save and get out of nano, hit CTR + X and then hit Y. To run: bash helloworld.sh or .\helloworld.sh But first you need to give permission: chmod +x helloworld.sh

Basic commands for this lesson:

echo 		#to print a message or variable
chmod 		#to change permissions in files or directories
exit 		#to exit terminal or connection

02 Variables

read $name  #for user input

name="assign text to a variable"

echo "It will use your variable here: $name"

To use an input directly from shell, like .\BestDay.sh eggs, use $1 for the first parameter

recipe=$1
echo "Today I'm going to cook $recipe"

Basic commands for this lesson:

whoami 		#your username
date 		#current date and time
pwd			#where in directory you are

03 Basic Math

echo $SHELL 		#your shell
echo $USER 			#your userid
echo $HOSTNAME		#your hostname

To create a new variable name for your system:

$ bestteam="Corinthians"
$ echo $bestteam

That can be used in your script!

But that will be erased as soon as you restart your terminal. To make it permanent, you need to write into a file called .bashrc. The . means that the file is hidden. That's a script that will run every time the system logs in.

nano .bashrc

Add export bestteam="Corinthians" at the end of the file and log out and log in.

echo $bestteam		#will equals to Corinthians!

Cool commands

Basic commands

tree 	// shows the whole directory
mkdir 	// create a directory

Network commands

ipconfig
ipconfig /all
findstr
ipconfig /release
ipconfig /renew
ipconfig /displaydns
ipconfig /renew
clip
ipconfig /flushdns
nslookup
cls
getmac /v

Check Battery

powercfg /energy
powercfg /batteryreport
assoc

Is your computer slow?

chkdsk /f
chkdsk /r
sfc /scannnow
DISM /Online /Cleanup /CheckHealth
DISM /Online /Cleanup /ScanHealth
DISM /Online /Cleanup /RestoreHealth
tasklist
taskkill
netsh wlan show wlanreport
netsh interface show interface
netsh interface ip show address | findstr “IP Address”
netsh interface ip show dnsservers
netsh advfirewall set allprofiles state off
netsh advfirewall set allprofiles state on
ping
ping -t
tracert
tracert -d
netstat
netstat -af
netstat -o
netstat -e -t 5
route print
route add
route delete
shutdown /r /fw /f /t 0

Changing files permissions

chmod ugo+rwx foldername

Resources

About


Languages

Language:Jupyter Notebook 88.8%Language:Shell 11.2%