Home>Article>Operation and Maintenance> Share environment variables and file search examples
"Linux Basics (New Edition)" study notes
Attached is the laboratory address:
declare
Declare or display shell variables;linux $ declare tmp=liming //Create $ echo $tmp //Display $ liming $ unset tmp //Delete
The Shell program also runs on the operating system as a process, and most of the commands we run in the Shell will be Run as a child process.
Three commands related to environment variables:
set // All variables of the current Shell
env // Variables related to the current user
##export // Variables that export environment variables from the Shell
Note: In order to distinguish it from ordinary variables, we are usually used to set the environment variable name to uppercase.
* 永久的变量和临时的变量(export声明) * 两个文件: * "/etc/bashr // shell变量" * "/ect/profile // Share environment variables and file search examples,对所有用户永久生效" * 用户目录的一个隐藏文件:".profile //只对当前用户生效" * 如何实现永久: * 将需要的Share environment variables and file search examples添加到"/etc/profile"
$ echo $PATH $ PATH=$PATH:/home/shiyanlou/mybin // (这里在mybin目录下有自己写的.sh) // 添加自定义路径到“PATH”Share environment variables and file search examples中But once you exit the terminal and reopen it, it will become invalid
Achieving global validity
The configuration file of zsh is .zshrc,
The configuration file of Bash is .bashrc.
They also have one or more global configuration files under etc, but we generally only modify the configuration files in the user directory.
$ echo "PATH=$PATH:/home/shiyanlou/mybin" >> .zshrc
>>Modify variablesmeans appending to a file
>means overwriting to a file
Modify and delete existing variables
$ path=$PATH $ echo $path $ path=${path%/home/shiyanlou/mybin} # 或使用通配符,*表示任意多个任意字符 $ path=${path%*/mybin}
$ source .zshrc 或使用. $ . ./.zshrc
${Variable name##matching string} | |
${Variable name% matching string} | |
${Variable name% % Match string} | |
##${Variable name/old string/new string} | |
##${Variable name //Old string/ New string} | Replace all strings matching the old string with new strings |
Example: |
whereis
Search binary files (- b), man file (-m), source code file (-s)* 通过“/var/lib/mlocate/mlocate.db”数据库 * 手动更新数据库"updatedb" * 例:
$ locate /etc/sh //Find files starting with sh in the etc directory
$ locate /usr/share/*.jpg // \ escapecount*
-i" ignore casewhich
find
$ find ~ -mtime 0 //查找当天有改动的文件
Command:
cmatrix
$ sudo apt-get update;sudo apt-get install cmatrix
The above is the detailed content of Share environment variables and file search examples. For more information, please follow other related articles on the PHP Chinese website!