Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

Hi,

Is there a way to determine what shells are available on a Linux box other than trying out /bin/shellname ?

Even a workaround would do :)

Thanks.

asked 03 May '10, 08:16

Knight%20Samar's gravatar image

Knight Samar
885
accept rate: 33%




Have you a look in /etc/shells?

cat /etc/shells

Thinking about this further you could also make use of "whatis" command for any shells that are not listed in "/etc/shells".

cd /bin; whatis * | grep -i 'shell'

This will list any shells in '/bin' that have a description that contains the word "shell". It may also be worth doing this in other directories such as /usr/bin, /sbin. This may produce the odd false positive but should give you something to work with.

link

answered 03 May '10, 09:31

gjcwilliams's gravatar image

gjcwilliams
35729
accept rate: 37%

edited 03 May '10, 11:09

3

Some shells listed in /etc/shells might not be there, something like this might help: for i in $(</etc/shells) ; do [[ -x $i ]] && echo $i ; done

(03 May '10, 16:34) jlliagre

Nice work of a for loop jlliagre.

(03 May '10, 19:36) bullium

@gjcwilliams thanks, i didn't know there was a /etc/shells. and thanks for the neat trick using 'whatis'. It never crossed my mind, i could do that !

@jilliagre, thanks for the trick! It works great too!

I am already loving LinuxExchange!

(05 May '10, 09:32) Knight Samar

which and whereis, along with locate. on a newly installed machine run

# updatedb

when you first install the OS so you can use locate, which likes specific syntax,but shows everything matching.

And on Slackware you can grep /var/log/packages for a match.

For determining, say, whether you had ruby installed, you would type:

# which ruby

And if ruby is installed, you should get back:

/usr/bin/ruby

...others are python, bash, tclsh, tcsh, zsh, ksh, tksh, sh (usuallaly just a symlink to /usr/bin/bash, but will actually point to /bin/tcsh if you choose the C shell as your particular user's default.

man whereis

man which

man locate

to quickly determine the default shell for any particular user simply grep /etc/password for their username and examine the designated shell (or lack thereof) there.

$ cat /etc/passwd |grep jschmoe

I hope that helps!

Kindest regards,

Bradley

.

link

answered 15 May '10, 12:31

tallship's gravatar image

tallship
390111
accept rate: 20%

@tallship but that requires me to try out all shells that may be which thus require me to know what shells are out there. As I stated in my question, I wanted to know a way wherein I can know what shells are available on the box other than trying out each shell.

(17 May '10, 18:22) Knight Samar

@Knight_Samar: That is how you tell without as you say, "trying out each shell". this simply proves the existence of the shells and returns an error if they don't exist - because /etc/shells can have bogus entries (which is common for say, chroot'd accounts for ftp only configs, etc.), and as I pointed out above, is incomplete because it fails to list many shells, like the ones I listed above.

You can use the "whatis" construct above, but as even gjcwilliams points out himself in his post - it can provide false positives.

The way I provided shows you definitively.

Hope that helps!

Bradley

(24 May '10, 19:24) tallship

I'm not sure whether the following will double-check the actual existance of the shell files but it should work and looks a little neater too:

chsh -l

link

answered 12 May '10, 17:54

pmarini's gravatar image

pmarini
286216
accept rate: 28%

chsh has only -h and -s options on ubuntu 9.04 :(

so no listing possible.

(12 May '10, 22:31) Knight Samar
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8
×4

Asked: 03 May '10, 08:16

Seen: 2,329 times

Last updated: 15 May '10, 12:31

powered by OSQA