Ubuntu Wiki
A shell is a program that provides the traditional, text-only user interface for Unix-like operating systems. Its primary function is to read commands that are typed into a console (i.e., an all-text display mode) or terminal window (an all-text window) in a GUI (graphical user interface) and then execute (i.e., run) them.
Although bash, the default shell on many Debian based Linux distros like Ubuntu and Linux Mint, is highly versatile and can be used for almost anything, each shell has its own characteristics and there might be situations in which it is preferable to use some other shell, such as ash, csh, ksh, sh or zsh. For example, the csh shell has a syntax that resembles that of the highly popular C programming language, and thus it is sometimes preferred by programmers.
Short Description of the main shells
Bourne: the standard default shell for non root users in FreeBSD. You can read about the shell by looking at the "man sh" pages. Uses abbreviation sh.
Korn: a shell developed by AT &T. You can read more about it by looking at the "man ksh93" pages. Uses abbreviation ksh or ksh93.
Bash: The Bourne Again SHell. You can read about it in the "man bash" pages. Uses abbreviation bash.
Z-Shell: The Z shell. You can read about it by looking at the "man zsh" pages. Uses the abbreviation zsh.
C-Shell: The C shell. You can read about it by looking at the "man csh" pages. Uses the abbreviation csh.
TC-Shell: Basically the same thing as above. They are a little bit different, but not very much so they now fall into the same category. You can read about it by looking at the "man tcsh" pages. Uses the abbreviation tcsh.
How to find out what shell you are running:
Here is what you may see:
/bin/sh : This is the Bourne shell.
/bin/ksh93 : This is the Korn shell.
/bin/bash : This is the Bash shell.
/bin/zsh : This is the Z shell.
/bin/csh : This is the C Shell.
/bin/tcsh : This is the TC Shell.
Next Check on your Valid login Shells
Important Note: You May not have all of these installed on your system right now. The way I checked If a shell was installed my system was by looking to see if I had man pages for a particular shell. I will use csh as an example. Type this into your terminal.
If you don’t have any man pages then there is a high probability you don’t have this shell on your system. There is one other way to test this. Type this into your terminal.
If you have csh installed on your system you will see something similar to this.
If you don’t have csh installed on your system then install it will this command.
Why change your shell
The UNIX shell is most people’s main access to the UNIX operating system and as such any improvement to it can result in considerably more effective use of the system, and may even allow you to do things you couldn’t do before. The primary improvement most of the new generation shells give you is increased speed. They require fewer key strokes to get the same results due to their completion features, they give you more information (e.g. showing your directory in your prompt, showing which files it would complete) and they cover some of the more annoying features of UNIX, such as not going back up symbolic links to directories.
Deciding on a shell
Which of the many shells you choose depends on many different things, here is what I consider to be the most important, you may think differently.
- There is no point in using a shell with a different syntax, or a completly different alias system if you havn’t the time to learn it. If you have the time and are presently using csh or tcsh it is worth considering a switch to a Bourne shell variant.
- The main reason for switching shells is to gain extra functionality; its vital you know what you are gaining from the switch.
- If you may have to switch back to a standard shell, it is fairly important you don’t become too dependent on extra features and so can’t use an older shell.
- The more advanced shells tend to take up extra CPU, since they work in cbreak mode; if you are on an overloaded machine they should probably be avoided; this can also cause problems with an overloaded network. This only really applies to very old systems nowadays.
- If your new shell is not supported make sure you have someone you can ask if you encounter problems or that you have the time to sort them out yourself.
- Switching between certain shells of the same syntax is alot easier than switching between shells of a different syntax. So if you havn’t much time a simple upgrade (eg csh to tcsh) may be a good idea.
- Like most software all shells have some bugs in them (especially csh), can you afford the problems that may occur because of them.
How to Change Shells
- Temporarily changing your shell for the session you are in.
- Changing your login shell which is permanent.
Temporarily changing your shell for the session you are in
I will use csh as again an example. I will assume you already have csh installed on your system. All you need to do is type the command below into your terminal.
There are a few ways to verify this. This first comes from above.
If you have csh installed on your system you will see something similar to this.
The second: Upon changing shells, a different command prompt (i.e., the short text message at the left of each command line) may be shown, depending on the previous and new shells. For example, if the original shell were bash and the new shell is sh, the command prompt would change for a user george from something like [george@localhost george]$ to something like sh-2.05b$.
To return to the original shell, or any other one for that matter, all that is necessary is to just type its name and then press the ENTER key. Thus, for example, to return to the bash shell from the sh shell (or from any other shell), all that is required is to type the word bash or exit.
Changing your login shell which is permanent
You will use a program called chsh. There is a interactive method and non-interactive method. Type this into your terminal.
interactive method
This results in a brief dialog in which the user is prompted first for its password and then for the full path of the desired new shell.
Caution should be exercised when changing one’s default shell because it is possible to make an error that only the root user (i.e., system administrator) can repair (although it should be easy for a skilled user to repair it on a home system). In particular, it is important to first test the shell temporarily in the current session and then to make certain that a valid shell name is being entered when making the permanent change.
non-interactive method
I will use csh as again an example.
The -s sets it for you without having to go into the editor to do it.
Okay you did the command and it went ok.but the echo says it is the same. Log out and back it for the change to take effect.Then do echo $SHELL. You should see it show the new shell.
More information
If you would like more information I recommend reading these websites.
ChangingShells (последним исправлял пользователь 63-144-199-3 2010-12-02 10:49:22)
The material on this wiki is available under a free license, see Copyright / License for details.
How Can I Make /bin/sh point to /bin/bash?
In Ubuntu, /bin/sh points to /bin/dash by default.
I want to use /bin/bash as my system-wide shell for /bin/sh . What is the best way to do this?
1 Answer 1
As shown on this Ubuntu wiki page, you should run
and select the option not to use /bin/dash as the default shell. Making the change this way will not only fix the symlink /bin/sh , but will also configure other parts of your system to behave correctly, such as making sure that man sh points to the bash manpage instead of the dash one.
3 способа изменить пользовательскую оболочку по умолчанию в Linux
В этой статье мы расскажем, как изменить оболочку пользователя в Linux. Оболочка — это программа, которая принимает и интерпретирует команды; есть несколько оболочек, таких как bash, sh, ksh, zsh, fish и многие другие менее известные оболочки, доступные в Linux.
Bash (/ bin/bash) — популярная оболочка в большинстве, если не во всех системах Linux, и обычно это оболочка по умолчанию для учетных записей пользователей.
Есть несколько причин для изменения пользовательской оболочки в Linux, включая следующие:
- Чтобы заблокировать или отключить вход обычных пользователей в Linux с помощью оболочки nologin.
- Используйте сценарий или программу оболочки оболочки для входа в пользовательские команды перед их отправкой в оболочку для выполнения. Здесь вы указываете оболочку оболочки как оболочку входа пользователя.
- Для удовлетворения требований пользователей (желающих использовать определенную оболочку), особенно тех, у кого есть права администратора.
При создании учетных записей пользователей с помощью утилит useradd или adduser можно использовать флаг —shell для указания имени оболочки входа пользователя, отличного от указанного в соответствующих файлах конфигурации.
Доступ к оболочке входа в систему можно получить из текстового интерфейса или через SSH с удаленной машины Linux. Однако, если вы входите в систему через графический интерфейс пользователя (GUI), вы можете получить доступ к оболочке из эмуляторов терминала, таких как xterm, konsole и многих других.
Давайте сначала перечислим все доступные оболочки в вашей системе Linux, введите.
Прежде чем продолжить, обратите внимание, что:
- Пользователь может изменить свою собственную оболочку на что угодно: что, однако, должно быть указано в файле/etc/shells.
- Только root может запускать оболочку, не указанную в файле/etc/shells.
- Если учетная запись имеет ограниченную оболочку входа, то только root может изменить оболочку этого пользователя.
Теперь давайте обсудим три различных способа изменения пользовательской оболочки Linux.
1. Утилита usermod
usermod — это утилита для изменения данных учетной записи пользователя, хранящихся в файле/etc/passwd, а параметр -s или —shell используется для изменения оболочки входа пользователя .
В этом примере мы сначала проверим информацию учетной записи пользователя tecmint, чтобы просмотреть его оболочку входа по умолчанию, а затем изменим ее оболочку входа с/bin/sh на/bin/bash следующим образом.

