Most recent Linux distributions include bash as default shell, I did some reading on this and the conclusion seems to be that it is the default shell of GNU (used by most Linux based OS), and therefore simply comes packaged as part of GNU, while also having 20 years of development behind it making it stable and well rounded, it is simply the best all rounder, meeting the needs of all but the most advanced users.
There are quite a few features that the Bash shell has and some of the lesser-known ones include:
- Insert the last parameter(s) of the preceding command in your current command using Alt + .
- You can keep a process running even after logging out. To do so, use the command disown -h <pid> where you will have to place the process ID (PID) of the program.
- Perform a reverse incremental search using the Ctrl + R keys
- Press tab twice and you will see the list of completions for the word that you have just typed or are typing..
- When executing a script with bash, use the -x option to output the script contents as it's being executed
- Execute the previous command again using the !! (!! is shorthand for 'the previous command')
For Example
$ mkdir /testmkdir: /test: Permission denied$ sudo !!sudo mkdir /testPassword:
Just to add a bit more to this, there are many other shells to try, if you are interested, here's a few
- Zsh has more advanced interactive facilities, but a few quirks when it comes to scripting (less so now than back in the days). In the early to mid-1990s when Linux was in its infancy, zsh was virtually unknown.
- Ksh was the de facto standard on commercial unices since the mid-1980s, but it was proprietary software until 2000, so not an option on Linux. Also, ksh had subpar command line editing capabilities, compared with bash.
- Pdksh, a free clone of ksh, would have been an option, but it was not well-known and had poor command line edition capabilities. (Pdksh is no longer a very active project, even though it's still used in some BSDs, now that ATT ksh is free.)
- Some distributions install an ash variant as /bin/sh. Ash (by which I mean any of the loose family of shells called ash) is designed to be small and fast, with no interactive features (it's only for editing scripts). The ash revival is relatively recent; in the 1990s the existing variants lacked a lot of features.
- Tcsh was the most advanced interactive shell until zsh came along, but it's incompatible with sh and not so good with scripting.
0 Comments