Changing a user's default shell

12,844

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.

Share:
12,844

Related videos on Youtube

Hayes121
Author by

Hayes121

Updated on September 18, 2022

Comments

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

  • Hayes121
    Hayes121 over 8 years
    If I am logged in as user1 where the .c file is, how would I go about moving that to /etc/shell?
  • Alessio
    Alessio over 8 years
    can only be added to /etc/shells as root. e.g. with su or sudo.
  • terdon
    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
    Hayes121 over 8 years
    I 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
    Alessio over 8 years
    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