Shell learning notes and shell scripts

Source: Internet
Author: User

Shell learning notes and shell scripts
I. source command

Function: read and execute commands in the configuration file in the current bash environment.

1. Command Format

Source configuration file or. Configuration File

2. Command example
[Root @ localhost ~] # Source/etc/profile # Make the/etc/profile configuration file take effect [root @ localhost ~] #./Etc/profile # same effect as the above command
Ii. Global Environment variable configuration file

The global environment variable configuration file takes effect for all users.

1./etc/profile

Purpose:

1) define the USER variable, LOGNAME variable, MAIL variable, PATH variable, HOSTNAME variable, and HISTSIZE variable

2) define the default system permission umask

3) Call the/etc/profile. d/*. sh file.

2./etc/profile. d/*. sh3./etc/bashrc

Purpose:

1) define PS1 (command prompt) variables

2) umask

3) define the PATH variable

4) Call the/etc/profile. d/*. sh file.

3. USER environment variable configuration file

Each user has the following two environment variable configuration files, which will only take effect for the user to which they belong.

1 .~ /. Bash_profile

Purpose:

1) Call ~ /. Bashrc File

2) add the ": $ HOME/bin" directory after the PATH variable.

2 .~ /. Bashrc

Purpose:

1) define the alias of rm cp mv

2) Call/etc/bashrc

Iv. Execution Process of environment variable files

1. If the user logs on normally, it will be loaded from/etc/profile to/etc/bashrc

2. the user logs on to [not login shell] abnormally. For example, if the user switches over through su, it will start to run from/etc/bashrc, and finally to/etc/sysconfig/i18n.

5. Other environment variable configuration files 1 .~ /. Bash_logout

Environment variable configuration files that take effect upon cancellation are generally not used. Common commands added include clear (clear screen) and history-c (clear history command ).

Example:

2 .~ /. Bash_history

Operation History commands are used to store files. Only when you log out, the operation commands during user logon are written to the file. The commands executed during logon are not immediately written to the file, it is written in the memory.

3./etc/issue

Welcome information of the local terminal, which cannot be seen through remote logon.

Example:

Logon result:

4./etc/issue.net

Remote Login welcome information

Note: whether to display this welcome message is determined by the ssh configuration file (/etc/ssh/sshd_config). After adding the "Banner/etc/issue.net" line, restart the ssh service.

Example:

5./etc/motb

After logging on, the welcome information is displayed, whether it is local logon or remote logon.

 

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.