Have a Bash With This Linux Shell
Any Linux administrator who wishes to remain sane relies heavily on scripting to automate routine tasks, customize jobs, and build the plumbing that connects the different utilities that make a Linux system run smoothly. The Linux world is chock-full of scripting languages: Perl, Python, PHP, Scheme, Tcl, Tk, Ruby, Forth, Smalltalk, Eiffel, and doubtless many more. To get the column started, we'll look at shell scripting with Bash, and scripting with Python and Perl.
Understanding what Bash does is fundamental to using Linux. Bash is a command interpreter, the direct interface between you and your Linux system. Python is easy-to-learn, yet capable of handling any system administration chore. Perl is endlessly flexible, which makes learning it rather vexing at times. But it can do almost anything: Complex programs are written in Perl, such as the indispensible game Frozen-Bubble.
Scripting and text-and-file processing go hand-in-hand. So we'll also incorporate regular expressions, awk, sed, find, sort, uniq, and other text-and-file processing utilities. Half of using Linux is simply learning all these odd little specialized commands. Here is where the real power of Linux/Unix lies: All these little, specialized programs can be strung together in any way you need. You're not limited by some program author's idea of what you need, so you can use these building blocks to construct your Linux house the way you like it.
The default command shell on most Linux distributions is the Bash shell. Linux/Unix gurus adore silly wordplay; Bash stands for Bourne-again Shell. Bash is based on the Bourne Shell, the original command shell for Unix SysV systems. It incorporates features of the Korn shell, the C shell, and some new stuff of its own. Some folks love to debate command shells, and wax poetic over Csh, Tcsh, Zsh, and so forth. You are welcome to go nuts and experiment with any shells you like. Meanwhile, we're going to talk about Bash. (Should there come a time when you need to run a different shell, but don't want change your system default, simply invoke it from Bash: $ exec /bin/zsh)
For admins looking to master the shell game, the book "Linux In A Nutshell," by Ellen Siever, is indispensible. It's the best Linux command reference we've seen. It separates the built-in Bash shell commands from other commands, such as system administrator and user commands. Understanding what belongs to Bash will prevent a lot of confusion. Run this command to see what built-in commands are enabled on your system:
This command displays all of your environment variables:
You should have version 2 or newer:
carla@windbag:~$ echo $BASH_VERSION 2.05b.0(1)-release
Unlike many Linux programs, Bash is mature, and does not change very often, so you don't have to worry about laboring to keep up with the latest and greatest.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linux 3.10 Goes Long, Linux 3.11 Advances as LXDE Merges
- 3Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 4Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 5Linux Top 3: Linux 3.11, Kubuntu Goes Commercial