Scripting Classroomnotes 30/Oct/2022

Command

  • Command is an executable written in any language.
  • An executable has execute permissions for owner or group or other(RWX)
  • To run the shell script
bash <path-to-script>.sh
# if we change permissions to execute
<path-to-script>.sh


* Now commands like ls, ping etc are executed without complete file path
* When you type any command in linux or windows systems it searches for the executable in certain folders. These folders are listed in environmental variable called PATH
* Linux: folder paths seperated by colon

* Windows: folder paths seperated by semicolon

* Linux Path:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
==>
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin


* Now lets make our script2.sh work from anywhere
* copy the script2.sh into any folder which is already part of path variable.
* We can also copy the script to new location and remove the extension

* To see all the environmental variables, possibilities are
* set
* declare
* printenv
* Next Steps:
* Adding folders of our choice to PATH
* Every command generally takes arguments

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

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%%