Discuss Linux environment variables

We all know that there are some commands use of Linux, and some can be used anywhere, from time to time in the Linux environment to go with, then the environment in the end what is?

We need not so much with the environment, as it is we can execute commands with the help of the environment.

In the Linux environment variable is PATH, first check what the current environment:

xxx@xxx-ThinkPad-X230-Tablet:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin

Switch to the root inquiries about current environment:

root@xxx-ThinkPad-X230-Tablet:/home/xxx# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Show environment is currently owned by each user.

You can go to the show look at what each directory is found are either ordinary or executable file is linked files. In the / bin also see the usual cat and other system commands, then there is a case that a command has the same in both environments are then executed first, of course, is the order of the output of the environmental variables in order to find out.

In other words, you can only execute commands in the current environment, it is often said that the need to take the environment is to add commands to work under their own environment variables.

In addition to adding to your own environment variables, of course, you can use absolute paths using the instructions, but this method was too much trouble, so no one use.

So our system programming written, of course, you are free to use an alternative, because in fact, the beginning and not so much Linux commands, procedures need to be resolved when the corresponding write specific questions, people use more, it has gradually become the standard commands, so you can write commands in your own environment according to their needs, so-called open source, itself, is to let everyone contribute together to make Linux more convenient and robust.

Of course, you can not feel free to add environment variables to use this thing to be careful, because Linux is a multi-user, such as / tmp directory for each user can be written, so if you have some of the following in this order to steal data, it is likely He will be succeeded.

And of course there are different working directories use of a different place:

  • / bin is the number of instruction. The main bin shorthand binary place some essential system executables example: cat, cp
  • / sbin generally refers ** super user instruction. ** The main place some system management of essential programs such as: cfdisk, dhcpcd
  • / usr / bin is some software that you run the script in the late installed. The main place some application software tools necessary executables e.g. c ++, g ++, gcc
  • / usr / sbin place some management system users to install the necessary programs, for example: dhcpd, httpd
Published 15 original articles · won praise 13 · views 9062

Guess you like

Origin blog.csdn.net/weixin_43122409/article/details/83962874