• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Configure Restricted Bash Shell in Linux

by admin

Restricted bash shell can be invoked using below command:

# bash -r

The ‘/bin/rbash‘ represents the restricted bash shell and can be created by creating as a soft link to ‘/bin/bash’ as shown below:

# ln -s /bin/bash /bin/rbash

Once soft link for /bin/rbash is created, one can launch restricted bash shell using below command:

# rbash

If bash is started with the name ‘rbash’ or the ‘-r’ option is supplied at invocation, the shell becomes restricted. Below is the output from man page of bash command:

A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the following are disallowed or not performed:

1. Changing directories with cd.
2. Setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV
3. Specifying command names containing /
4. Specifying a file name containing a / as an argument to the . builtin command
5. Specifying a filename containing a slash as an argument to the -p option to the hash builtin command
6. Importing function definitions from the shell environment at startup
7. Parsing the value of SHELLOPTS from the shell environment at startup
8. Redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
9. Using the exec builtin command to replace the shell with another command
10. Adding or deleting builtin commands with the -f and -d options to the enable builtin command
11. Using the enable builtin command to enable disabled shell builtins
12. Specifying the -p option to the command builtin command
13. Turning off restricted mode with set +r or set +o restricted.

These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed (see COMMAND EXECUTION above), rbash turns off any restrictions in the shell spawned to execute the script.

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. Beginners guide to Kernel Module Configuration in Linux
  2. pscp – ssh_init: Network error: Cannot assign requested address
  3. 3 Ways of Increasing Swap Space on Linux
  4. fdisk: Unable to write /dev/sdg: Bad file descriptor – error while formatting USB disk
  5. tuned-adm and Oracle
  6. Linux OS Service ‘cups’
  7. Using vmstat to troubleshoot performance issues in Linux
  8. CentOS / RHEL 7 : How to configure VLAN Tagging using nmcli
  9. CentOS / RHEL 6 : How do I find my current runlevel?
  10. yum Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright