Linux Login script

Source: Internet
Author: User
Linux Login script-general Linux technology-Linux programming and kernel information. The following is a detailed description. According to a study note In debian,. bash_profile is the bash global setting file, while. bashrc is the setting read when a bash shell calls another bash shell. When I configure debian, copy the content in/etc/. bash_profile to/root/. bashrc and comment out the following content based on the practices on the Internet.

If [-f/etc/bash_completion]; then
./Etc/bash_completion
Fi

Make the root account have the ability to complete the table.

So here is my problem. When I log on to linux, I directly log on to the root account and did not call other shells. So how do I copy these files. in bashrc, and comment out the above to make up? If I comment out the statements in. bash_profile, does the root account have the ability to complete? When I installed the system, I created a new user. This user does not need to be set in this step, so it has a complete effect. The. bashrc under this account has the above content. Why?

Let me explain it to you. Thank you.

Reply 1

1. first, we need to distinguish between login shell and non-login shell. login shell is the shell with authentication started when the user logs on. The shell name corresponding to username can be seen in/etc/passwd, commonly used is bin/bash. when login shell is started, two files are read, under/etc/profile and the user root directory. bash_profile (if not, it will be executed again ~ /. Bash_login ,~ /. Profile ).

2. shell is also divided into interactive shell and non-interactive shell. Obviously, login shell is also an interactive shell. For the non-login interactive shell, it will be executed at startup ~ /. Bashrc, and ~ /. Bashrc will execute/etc/bashrc again. For the login shell ~ /. Execute ~ in bash_profile ~ /. Bashrc, so modifications to. bashrc can affect all interactive shells.

3. when a new user is added, a record is added to the/etc/passwd directory, the home directory of the user is created, and the content under the/etc/skel directory is copied to the home directory, skel contains the basic file and directory structure of the user's home directory, including. bashrc. (Of course, these can be customized, such as useradd-k-m or something ).

Reply 2:

So
1. bashrc is indeed prepared for the non-login interactive shell. Login shell is not directly read, but is executed in. bahs_profile.
2. You can change the bash_profile of login shell. So whether to modify. bash_profile or. bashrc depends on the specific situation.
3. For questions about creating a user, see/etc/skel.

Of course, the most effective method is to change. bash_profile. log on and check out, add several files to/etc/skel, modify. bashrc, and create a new user. In view of the diversity of linux, practice + understanding is the king.

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.