2

lets assume I am user(with no rights) and I need to change my shell as a default to /bin/bash by editing a file. So where I can find a file for a specific user where I can edit my default shell and set it permanently without involving an administrator.

And also, is there any command to change my own shell on top of that I can edit in the file directly.

I have tried to find something, but is only telling commands and files only if you have root access.

Thank you.

Antoshjke
  • 121
  • 2
    lets assume your default shell is tcsh and your account is properly set up. You have a .tcshrc file in your home directory. As the first line in this file you place the command /bin/bash. As soon as it hits, you will have a bash shell. – MelBurslan Mar 24 '16 at 04:37
  • other have answer, but just for information, the file to edit is /etc/passwd, but chsh will do it for you. you ay also use chfn to change information about current user. – Archemar Mar 24 '16 at 07:41
  • @Archemar No, the right way to change the shell is chsh. /etc/passwd is where the shell setting is stored, but only if the account is a local one, and not on all Unix variants (most if not all provide the information in /etc/passwd, but it might be generated from some other file), and even if that's the place where the setting is stored you shouldn't edit it manually. – Gilles 'SO- stop being evil' Mar 24 '16 at 22:45

1 Answers1

6

You don't need root access to change your own shell to any shell listed in /etc/shells.

Just run chsh -s /bin/bash.

A normal user can only change their own shell. And only to one of the shells listed in /etc/shells. Root can change any user's shell to anything at all.

see man chsh for details.

NOTE: root may disable this if they choose, e.g. by removing the setuid bit on /usr/bin/chsh or by listing only one or two shells in /etc/shells. There's little point in doing this, however, because (as MelBursian points out in his comment) the user can always run exec bash in the .rc or .profile file for their current shell. or just type exec bash as their first command when they login.

cas
  • 78,579