Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Friday, September 8, 2017

How to install tcsh or csh shell on a Debian or Ubuntu Linux ?

Cshell is a shell (command interpreter) with C-like syntax.

csh is a command language interpreter incorporating a history mechanism , job control facilities , interactive file name and user name completion, and a C-like syntax. It is used both as an interactive login shell and a shell script command processor. tcsh is an enhanced but completely compatible version of the Berkeley UNIX C shell.

"tcsh" advantages

   - The ability to use multiline aliases and exec statements in a reliable and consistent way.                          (Hense "sh" scripts can be  re-written as tcsh scripts with aliases instead of functions.)
   - "tcsh" is the same on all machines.  For "csh" I typically  have to modify scripts for different machines.  [example: HP-UX  "set nonomatch" needs to be replaced by "set nonomatch = ()"] 
   - source code is freely available
   - PWD and other common environmental variables are always defined. With "csh" this depends on the machine.

In most cases csh / tcsh is installed by default. All you have to do is type shell name to start using it:

$ csh

OR
$ tcsh

Install csh / tcsh

In case csh is not installed, type the following command at shell prompt as per your Linux distro / version.

Install it on Debian/Ubuntu/Mint Linux

$ sudo apt-get install csh

Install it on CentOS/RHEL

# yum install tcsh

Install it on Fedora Linux

$ sudo dnf install tcsh
Set csh as default login shell
To make csh as default login shell, type the following command:
$ which tcsh
OR
$ which csh
Sample output:
/bin/csh
Note down the /bin/csh or /bin/tcsh path. To change the shell simply type
$ chsh
OR
$ chsh -s /bin/csh


Saturday, December 19, 2015

How to change default login shell permanently in linux ?

  
In Red hat Linux the default shell you login to is /bin/bash but in case you want to change the default login shell follow the below procedure

To check the currently logged in shell

# echo $SHELL
/bin/bash

To view all the available shells in your machine

# chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh

You can also view the available shell details from the below file
# less /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh

To change the shell temporarily
To do this just provide the full path of the shell you want to use. But this is just a temporary change as next time you switch terminal you will login to the default shell
[root@linuxforfreshers ~]# /bin/sh
sh-4.1#
As you see above my shell prompt changed from /bin/bash to /bin/sh

To change the shell prompt permanently
# chsh -s /bin/sh
Changing shell for root.
Shell changed.
[root@linuxforfreshers ~]#
But as you notice even though our shell was changed successfully but still we see bash shell prompt.

NOTE: To make the changes affect you need to log out and log back in
Using username "root".
root@192.168.8.130's password:
Last login: Fri Mar 21 10:15:03 2014 from 192.168.8.20
-sh-4.1# echo $SHELL
/bin/sh
-sh-4.1#

So now as I try to login I see my default login shell is changed to /bin/sh

Which file is responsible for assigning shell by default?
What if you want next time you create a user, he/she should get different shell and every time you don't change their shell manually

Check the below file
# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes


As you see the SHELL argument has /bin/bash as default. Just change this value to any shell you want to provide for a new user.

Thursday, November 26, 2015

what is mean by shell in linux?

What is a Shell?


The shell is an interactive command interpreter environment within which commands may be typed at a prompt or entered into a file in the form of a script and executed. The origins of the shell can be traced back to the early days of the UNIX operating. In fact, in the early days of Linux before the introduction of graphical desktops the shell was the only way for a user to interact with the operating system.

A variety of shell environments have been developed over the years. The first widely used shell was the Bourne shell, written by Stephen Bourne at Bell Labs.

Yet another early creation was the C shell which shared some syntax similarities with the C Programming Language and introduced usability enhancements such as command-line editing and history.

The Korn shell (developed by David Korn at Bell Labs) is based on features provided by both the Bourne shell and the C shell.

The default shell on RHEL 6 is the Bash shell (shorthand for Bourne again shell). This shell, which began life as an open source version of the Bourne shell, was developed for the GNU Project by Brian Fox and is based on features provided by both the Bourne Shell and the C Shell.


Gaining Access to the Shell

From within the GNOME desktop environment, the shell prompt may be accessed from a Terminal window either by selecting the Applications -> System Tools -> Terminal menu option or right clicking on the desktop and selecting Open in Terminal from the resulting menu. When remotely logging into an RHEL server, for example using SSH, the user is also presented with a shell prompt. When booting a server based system in which a desktop environment has not been installed, the shell is entered immediately after the user completes the login procedure at the console terminal or remote login session.

different type of shells in linux


Bourne Shell

    The original Bourne shell is named after its developer at Bell Labs, Steve Bourne. It was the first shell used for the Unix operating system, and it has been largely surpassed in functionality by many of the more recent shells. However, all Unix and many Linux versions allow users to switch to the original Bourne Shell, known simply as "sh," if they choose to forgo features such as file name completion and command histories that later shells have added.

C Shell

    The C shell, as its name might imply, was designed to allow users to write shell script programs using a syntax very similar to that of the C programming language. It is known as "csh."

TC Shell

    TC shell is an expansion upon the C shell. It has all the same features, but adds the ability to use keystrokes from the Emacs word processor program to edit text on the command line. For example, users can press Esc-D to delete the rest of the highlighted word. It is also known as "tcsh."

Korn Shell

    Korn Shell was also written by a developer at Bell Labs, David Korn. It attempts to merge the features of the C shell, TC shell and Bourne shell under one package. It also includes the ability for developers to create new shell commands as the need arises.

    It is known as "ksh."

Bourne-Again Shell

    The Bourne-Again shell is an updated version of the original Bourne shell that was created by the Free Software Foundation for its open source GNU project. For this reason, it is a widely used shell in the open source community.

    Its syntax is similar to that used by the Bourne shell, however it incorporates some of the more advanced features found in the C, TC and Korn shells.

    Among the added features that Bourne lacked are the ability to complete file names by pressing the TAB key, the ability to remember a history of recent commands and the ability to run multiple programs in the background at once.