2. Утилита chsh
chsh — это утилита командной строки для изменения оболочки входа с помощью параметра -s или –shell, подобного этому.

Два вышеуказанных метода изменяют оболочку, указанную в файле/etc/passwd, который вы можете редактировать вручную, как в третьем методе ниже.
3. Измените пользовательскую оболочку в файле/etc/passwd.
В этом методе просто откройте файл/etc/passwd с помощью любого из ваших любимых текстовых редакторов командной строки и измените оболочку конкретного пользователя.
Когда вы закончите редактирование, сохраните и закройте файл.
Не забудьте прочитать эти связанные темы:
- Общие сведения о файлах инициализации оболочки и профилях пользователей в Linux
- Общие сведения о оболочке Linux и основные советы по созданию сценариев оболочки — Часть I
- Как писать и использовать собственные функции оболочки и библиотеки
- Понимание различных классификаций команд оболочки и их использования
В этой статье мы описали различные способы изменения оболочки пользователя в Linux. Чтобы поделиться с нами любыми мыслями, используйте раздел комментариев ниже.
How do I switch from an unknown shell to bash?
I was surprised that I didn’t find this question already on the site. So, today $ came up after I logged in as a new user. This was unexpected because my main user’s prompt starts with username@computername:
So, how do I switch from this other shell to bash?
![]()
$ doesn't mean it wasn't bash. The exact formatting of the prompt is set by the PS1 variable, which can be set up or customized differently for different users.
3 Answers 3
Assuming the unknown shell supports running an absolute command, you could try: /bin/bash
To change the default shell, I would use chsh(1) . Sample usage: chsh -s /bin/bash $USER
![]()
You type in bash . If you want this to be a permanent change the default shell to /bin/bash by editing /etc/passwd .
Here’s some snippets from my /etc/passwd :
The very last field contains the shell, Modifying the field after the last : to a valid or invalid shell will work. /bin/false and /sbin/nologin both mean the user doesn’t have a real login shell, although if pam is not set up right this doesn’t mean they can’t login (I reported a bug on this in Arch Linux, because you can login graphically without having a login shell). /bin/bash and /bin/zsh are both valid shells, see /etc/shells for a list of valid shells on your systems. Here’s my /etc/shells if you’re interested.
Yes you can use chsh or usermod to do the same things, please remember these are just structured text files, and TIMTOWTDI.