Something you’ll find once you start working with and administrating Linux servers is how often scripts are used to perform tasks. In fact, as you delve deeper you find that an awful lot of a Linux distribution is held together by scripts that make it all work.
We’ll start by looking over what a script is. A script is a type of computer program written in scripting language. In traditional programming languages a program is written in a language that is human readable, and then another program called a compiler is used to convert the program code into a program that a computer can then run. This compiled program is then distributed to be run on other computers.
Scripts on the other hand are not compiled into programs, but a program called an interpreter is used to convert the script code into a code that the computer can run as it is used. This can make them slower to run than compiled programs, but they can be edited and customized more easily. A big advantage that interpreted scripts have over compiled programs is that they can be run on any system with an interpreter without being changed, whereas the compiled program will need recompiling for each different computer system that it will be run on. More often than not, scripts tend to be used for smaller single purpose tasks as they can make it easier to get the program written, tested and working than a compiled language can.
How Does Scripting Help Me?
As for why you should care, as mentioned before pretty much all Linux distributions make use of a lot of scripts to perform various tasks that make the system work. While you’ll be highly unlikely to need to deal with any problems from these scripts, their presence should highlight just how ubiquitous scripting has become. An understanding of scripting means you can use their power to help you get jobs done faster and easier.
The common scripting languages you’ll encounter on Linux systems are Perl, Python and Shell scripts. While Perl and Python are dedicated programming languages that can allow for the creation of very powerful scripts, there is a barrier to entry in that learning to use them can take some time for people who’ve never done any programming before. By contrast, shell scripting has a much lower barrier to entry as a basic shell script can simply consist of a collection of shell commands one after the other. The Bourne Again SHell (BASH) that most Linux distributions ship with as the default shell also has some other features that allow you to perform decision making tasks similar to other programming languages, making it more powerful for scripting than simply running a chain of commands
Give Yourself A Break
Scripting exists to help make your life easier. At some point when working with Linux systems, you’ll likely find yourself doing tasks on a server that sees you repeatedly running a batch of commands. Alternatively, you could be running a command that takes a number of arguments, most of which you never change. Simple scripts can chain those commands together or act as a wrapper for that awkward command allowing you to type a shorter command with just the arguments that you’d be changing. Another prime candidate for a script is a task that you perform infrequently but have to keep looking up. By creating a script to run the commands for you can save you searching for that how-to guide repeatedly.
Just learning the basics of scripting can make a massive difference to the speed with which you can get repetitive tasks done, and is seen as important skill for pretty much any Linux systems administrator.
This article was brought to you by VPS.net, for dedicated server hosting, cloud servers and 24/7 support visit our site here vps.net