Linux tips and tricks
Very often I find my self doing repeating tasks when working with DevOps operations; so I always think how to automate things. When working on Windows platform I tend to create PowerShell scripts on Linux I create bash scripts.
On Ubuntu it is very easy to create executable scripts that will hold your bash commands. To create executable bash script create new file with your favorite text editor; mine is nano :-).
In the new file reference the script interpreter at the beginning of the script
Next add your commands and save your file. Just for illustration; here is a simple automation script I use when deploying web sites. This commands will recursively copy all files for
~/www to the target
/var/www/html folder and will change permission to all files to the
rsync -r ~/www/* /var/www/html/ chown -R www-data:www-data /var/www/html
At the end change the permissions to your file to make it executable
chmod +x script.sh
To execute the script type
That is it. Enjoy coding! For more info check: