ArticleslgStudy

science

Chsh

Chsh is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Chsh rather than just read about it. In short: chsh (an abbreviation of "change shell") is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case chsh allows the user to change the shell interactively.

Key takeaways

  • Chsh belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Chsh to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Chsh from memory before moving on to harder problems.

Reference excerpt

chsh (an abbreviation of "change shell") is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case chsh allows the user to change the shell interactively.

Usage chsh is a setuid program that modifies the /etc/passwd file, and only allows ordinary users to modify their own login shells. The superuser can modify the shells of other users, by supplying the name of the user whose shell is to be modified as a command-line argument. For security reasons, the shells that both ordinary users and the superuser can specify are limited by the contents of the /etc/shells file, with the pathname of the shell being required to be exactly as it appears in that file. (This security feature is alterable by re-compiling the source code for the command with a different configuration option, and thus is not necessarily enabled on all systems.) The superuser can, however, also modify the password file directly, setting any user's shell to any executable file on the system without reference to /etc/shells and without using chsh. On most systems, when chsh is invoked without the -s command-line option (to specify the name of the shell), it prompts the user to select one. On Mac OS X, if invoked without the -s option, chsh displays a text file in the default editor (initially set to vim) allowing the user to change all of the features of their user account that they are permitted to change, the pathname of the shell being the name next to "Shell:". When the user quits vim, the changes made there are transferred to the /etc/passwd file which only root can change directly. Using the -s option (for example: % chsh -s /usr/local/bin/bash) greatly simplifies the task of changing shells. Depending on the system, chsh may or may not prompt the user for a password before changing the shell, or entering interactive mode. On some systems, use of chsh by non-root users is disabled entirely by the sysadmin. On many Linux distributions, the chsh command is a PAM-aware application. As such, its behaviour can be tailored, using PAM configuration options, for individual users. For example, an auth directive that specifies the pam_listfile.so module can be used to deny chsh access to individual users, by specifying a file of the usernames to deny access to with the listfile= option to that module (along with the sense=deny option).

Portability POSIX does not describe utilities such as chsh, which are used for modifying the user's entry in /etc/passwd. Most Unix-like systems provide chsh. SVr4-based systems provided a similar capability with passwd. Two of the three remaining systems (IBM AIX and HP-UX) provide chsh in addition to passwd -e. The exception is Solaris, where non-administrators are unable to change their shell unless a network name server such as NIS or NIS+ is installed. The obsolete SGI SVr4 system IRIX64 also lacked chsh.

See also Comparison of command shells

References

Further reading Cynthia Gibas and Per Jambeck (2001). Developing Bioinformatics Computer Skills. O'Reilly. pp. 89–90. ISBN 1565926641. — some examples of invoking chsh with the -s and -l options

External links

chsh(1) – 4.2BSD General Commands Manual chsh(1): change your login shell – Linux User Commands Manual chsh(1) – Darwin and macOS General Commands Manual passwd(1) – Solaris 11.4 User Commands Reference Manual

Worked examples

Example 1 — a first encounter with Chsh

Start with the simplest possible case. Write down what Chsh claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Chsh before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Chsh ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Chsh

In research
Chsh appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Chsh in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Chsh is common in secondary-school and first-year university syllabi. It links to neighbouring topics Standard Unix programs, Unix user management and support-related utilities, so understanding it makes those chapters shorter.
In everyday life
Look for Chsh outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Chsh” →

How to study Chsh in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Chsh means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Chsh out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Chsh in simple terms?

chsh (an abbreviation of "change shell") is a command on Unix-like operating systems that is used to change a login shell. Users can either supply the pathname of the shell that they wish to change to on the command line, or supply no arguments, in which case chsh allows the user to change the shel…

Why does Chsh matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Chsh?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Chsh.

Tags

  • Standard Unix programs
  • Unix user management and support-related utilities

Keep exploring