I connect to a server via ssh.
Now i wanted to set the shell to bash, because at the moment the shell is sh.
sudo /sbin/usermod -s /usr/bin/bash santi
Should i use /bin/bash
or /usr/bin/bash
or does it not matter?
I connect to a server via ssh.
Now i wanted to set the shell to bash, because at the moment the shell is sh.
sudo /sbin/usermod -s /usr/bin/bash santi
Should i use /bin/bash
or /usr/bin/bash
or does it not matter?
The permitted shells are listed in the file /etc/shells
.
Run the chsh
from the santi
account, without sudo. It will prevent you from using a non-permitted shell.
The administrator can set a non-permitted shell, but that's a bad idea unless you're deliberately setting up a user account with restricted access. One reason is that ordinary users can't change it anymore. Another reason is that distributions keep /etc/shells
updated, so an upgrade won't prevent users from logging in, but if you use administrator powers to give an account a non-permitted shell, then the burden is on you to be careful not to lock that account out.
ftpd
treats users differently depending on whether their login shell is in /etc/shells
.
– Barmar
May 05 '23 at 14:31
For determine what is the path of the bash
executable on your system, you can use the following command:
command -v bash
You can list available shells on your system too:
cat /etc/shells
If you want an interactive way to set the shell:
chsh <userame>
Hope this helps !
If bash is available both in /bin/bash
and /usr/bin/bash
(typically because /bin
is a symlink to /usr/bin
due to the /usr merge) it does not matter. Both will work on this system
I would however prefer to use /bin/bash
over /usr/bin/bash
, as that's the traditional location where it was installed, and it would be more compatible if run in other systems (if instead of being a manual step this was included on a script that might be run on multiple machines, or if the location of bash was for writing it on a shebang)
One of them is probably a link to the other...
Traditionally, shells (like bash, csh and zsh) are located in /bin - because a shell is needed even in single user mode or other times when /usr may be unmounted (/usr is often on a separate partition and may even be mounted through the network - thus not readily available in singe user mode).
On the other hand, additional shells (than the default one/ones) aren't strictly needed in single user mode (unless root happens to use one of them), so it's natural to put such shells it in /usr/bin instead of /bin.
what's the difference between /bin/zsh and /usr/bin/zsh?
Both /bin/bash
and /usr/bin/bash
are valid paths for the Bash shell executable.
The difference between /bin/bash
and /usr/bin/bash
is historical and depends on the system conventions and configuration.
Traditionally, Bash was installed in the /bin
path on Unix systems, some modern Linux distributions store it in the /usr/bin
path.
Most system create symbolic link from /bin/bash to /usr/bin/bash, which means that both paths are equivalent.
/usr/bin
is the default location for user-level executables on most modern Linux distributions. This path contains user-installed executables and is typically not mounted until later in the boot process.
/usr/bin/bash
is the path to the bash executable if it is installed in this location.
The symbolic link ensures that legacy scripts and applications that reference /bin/bash
will continue to work correctly even if the Bash executable is installed in /usr/bin
You can use /bin/bash
or /usr/bin/bash
in the usermod
command to set the shell for the user santi
Both will work correctly.
zsh is in /usr/bin, but also in /bin, what is the difference?
Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin
Difference between /bin/bash and /usr/bin/bash
What is the difference if I start bash with "/bin/bash" or "/usr/bin/env bash"?
/bin/bash
? or as/usr/bin/bash
? or in both places? If in both places, is it the same Bash? Is/bin
symlinked tousr/bin
maybe? – Kamil Maciorowski May 04 '23 at 10:00