1

I changed my shell recently to ZSH, I heard people say they liked it a lot more than the default BA shell or BASH. Everything went fine, followed a guide word for word, and the guide did not miss lead me, however; as is the problem with such guides, I didn't really know what I was doing, which always bugs me, so I went back through the instructions, attempting to interpret there "under the hood" mechanics, but I don't really understand one of the commands. Can someone better explain, what exactly the command below does, and how it does it (I know it has something to do with setting the user).



The instruction for using this command read:

If you are logged in on a shell you are on a standard user, simply change your shell by running:

chsh -s $(which zsh)

Perhaps the part I understand the least is the word which, like why use which?

muru
  • 197,895
  • 55
  • 485
  • 740
JΛYDΞV
  • 211

1 Answers1

2
  1. chsh -> change shell
  2. -s -> specify which shell
  3. $(which zsh) -> run command which zsh and return it as operand to chsh -i

Some distributions store binaries (like your shell) in different locations. So there is no one-fits-all tutorial for chsh. To make sure you give a valid path to chsh, you can search for zsh. This are 2 steps, combined in one command.

  1. Search for zsh ("which zsh is provided by system to me")
  2. Set it as your shell.

The given command is failsafe and works on every Linux (and Unix) with chsh and zsh installed, no matter in which directory/path it is installed.

Pablo Bianchi
  • 15,657