O'Reilly logo

Learning the bash Shell, Second Edition by Bill Rosenblatt, Cameron Newham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System Security Features

UNIX security is a problem of legendary notoriety. Just about every aspect of a UNIX system has some security issue associated with it, and it’s usually the system administrator’s job to worry about this issue.

bash has two features that help solve this problem: the restricted shell, which is intentionally “brain damaged,” and privileged mode, which is used with shell scripts that run as if the user were root.

Restricted Shell

The restricted shell is designed to put the user into an environment where his or her ability to move around and write files is severely limited. It’s usually used for “guest” accounts. [137]You can make a user’s login shell restricted by putting rbash in the user’s /etc/passwd entry. [138]

The specific constraints imposed by the restricted shell disallow the user from doing the following:

  • Changing working directories: cd is inoperative. If you try to use it, you will get the error message bash: cd: restricted.

  • Redirecting output to a file: the redirectors >, >|, <>, and >> are not allowed.

  • Assigning a new value to the environment variables SHELL or PATH.

  • Specifying any pathnames with slashes (/) in them. The shell will treat files outside of the current directory as “not found.”

  • Using the exec built-in.

  • Specifying a filename containing a / as an argument to the . built-in command.

  • Importing function definitions from the shell environment at startup.

  • Adding or deleting built-in commands with the -f and -d options to the enable built-in command. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required