Changing a user's default shell
As root, you can set a user's shell to whatever you like with chsh
or any other method (e.g. editing /etc/passwd
with vipw
), just remember to use the full pathname to the executable.
If you want a user to be able to choose it as their shell with chsh
, you first have to add it to /etc/shells
, which is a list of full pathnames of valid shells.
You can't change another user's shell unless you are root, you can only change your own shell.
Related videos on Youtube
Hayes121
Updated on September 18, 2022Comments
-
Hayes121 over 1 year
I have created a simple C shell on my local Linux server. I am trying to learn how to change the default shell of another user (
bob
) to be this new C shell that I have created.Is it possible to changing the default shell of my user
bob
so that when I log in as him, he will be using the C shell I made?Do I need to add the
.C
file into the/bin/bash
folder and then changing the starting shell forbob
in my root account? -
Hayes121 over 8 yearsIf I am logged in as user1 where the .c file is, how would I go about moving that to /etc/shell?
-
Alessio over 8 yearscan only be added to
/etc/shells
as root. e.g. withsu
orsudo
. -
terdon over 8 years@Hayes121
/etc/shells
is a file that lists all available shells. You would need to edit that file as root and add/path/to/your/shell
to it. -
Hayes121 over 8 yearsI have moved the shell into /etc/shell, so now when I have the executable C file in /etc/shell, path to file name is now /etc/shell/shell1 but when I try 'chsh -s /etc/shell/shell bob' I get an error an error saying /etc/shell/shell1 isnt a directory
-
Alessio over 8 yearsthat makes no sense. you add the full path to your shell (e.g.
/usr/local/bin/myfabulousshell
) to the list of valid shells in/etc/shells