Category: 1. Shell Script Basic
-
Shell Scripting Prevent setuid root spoofing
Spoofing is a technique through which a user tries to grant unauthorized access on a system by pretending to be the root user. This is called setuid root spoofing. To prevent from spoofing you can add — after #!/bin/bash. It disables further option processing so that shell will not accept any options. Look at the…
-
Troubleshooting a shell script
There is one more way other than script execution to run a script in a different shell. Type bash with the name of the script as parameter. Syntax: Example: bash exm Look at the above snapshot, it displays the exm script content with bash command. Look at the above snapshot, this is the exm script we have…
-
Shell Scripting Sourcing a file
A file is sourced in two ways. One is either writting as source <fileName> or other is writting as . ./<filename> in the command line. When a file is sourced, the code lines are executed as if they were printed on the command line. The difference between sourcing and executing a script is that, while executing a script…
-
Shell Scripting Variables
Scripts can contain variables inside the script. Look at the above snapshot, two variables are assigned to the script $var1 and $var2. As scripts run in their own shell, hence variables do not survive the end of the script. Look at the above snapshot, var1 and var2 do not run outside the script.
-
Shell Scripting Comments
Any line starting with a hash (#) becomes comment. Comment means, that line will not take part in script execution. It will not show up in the output. Look at the above snapshot, lines after the # are commented. Look at the above snapshot, commented lines are not displayed in the output.
-
Shell Scripting She-bang
The sign #! is called she-bang and is written at top of the script. It passes instruction to program /bin/sh. To run your script in a certain shell (shell should be supported by your system), start your script with #! followed by the shell name. Example:
-
How to determine Shell
You can get the name of your shell prompt, with following command : Syntax: Look at the above snapshot, with the help of above command we got the name of our shell which is ‘bash’. The $ sign stands for a shell variable, echo will return the text whatever you typed in.
-
What is Shell Scripting
In Linux, shells like bash and korn support programming construct which are saved as scripts. These scripts become shell commands and hence many Linux commands are script. A system administrator should have a little knowledge about scripting to understand how their servers and applications are started, upgraded, maintained or removed and to understand how a…
-
Shell Scripting Tutorial
Shell Scripting tutorial provides basic and advanced concepts of Shell Scripting. Our Shell Scripting tutorial is designed for beginners and professionals. Shell Scripting is an open-source operating system. Our Shell Scripting tutorial includes all topics of Scripting executing scripting, loops, scripting parameters, shift through parameters, sourcing, getopts, case, eval, let etc. There is also given…