Bash Scripting Cheatsheet
July 21, 2020
Shell is common Linux, Unix
Bash is a CLI tool to run the scripts. The shell script communicate with the kernel which in turn kernel tells the hardware what to do
To create a script file
gedit first.shCommands
#!/bin/bash #to the tell the path of bash
# hash is used for comments
echo "Hello World!" # prints stuff on the screenRun the script
chmod +x first.sh # +x makes the file executableor
chmod 755 first.sh # 755 is the octal here which is used to manage permissionsTo show which command is giving which output
#!/bin/bash/ -xecho $PATH # to know the path(run this in the root directory)Use \ to make the long commands readable
npm install chrome inkspace vlc sublime mediaplayer \
soundrecorder vscode Points to remember
- BASH is very well documented, don’t hesitate to search the web
- Always use absolute paths in a script. Eg: /home/Documents/logo.png
- Write detailed comments
~in terminal refers to home directory