Linux shell basics

In this quick tutorial we will look at few different Linux shells , main shell configuration files and few quick tricks that will help you when working with shell commands.

Linux provides a range of options for shells. A complete list would be quite long, but the more common choices include the following: bash The GNU Bourne Again Shell (bash) is based on the earlier Bourne shell for Unix but extends it in several ways. In Linux, bash is the most common default shell for user accounts.

 

bsh

The Bourne shell upon which bash is based also goes by the name bsh. It’s not often used in Linux, although the bsh command is usually a symbolic link to bash.

tcsh

This shell is based on the earlier C shell (csh). It’s a fairly popular shell in some circles,but no major Linux distributions make it the default shell. Although it’s similar to bash in many respects, some operational details differ. For instance, you don’t assign environment variables in the same way in tcsh as in bash.

csh

The original C shell isn’t much used on Linux, but if a user is familiar with csh, tcsh makes a good substitute.
ksh

The Korn Shell (ksh) was designed to take the best features of the Bourne shell and the C shell and extend them further. It’s got a small but dedicated following among Linux users.

zsh

The Z shell (zsh) takes shell evolution further than the Korn Shell, incorporating features from earlier shells and adding still more.

In addition to these shells, dozens more are available. In Linux, most users run bash because it’s the default. Some other OSs use csh or tcsh as the default.

Tips

 

  • The file /bin/sh is a symbolic link to the system’s default shell—normally /bin/bash for Linux. Most shells offer a similar set of internal commands, but shell-to-shell differences do exist.
  • Another helpful shell shortcut is the shell history. The shell keeps a record of every command you type (stored in ~/.bash_history in the case of bash).
  • Move within the line Press Ctrl+A or Ctrl+E to move the cursor to the start or end of the line.
  • ~/.bashrc and ~/.profile files are the main user configuration files for bash, while /etc/bashrc and /etc/profile are the main global configuration files.