5

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 for bob in my root account?

1 Answer 1

13

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.

6
  • If I am logged in as user1 where the .c file is, how would I go about moving that to /etc/shell?
    – Hayes121
    Oct 21, 2015 at 12:03
  • can only be added to /etc/shells as root. e.g. with su or sudo.
    – cas
    Oct 21, 2015 at 12:04
  • @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.
    – terdon
    Oct 21, 2015 at 12:05
  • 1
    that 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
    – cas
    Oct 21, 2015 at 12:11
  • 1
    and you can't change another user's shell unless you are root. and if you are root, you can set it to anything whether it is listed in /etc/shells or not
    – cas
    Oct 21, 2015 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .