It is recommended that the root user use sh for explanations and modifications.

Source: Internet
Author: User
For more information about Linux general technology-Linux technology and application, it is best for root users to use sh. Original write: linuwa

In many systems, the default shell is sh, especially for root users. Why not use more comfortable bash or other shells?

You can think of it only for safety, but what is the reason?

Let's play.

A basic principle is that the system must be able to run the most basic program in case of serious faults. If your shell cannot be started, it will be almost useless.

Try the two commands ldd/bin/sh and ldd/bin/bash (note that the default installation directories of sh and bash vary with the system) to see what is the difference:

Different systems will get different answers, but there is one thing in common. sh depends less on things than bash, or even does not depend on things. (the result of a fedora user may be the same as that of bash, because sh ora links sh to bash by default), on Solaris earlier than version 10, you will also see that sh is a static Connection Program and does not rely on anything:

$ Ldd/sbin/sh
Ldd:/sbin/sh: file is not a dynamic executable or shared object

Static-link programs contain all the code and do not need to depend on other things. Their file size is larger than that of dynamic-link files.

If the dependent object is deleted or damaged, or the file system where the dependent object is located is damaged or not mounted,/bin/sh can still be executed.

Therefore, we recommend that you use/bin/sh (maybe/sbin/sh) as the default root shell.

However, bash is also safe for new versions of systems. bash in these systems only depends on things in/lib, And/lib exists in/file systems, so it is safer.

In addition, bash can be used for systems like Solaris, because it automatically switches to sh when bash fails.

I still have some questions that I don't understand. I 'd like to talk to you more. Thank you.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.