[Go] Linux Source command

Source: Internet
Author: User

SOURCE Command usage:
SOURCE FileName
Function: Reads and executes the commands in the filename under the current bash environment.
Note: This command usually uses the command "." To replace.
such as: source. BASH_RC and. The. BASH_RC is equivalent.

The source command (from C Shell) is a built-in command of the bash shell. The point command, which is a dot symbol, is another name for source (from the Bourne shell). Similarly, the variables that are configured in the current script will be used as the scripting environment, and the source (or point) command is often useful for re-executing the newly modified initialization document, such as. Bash_profile and. Profile, and so on. For example, if you modify the Editer and term variables in. bash_profile After logging in, you can use the source command to re-execute the. bash_profile command without logging off and logging back in.
For example, you export $KKK in a script = 111, if you use./a.sh execute the script, after execution, you run the Echo $KKK, found that there is no value, if you use source to execute, and then echo, you will find kkk=111. Because calling./a.sh to execute the shell is run in a child shell, after execution, the structure does not react to the parent shell, but the source is different he executes in this shell, so he can see the result
The source command (from C Shell) is a built-in command of the bash shell. The point command, which is a point symbol, is another name for source (from the Bourne shell). Both commands are parameterized with a script that executes as the current shell's environment, that is, a new child process is not started. All variables set in the script will become part of the current shell. Similarly, the variables set in the current script will also be used as the scripting environment, and the source (or point) command is often useful for re-executing the newly modified initialization files, such as. Bash_profile and. Profile, and so on. For example, if you modify the Editer and term variables in. bash_profile After logging in, you can use the source command to re-execute the. bash_profile command without logging off and logging back in. Like. Bash_profile or other similar shell scripts this way, files can be executed with the source or point command without having to execute the permission. A magical magic of the source command when compiling the core, it is often necessary to repeatedly enter a long list of commands, such as make Mrproper
Make Menuconfig
Make DEP
Make clean
Make Bzimage
.......
These commands are both long and cumbersome. And sometimes it's easy to lose, wasting your time and energy. If you put these commands into a file and let it be executed automatically in order, it would be convenient for users who need to repeatedly compile the core multiple times. This can be done with the source command. It works by treating the contents of a file as a shell. First create a file in the/usr/src/linux-2.4.20 directory, named Make_command:
Enter the following:
Make Mrproper &&
Make Menuconfig &&
Make DEP &&
Make Clean &&
Make Bzimage &&
Make Modules &&
Make Modules_install &&
CP Arch/i386/boot/bzimge/boot/vmlinuz_new &&
CP System.map/boot &&
Vi/etc/lilo.conf &&
Lilo-v
After the file is set up, each time you compile the core, you only need to enter it under/usr/src/linux-2.4.20.
SOURCE Make_command
On the line. This file can also be fully scripted, with just a few tweaks. The main point here is to let you understand the use of source. If you are not using LILO to guide the system, you can remove the last two sentences. Configure your own boot program to boot the new kernel. commands in shell programming are sometimes the same as the C language. && expression with, | | Represents or. Connect two commands with &&, as
Make Mrproper && make Menuconfig
, which indicates that the first command executes successfully to execute the second command. Commands that are required to execute the order can guarantee that once an error occurs, the following command will not continue to execute blindly.
In addition

1. When the user logs on to the system, bash first executes the/etc/profile configuration file and the configuration files under the/etc/profile.d/directory, which are valid for all users of the system, and they set a universal environment variable.

2. Then, bash executes the. bash_profile and. bashrc files in the login user's home directory, setting the user's personalization environment variables through these two configuration files. And you can repeat the settings set in the previous configuration file to override their setting values.

3. The. bashrc file below the user's home directory executes the/ETC/BASHRC file to complete setting of the environment variable.

4. The. Bash_profile in the user's home directory is set to execute at each logon, while. BASHRC is set to execute each time a new terminal is opened (such as opening multiple xterm windows after logging in the graphical environment), which opens a new terminal without having to log on again. The environment variable that was set when the initial login was accepted.

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.