Pipe character, shell, environment variable configuration file

8.6 Pipelines and job control

1. # cat 1.txt |wc -l
# cat 1.txt |grep 'aaa'
#View the ls |wc -lnumber of files in the current directory #View
the number find / -name *.conf |wc -lof files searched
2. ctrl + z Pause the task and return to the command window
3. fg#Resume the pause command
4. jobsThe #command can list the stopped tasks, # fg 1, fg 2You can restore the corresponding task to the current state, # bgis to run the command in the background
5, # sleep 1000 &run the command directly in the background
6, # vmstat 1 vmstat detailed explanation, click here to enter the link
7, # ps auxview the process

8.7/8.8 shell variables

1. Variable
①, PATH
②, HOME
③, PWD
④, LOGNAME
2, # envcan output the environment variables in the system, all variables are capitalized
3, # setView system and custom variables
4, # custom a=111variable a=111 Variable Name rules: letters, numbers, underscores, the first position cannot be a number . When the variable value has special symbols, it needs to be enclosed in single quotation marks. 5. Accumulation of variables


[root@ajianglinux-01 ~]# a=1
[root@ajianglinux-01 ~]# b=2
[root@ajianglinux-01 ~]# echo $a$b
12
[root@ajianglinux-01 ~]# c=a"$b"c
[root@ajianglinux-01 ~]# echo $c
a2c

6. The global variable export b=2, the global variable is valid for the shell of this level and the child level, the parent of this level does not take effect, the local variable can only be valid in the first level shell
bash command enters the child level shell

[root@ajianglinux-01 ~]# bash

7. The pstree command needs to install the package

[root@ajianglinux-01 ~]# yum install -y psmisc
[root@ajianglinux-01 ~]# pstree
systemd─┬─NetworkManager───2*[{NetworkManager}]
        ├─VGAuthService
        ├─agetty
        ├─auditd───{auditd}
        ├─chronyd
        ├─crond
        ├─dbus-daemon───{dbus-daemon}
        ├─firewalld───{firewalld}
        ├─lvmetad
        ├─master─┬─pickup
        │        └─qmgr
        ├─polkitd───5*[{polkitd}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sshd─┬─sshd───bash───pstree
        │      ├─sshd───bash
        │      └─sshd───bash───bash
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        ├─tuned───4*[{tuned}]
        └─vmtoolsd───{vmtoolsd}

8. echo $SSH_TTY#Check yourself logged in through the terminal to
see under which TTY you can use the following commands

[root@ajianglinux-01 ~]# echo $SSH_TTY
/dev/pts/2

9. Unset variables

[root@ajianglinux-01 ~]# export ajiang=linux
[root@ajianglinux-01 ~]# echo $ajiang
linux
[root@ajianglinux-01 ~]# bash
[root@ajianglinux-01 ~]# echo $ajiang
linux
[root@ajianglinux-01 ~]# unset ajiang
[root@ajianglinux-01 ~]# echo $ajiang

10. The shell is actually a process, #Open a shell process again, and see which process it is in bashby #pstree

8.9 Environment variable configuration file

1. /etc/profile user environment variable, interactive, and only executed after login
2. /etc/bashrc user does not need to log in, the shell will take effect
3. ~/.bashrc user home directory has .bashrc, .bash_profile
4, ~/ .bash_profile
5, ~/.bash_history
6, ~/.bash_logout are used to define the operations that need to be done when the user exits
7. echo $PS1 is defined in /etc/bashrc, PS1='[\033[01;32m ]\u@\h[\033[00m]:[\033[01;36m]\w[\033[00m]$'

[root@ajianglinux-01 etc]#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$'
root@ajianglinux-01[:/etc#cd 
root@ajianglinux-01[:~#

8、do $PS2

root@ajianglinux-01[:~#echo $PS2
>
root@ajianglinux-01[:~#for i in `seq 1 10`
> do 
> echo $i
> done
1
2
3
4
5
6
7
8
9
10
root@ajianglinux-01[:~#

9. When the .bash_profile user logs in, for example, open the terminal and enter IP, port, username and password, the .bash_profile in the user's home directory will be automatically loaded.
10. .bashrc When the shell script is executed, the configuration in .bashrc will be automatically called
11 , . and source have the same function as loading the configuration in the file

expand

The difference between bashrc and bash_profilehttp : //www.apelearn.com/bbs/thread-7719-1-1.htmlSimple audit system: http://www.68idc.cn/help/server/linux/2014042190951.htmlAbout Meaning of PROMPT_COMMAND environment variable: http://www.linuxnote.org/prompt_command-environment-variables.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325621359&siteId=291194637