Shell script execution and configuration files

Source: Internet
Author: User
Tags define local

Linux shell script execution and configuration files
  • Bash Script Execution method:

    1 interpreter runs/usr/bin/bash bash foo.sh 2 run script with path (requires x permission) chmod +x foo.sh/path/to/foo.sh 3 use. or so The Urce command executes the script.        /path/to/foo.sh source/path/to/foo.sh The difference between the execution method and the 3 execution method: 1, 2: The interpreter being executed is a subroutine and therefore does not affect the variables of the current shell. 3: The interpreter being executed is the current shell program, which reads the variables and overwrites the variables for the current environment. (typically used to set default variables)
  • Bash's configuration file

         Global Configuration         /etc/profile         /etc/profile.d/*.sh        /etc/bashrc      Personal Configuration         ~/.bashrc         ~/.bash_profile        ~/.bash_logout         profile Series File:              (1)   for defining environment Variables              (2)   Run a command or script         BASHRC series file:              (1)   define command aliases and functions               (2)   Define local variables         .bash_logout:              scripts executed before the user exits the login 
  • Bash Interactive login and non-interactive login

    Interactive logon and non-interactive logon differences: Read profile different switch command: SU USERNAME non-interactive su-username interactive logon interactive logon read profile order:/et        C/profile---/etc/profile.d/*.sh---~/.bash_profile----~/.BASHRC to read the configuration file in sequence: /ETC/BASHRC-~/.BASHRC-/etc/profile.d/*.sh Note: When the interactive shell switches to a non-interactive shell, it first inherits all the variables of the parent shell, then reads the variables in the corresponding configuration file and Overwrite an existing variable.


  • Variable check and change

        set        set   lists the variable names and their values in the current shell     env        env   list the current shell environment variables      unset        unset name       Remove variable names     $-   show enabled features for set         #  echo $-        himBH             h :  whether to open hash         Whether     i :  is an interactive shell             m :  whether to open job control             b  :  whether to open the extended functionality of {}             C :  Whether override redirection is turned on   &Nbsp;         h :  whether to enable the history expansion command and use! Wait for the shortcut call 


This article is from the "12064120" blog, please be sure to keep this source http://12074120.blog.51cto.com/12064120/1963915

Shell script execution and configuration files

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.