Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the source command of Linux

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge points about how to use the source command of Linux. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

In Linux systems, the source command usually uses "." Instead, it's a dot command, which is different from a general command.

Sourcesource filename

The function is to read and execute commands in Filename in the current bash environment. Because the command can be used with "." To replace, for example

Source filename. A wonderful use of the filenamesource command

When compiling the core, you often have to type a long list of commands repeatedly, such as

Make mrpropermake menuconfigmake depmake cleanmake bzImage

These orders are both long and tedious. And sometimes it's easy to lose, wasting your time and energy. If you make these commands into a file and let it be executed automatically in order, it will be convenient for users who need to compile the core repeatedly.

This can be done with the source command. Its function is to execute the contents of a file as if it were shell.

First create a file under the / usr/src/linux-2.4.20 directory and name it make_command, and 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 created, each time the core is compiled, you only need to type source make_command under / usr/src/linux-2.4.20. This file can also be made into a script, with only minor changes.

Commands in shell programming are sometimes the same as in C language. & & for and, | | for or. Concatenating two commands with & & such as make mrproper & & make menuconfig means that the first command must be executed successfully before the second command can be executed. Commands that require the order of execution ensure that once an error occurs, the following commands will not continue blindly.

The difference between source filename and sh filename and. / filename executing scripts when shell scripts have executable permissions, there is no difference between executing scripts with sh filename and. / filename. . / filename is because the current directory is not in PATH, all "." Is used to represent the current directory. Sh filename re-creates a child shell and executes the statements in the script in the child shell. The child shell inherits the environment variables of the parent shell, but the newly created and changed variables of the child shell are not brought back to the parent shell. Source filename: this command simply reads the statements in the script and executes them in the current shell in turn, without creating a new child shell. Then all statements in the script that create new and change variables will be saved in the current shell. These are all the contents of this article entitled "how to use Linux's source commands". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report