Display shells in linux

How to find list of available shells by command-line?

(IFS=: && grep -rl tcsetpgrp $PATH | xargs grep -rl setrlimit) on a Debian system seems to give a good approximation.

4 Answers 4

To list available valid login shells for use at time, type following command:

pandya@pandya-desktop:~$ cat /etc/shells # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash /bin/ksh93 

For information about shell visit wikipedia.

Note that this will not work for all systems. E.g. Solaris and HP-UX do not have an /etc/shells file by default.

You can also use chsh -l This will print the list of shells.

[anurag@focused ~]$ chsh -l /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin 

@Pandya can you provide the complete command you are using. You might be using it with combination of other shell methods or constructs like ((. )) or [. ] or [[. ]]

@Pandya man7.org/linux/man-pages/man1/chsh.1.html This provides -l option. Just click on the link on the top of the page, to go to linux-util man page

On at least OpenBSD and NetBSD:

On (Ubuntu) Linux and many other Unices (including BSDs):

On Solaris, the file /etc/shells may not exist. The list of valid shells is contained in the shells(4) manual. On my vanilla Solaris 11.3 system, this lists the following shells:

/bin/bash /usr/bin/bash /bin/pfbash /usr/bin/pfbash /bin/csh /usr/bin/csh /bin/pfcsh /usr/bin/pfcsh /bin/jsh /usr/bin/jsh /sbin/jsh /usr/sbin/jsh /bin/ksh /usr/bin/ksh /bin/pfksh /usr/bin/pfksh /bin/ksh93 /usr/bin/ksh93 /bin/pfksh93 /usr/bin/pfksh93 /bin/sh /usr/bin/sh /bin/pfsh /usr/bin/pfsh /bin/tcsh /usr/bin/tcsh /bin/pftcsh /usr/bin/pftcsh /sbin/sh /usr/xpg4/bin/sh /sbin/pfsh /usr/xp4/bin/pfsh /bin/zsh /usr/bin/zsh /bin/pfzsh /usr/bin/pfzsh /usr/sfw/bin/zsh 

It’s worth noting that on my installation, neither /usr/sfw/bin/zsh nor /usr/xp4/bin/pfsh exists.

A shorter list of valid Solaris shells (duplicates of each shell removed):

/bin/bash /bin/ksh /bin/pfcsh /bin/pfsh /bin/sh /bin/csh /bin/ksh93 /bin/pfksh /bin/pftcsh /bin/tcsh /bin/jsh /bin/pfbash /bin/pfksh93 /bin/pfzsh /bin/zsh 

Источник

How to check what shell I’m using on Linux

The shell on a Linux system is the layer that interprets the commands being executed by the user, and translates them into a language that the operating system can understand. The Bash shell is the default one in Linux, and typically what all users become familiar with first. But there are a lot of other shells that can be used, too; like sh, zsh, ksh, csh, and tcsh, to name a few.

Knowing what shell you are currently using is important, since each one will interpret commands a little differently. Some of them expect a different syntax than others. For example, a Bash script may work perfectly fine in Bash, but produce errors when executed with the sh shell. In this tutorial, we will show you how to check what shell you are using on Linux.

Читайте также:  Изменение времени создания файла linux

In this tutorial you will learn:

  • How to check what shell you are currently using
  • How to check a user’s default shell
  • How to generate a list of available shells on the system
  • How to change to a different shell

How to check what shell I'm using on Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to check what shell I’m using – example commands

DID YOU KNOW?
Linux user accounts can be configured to log in to a particular shell by default (for example, with the usermod command), or they can switch to a different shell after being logged in.

Let’s see how to check our current shell, display a list of usable shells, and switch to a different shell in Linux.

    First, let’s check what shell we are currently using. We can rely on the SHELL environment variable for this by executing the following command:

Checking what shell we are currently using in Linux

The command shows us that we are using the Bash shell, which is located at /bin/bash .

$ cat /etc/passwd | grep linuxconfig

The /etc/passwd file shows us that /bin/bash is our default configured shell

The final field in the output will show what shell a user is using by default when they log in.
We can get a full list of the shells installed on the system by executing the following command. Any of these are available to use, except some, like the /sbin/nologin shell, which serve a specific purpose and are not meant to be usable by people.

Checking which shells are available for use on our Linux system

Now, let’s see how we can change to a different shell, in case we recognize one from the list above that we would like to use instead of our current one. For this, we can just execute the full path of the shell we want to use. This command will log us into the sh shell.

Closing Thoughts

In this tutorial, we saw how to check what shell you are currently using on a Linux system. Experienced users may come to appreciate some of the functions offered outside of the Bash shell, and have the desire to switch every once in a while. Being able to quickly identify and switch between shells allows you to get the most out of your Linux command line experience, and always choose the right tool for the job.

Comments and Discussions

Источник

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

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

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

Читайте также:  Python на линукс запустить

Когда вы работаете в терминале, именно командная оболочка обрабатывает вводимые вами команды. Более того, оболочки 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, выполните команду

Источник

What is the Linux command to find out which shell you are using

In the Linux operating system, the shell is the medium between the user and the computer system which communicates the commands entered by the users in the terminal to the computer and tells it to perform the specified task. There are different types of shells, the first type of shell used in about 1976 was Bourne Shell (sh) and nowadays most Linux-based operating systems are using the GNU Bourne-Again Shell, commonly known as bash.

Читайте также:  Ноутбук dell inspiron linux

When we use any distribution of Linux, the first thing we want to know about the shell we are using, to find out information about the shell, different commands can be used, in this write-up, we will discuss those commands.

What are the commands to find out shells you are using in Linux

There are different types of shells installed when we login the Linux operating system, to list down all these shells, we use the command:

In the above output, we can see that the Bourne Shell (sh), the GNU Bourne-Again Shell (bash), and the Debian Almquist (dash) shell are installed in Linux. These shells have their own features and specifications but to know which shell is being used by our Linux, there are many commands, the first one which we are going to discuss is simply printing the value of variable $SHELL with the help of echo command:

The output shows that we are using the bash shell. Another way of finding shell is using the echo command:

Likewise, the shell can be found out by using the ps command, though the ps command is used to display the PIDs of all the running processes:

To specifically find the shell you are using with the help of the ps command, execute the following command with the flag “-p” which is for PID, and pass $$, to use the current PID of the shell:

The column under the name of “CMD” is displaying the shell name which you are using, likewise, the readlink command can also be used to display the shell:

One of the most used technique to find the shells is by accessing the /etc/passwd, it contains the important credentials likes usernames, passwords, and users, so we can use this path with the help of the grep command and display the shell you are using:

We used the grep command to display the details of variable $USER stored on the /etc/passwd, and the last command we are going to discuss in this write-up is the lsof command, it is used to list the open files and processes, but it can also be used to display the shell by using the flag “-p” with $$:

Conclusion

Shell plays an important role; it communicates the information given by the user to the computer and makes sure the user-specified tasks should be completed by the computer. In this write-up, we have discussed different commands through which we can find out the name of the shell we are using in Linux. There are different methods discussed in this write-up, all are convenient and most helpful.

About the author

Hammad Zahid

I’m an Engineering graduate and my passion for IT has brought me to Linux. Now here I’m learning and sharing my knowledge with the world.

Источник

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