linux命令(export,dpkg,git diff,git status,echo,apt)

The export command is used to set or display environment variables

When executing a program in the shell, the shell provides a set of environment variables. Export can add, modify or delete environment variables for subsequent execution of the program. The effect of export is limited to this login operation.

  • What are environment variables?
  • Environment variables: continue to be effective in the child process of its process
  • Custom variables: Cannot extend to the child process

Export is to set variables as environment variables

  • The role of environment variables:
    When you want to enter a variable (such as the date command) without specifying the path where the system executes the date, linux will turn to the $PATH environment variable to modify the environment variable: export PATH = $ PATH:/home/roc/operation_tools Here is to add the /home/roc/operation_tools environment variable (if you do not add export when adding the variable, that is, the variable is a custom variable)

for example:

hr@ZERO看你:~$ var1=one
hr@ZERO看你:~$ var2=two
hr@ZERO看你:~$ echo $var1
one
hr@ZERO看你:~$ echo $var2
two
hr@ZERO看你:~$ export var1
hr@ZERO看你:~$ bash
hr@ZERO看你:~$ echo $var1
one
hr@ZERO看你:~$ echo $var2

hr@ZERO看你:~$

After var1 is set as an environment variable by export, it is still valid after a new bash child process is started, and the custom variable var2 cannot be inherited to its child process.

grammar

export [-fnp][变量名称]=[变量设置值]

parameter

  -f  代表[变量名称]中为函数名称。
  -n  删除指定的变量。变量实际上并未删除,只是不会输出到后续指令的执行环境中。
  -p  列出所有的shell赋予程序的环境变量。

1. Query command

hr@ZERO看你:~$ echo $SHELL
/bin/bash

2. List all environment variables

hr@ZERO看你:~$ export
declare -x HOME="/home/hr"
declare -x HOSTTYPE="x86_64"
declare -x LANG="C.UTF-8"
declare -x LESSCLOSE="/usr/bin/lesspipe %s %s"
declare -x LESSOPEN="| /usr/bin/lesspipe %s"
declare -x LOGNAME="hr"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
declare -x NAME="ZERO看你"
declare -x OLDPWD
declare -x PATH="/usr/hcc_riscv32/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_2020.1804.7.0_x64__79rhkp1fndgsc:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/WiFi/bin/:/mnt/c/Program Files/Common Files/Intel/WirelessCommon/:/mnt/f/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/黄睿/.dnx/bin:/mnt/c/Program Files/Microsoft DNX/Dnvm/:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/ProgramData/Microsoft/Windows/Start Menu/Programs/微信/weixin:/mnt/d/Microsoft VS Code/bin:/snap/bin"
declare -x PWD="/home/hr"
declare -x SHELL="/bin/bash"
declare -x SHLVL="2"
declare -x TERM="xterm-256color"
declare -x USER="hr"
declare -x WSLENV=""
declare -x WSL_DISTRO_NAME="Ubuntu-18.04"
declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share:/var/lib/snapd/desktop"

The result is all the environment variables of bash under the current user
3. For example, our common PATH:

hr@ZERO看你:~$ echo $PATH
/usr/hcc_riscv32/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_2020.1804.7.0_x64__79rhkp1fndgsc:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/WiFi/bin/:/mnt/c/Program Files/Common Files/Intel/WirelessCommon/:/mnt/f/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/黄睿/.dnx/bin:/mnt/c/Program Files/Microsoft DNX/Dnvm/:/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/ProgramData/Microsoft/Windows/Start Menu/Programs/微信/weixin:/mnt/d/Microsoft VS Code/bin:/snap/bin

Install deb package command under Ubuntu

  1. Download the deb package that needs to be installed, and enter the following command to install: sudo dpkg -i package.deb
  2. View the contents of the package.deb package:dpkg -c package.deb
  3. Extract information from the package.deb package: dpkg -I package.deb
  4. Remove the installed deb package: dpkg -r package
  5. Completely remove an installed package. Unlike remove, remove only deletes data and executable files. Purge also deletes all configuration files:dpkg -P package
  6. List all the files installed by the deb package. At the same time, please see dpkg -c to check the contents of a .deb file:dpkg -L package
  7. Display information about installed packages. At the same time, please see apt-cache to display package information in Debian archives, and dpkg -I to display package information extracted from a .deb file:dpkg -s package
  8. Reconfigure an installed package, if it uses debconf (debconf provides a unified configuration interface for package installation):dpkg-reconfigure package

git diff

Code before modification:

* it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/slab.h>

Modified code:

* it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
/********************is me add it*********************/
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/slab.h>

Run git status to view the modified files in our workspace

ts@ts-OptiPlex-7070:~/bin/kernel/msm-4.14$ git status
头指针分离于 d8110c633b15
尚未暂存以备提交的变更:
  (使用 "git add <文件>..." 更新要提交的内容)
  (使用 "git checkout -- <文件>..." 丢弃工作区的改动)

	修改:     drivers/mmc/core/mmc.c

git tells that a mmc.c file has been modified. But it didn't tell us exactly what was changed in this file. At this point, git diff is the most useful. It can be used to compare the current work area (not submitted to the temporary storage area) and the specific changes in the temporary storage area.
Run git diff:

ts@ts-OptiPlex-7070:~/bin/kernel/msm-4.14$ git diff
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 32619af7d915..53e2720f9c82 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -9,7 +9,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
+/********************is me add it*********************/
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/slab.h>

The specific changes are clear at a glance.
Let's look at running git diff HEAD again

ts@ts-OptiPlex-7070:~/bin/kernel/msm-4.14$ git diff HEAD
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 32619af7d915..53e2720f9c82 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -9,7 +9,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
+/********************is me add it*********************/
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/slab.h>

The results of the two runs are the same.
explain:

git diff: Check the difference between workspace (work area) and index (temporary area).
git diff --cached: is to check the difference between index (temporary storage area) and local repositorty (local warehouse).
git diff HEAD: Check the difference between workspace and local repository. (HEAD points to the latest committed version in the local repository)

echo for string output

format:

$ echo string

Type:
1

$ echo "a test" //显示字符串a test
$ echo It is a test//双引号完全可以省略,与上面实例效果一致

2

$ read name  //显示变量
ok
$ echo "$name"
ok

3

$ echo -e "OK! \n" // -e 开启转义
OK!

$ 

4

$ echo "1111111" > file //显示结果定向至文件

5

$ echo '$name\"'//原样输出,用单引号表示不进行转义或取变量
$name\"

6

$ echo `date` 显示命令执行结果
2020年 10月 29日 星期四 11:41:53 CTS

Linux apt provides commands to find, install, upgrade, delete one, a group, or even all packages

apt command execution requires super administrator privileges (root)

grammar

apt [options] [command] [package ...]
  • options: Optional, options include -h (help), -y (select all "yes" when prompted during the installation process), -q (do not display the installation process) and so on.
  • command: The operation to be performed.
  • package: The name of the installed package.

example

列出所有可更新的软件清单命令:sudo apt update
更新指定的软件:sudo apt update <package_name>
安装指定的软件:sudo apt install <package_name>
安装多个软件包:sudo apt install <package_1> <package_2>
删除软件包:sudo apt remove <package_name>
查找软件包: sudo apt search <keyword>
列出所有已安装的包:apt list --installed
列出所有已安装的包的版本信息:apt list --all-versions
显示软件包具体信息,例如:版本号,安装大小,依赖关系等等:sudo apt show <package_name>

Guess you like

Origin blog.csdn.net/weixin_42271802/article/details/109201811