The final lesson I’d like to teach in the Linux Commands section is an explanation of what “shell scripts” are. Shell scripts are simple scripts you can make that have multiple commands in them. Then you can just execute the shell script and all the commands written it will execute without you have to typing them one after another. You do this coding in a simple language called “BASH,” which is the language the Ubuntu shell uses. But for basic scripts you don’t really need to know any bash. You could write something like:
The first line is just required for the script to work. The #! symbols together are called “shebang” and basically are a signifier that the following is a bash a script. Don’t worry about it much yet.
The next thing to think is: “Crap, I could trigger this script (or any other script) via a cron job” and have it do routine cleanup for me--in this case remove old log files.
So that’s an example of the power of shell scripting. There’s obviously a lot more you can do. For example, you can do loops and conditional logic like a PHP script--though you'll have to explore that on your own. For scripts that deal with your application’s database, you probably just want to write a PHP script using Yii’s “console application” tools, but for scripts that mainly deal in Linux commands, you definitely want to write a bash script.