Linux Bash Shell
A Few Brief Notes
The bash shell is an indispensable tool for any website developer, site building, or maintainer. What follows are few brief notes that answer questions that appear occasionally, that are hopefully helpful.
There are numerous tasks that are best performed using the shell command line. However, there are some website professionals who either overuse the shell's command line interface, or don't employ it efficiently.
An easy way to help make using the shell efficiently is to efficiently use the shell's command history. First, it can be extremely helpful to increase the size of the shell command history list. While the default value is 500 commands, there are few reasons not to increase this to thousands of commands. Second, it is essential to know how to efficiently search the history for previous commands. The inspiration for how to search the bash shell command history comes from a fundamental understanding of the original intent of the unix/linux command line environment. This inspiration is that the command line tools were/are meant to used together, and string together into the larger command systems. So, the quick and easy way to search the command history, is to pipe the command history through the grep tool, which narrows the end result output set. The syntax for this is as follows:
history | grep {query}
For example, to find previous cd commands the required {query} variable would be replaced with the the cd command. Any other keyword in previous commands would yield all recent commands that contain that keyword. This simple usage is a real lightbulb moment for something quite simple, but which is an oft asked question on linux how to sites.
Save Complex Commands As Shell Scripts
Instead of typing long commands at the command line, write and edit lengthy commands in a text editor and save those commands as bash shell scripts that can be reused. Typing. re-typing, and trying to edit, complex linux commands at the command line just isn't an efficient way to use the command line, especially since the shell's greatest strength is script based automation.
