For giving read/write/execute permission to user and r/x permission to "groups" and "others":
chmod 755 script.sh
For checking a command type (if its a shell built in command or a binary):
type echo
OR type -a echo
-a
flag displays the list in order in which the command will execute.
For getting information about commands that are shell builtin like "echo", we can use:
help echo
For getting info about commands which are not shell builtins like "uptime", we can use:
man uptime
Must use double quotes for using variables in strings.
For Example: If we have a variable named "x",
echo "$x"
will work. But echo '$x'
won't because it will treat it as a string.
By convention, Variables must be all UPPERCASE.
Also should put a header comment in beginning of script which defines working of the script.
We can check for root privilages when our script includes commands that need root privilages.
if [[ $UID -eq 0 ]]
then
echo "You are Root"
else
echo "You are not Root"
fi