Linux command to change shell

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:

/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.

Читайте также:  Open zip files with linux

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.

PID TTY TIME CMD 13964 pts/0 00:00:00 bash 22450 pts/0 00:00:00 csh 22451 pts/0 00:00:00 ps

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.
Читайте также:  Astra linux firefox зависает

How to Change Shells

  1. Temporarily changing your shell for the session you are in.
  2. 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.

PID TTY TIME CMD 13964 pts/0 00:00:00 bash 22450 pts/0 00:00:00 csh 22451 pts/0 00:00:00 ps

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.

Читайте также:  Linux kernel pci e

Источник

Как определить и изменить командную оболочку (shell) в Linux

Как изменить оболочку Shell в Linux

Командная оболочка или командный интерпретатор в Linux — это программа, которая в текстовой среде выступает в качестве интерфейса между пользователем и операционной системой. Она интерпретирует вводимые команды с терминала и вызывает необходимые программы.

Когда вы работаете в терминале, именно командная оболочка обрабатывает вводимые вами команды. Более того, оболочки Linux поддерживают написание программ на языке оболочки.

Оболочки Linux

Одна из самых популярных командных оболочек — это оболочка Bash (Bourne Again Shell). Она используется по умолчанию в большинстве дистрибутивов Linux.

Существуют разные оболочки Linux. Можно отметить:

Оболочки могут очень сильно отличаться друг от друга. Они отличаются функциональностью, синтаксисом команд, строкой приветствия, дружелюбностью к пользователю и другими параметрами и возможностями.

Как определить текущую командую оболочку

Есть несколько способов определить оболочку, используемую по умолчанию в вашей системе Linux. Рассмотрим несколько из них, так как в разных системах (и оболочках) какие-то способы могут не сработать.

Также нужно знать, что у разных пользователей системы могут использоваться разные оболочки.

Способ 1

Переменная окружения SHELL хранит путь до исполняемого файла оболочки. Выполним команду:

Из вывода команды, мы видим, что используется оболочка bash.

Способ 2

Также можно воспользоваться командой echo $0 . Данная команда выведет на экран имя текущего работающего процесса, внутри которого она выполнена. Так как мы выполняем команду внутри оболочки, то будет выведено имя оболочки.

Способ 3

Определим, работающий процесс оболочки командой ps.

ps -p $$ PID TTY TIME CMD 10792 pts/3 00:00:00 bash

Определить текущую оболочку Shell в Linux

Как посмотреть список оболочек, доступных в системе

Список оболочек, которые в данный момент установлены и доступны в системе Linux, хранится в файле /etc/shells

Выведем содержимое файла /etc/shells , для этого выполняем команду:

cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/bash /bin/rbash /bin/dash

Список командных оболочек Linux

Как временно переключиться на другую оболочку

Чтобы временно переключиться на другую оболочку, достаточно выполнить в терминале команду, соответствующую ее имени. После этого вы переключитесь на новую оболочку.

Например, переключимся на оболочку sh. Выполняем команду:

Переключиться на другую оболочку в Linux

Как изменить оболочку

Для изменения командной оболочки на постоянной основе служит команда chsh (от слов change shell).

Чтобы изменить оболочку текущего пользователя нужно выполнить команду:

В качестве параметра путь_новой_оболочки необходимо указать путь до исполняемого файла оболочки, который вы можете найти в файле /etc/shells (см. выше).

Например, изменим оболочку на sh. Для этого выполняем команду (при выполнении команды нужно будет ввести пароль):

После этого нужно выйти и снова войти в систему.

Чтобы изменить оболочку, используемую по умолчанию, для другого пользователя, то команде chsh необходимо указать имя этого пользователя:

Заключение

Мы рассмотрели, как определить текущую оболочку Linux, как просмотреть список доступных оболочек, а также как изменить оболочку, используемую по умолчанию.

Чтобы получить информацию о какой-либо оболочке (доступной в системе) можно воспользоваться Man-страницами. Например:

Дополнительные оболочки можно устанавливать средствами системы (из репозиториев). Например, для установки оболочки fish в Ubuntu Linux, выполните команду

Источник

Оцените статью
Adblock
detector