Q. There is a way to cd a particular directory even if you spelled incorrectly on the command line. The command was added to my shell startup file. After formatting my hard disk, I lost my original file. Can you tell me the shell option or command that will automatically correct errors in the spelling of a directory name in a cd command?
A. There is a bash shell variable called cdspell If set, minor errors in the spelling of a directory component in a cd command will be corrected. The errors checked for are transposed characters, a missing character, and one character too many. If a correction is found, the corrected file name is printed, and the command proceeds. This option
is only used by interactive shells.
To toggle the values of cdspell variables controlling optional behavior use shopt command as follows:
$ shopt -s cdspell
$ cd /etx
Add above command to your .bash_profile file.
Q. Iâ€™m using CentOS Linux server. How do I insert the arguments to a previous command into the current input line or fix errors in previous commands quickly?
A. BASH History expansion is useful and time saving feature. To designates the last argument of the preceding command use !$
For example, consider following command:
$ cp /tmp/file.name /path/to/somewhere/directory/file.name
$ cp !$ /home/you
!$ will automatically expand into /path/to/somewhere/directory/file.name, thus calling last command argument. See HISTORY expansion section by typing man bash command for more information:
How do I search for file in Bash?
We are developing Linux based application and we would like to set the time zone on a per user basis for individual user. How do I configure Fedora Linux or any Unix like oses to set the time zone on a per user basis using bash shell?
Q. Iâ€™ve migrated from Windows NT to Linux workstation. Most documents refer to a command line shell. Can you explain me command line shell?
A. A shell allows you to type the commands such as date or clear. There are many shell available. BASH (bourne again shell) is default shell for most Linux distributions.
It also known as a command interpreter which takes command from user and pass the same to kernel for execution. Bash shell supports aliases, filename completion, command history, POSIX compatibility and many other features.
Other UNIX / Linux shell
I want to disable Control-C while running shell bash script program under UNIX / Linux like operating systems. How do I disable Control-C?