Pipelines and job control, shell variables, environment variable configuration files

pipe character

  • "|" function: pass the output of the previous command to the following command

    job control

  • ctrl z pause a task

[root@localhost ~]# vim 1.txt 

[1]+  已停止               vim 1.txt
[root@localhost ~]# vim 2.txt 

[2]+  已停止               vim 2.txt
[root@localhost ~]# jobs
[1]-  已停止               vim 1.txt
[2]+  已停止               vim 2.txt
[root@localhost ~]# 
  • The jobs command is used to display the task list and task status in Linux, including tasks running in the background.

  • fg resumes a suspended task, which can be followed by a number parameter, indicating the number of suspended tasks to resume

  • bg runs tasks in the background, continuously outputting information, but does not delay running commands

shell variable

  • PATH,HOME,PWD,LOGNAME

  • You can view variables through env or set. System variables are generally larger English letters.

  • Rules for variable names: letters, numbers, underscores, and the first place cannot be a number

  • Variables with special symbols need to be enclosed in single quotes

[root@localhost ~]# echo $a$bb
1
[root@localhost ~]# echo '$a$bb'
$a$bb
  • The pstree command will display all processes in the Linux system in a tree structure. If this command is not available: yum install -y psmisc

[root@localhost ~]# pstree
systemd─┬─NetworkManager───2*[{NetworkManager}]
        ├─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
        │                    └─2*[vim]
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        ├─tuned───4*[{tuned}]
        └─vmtoolsd───{vmtoolsd}
[root@localhost ~]# 
  • Export sets the variable globally, and the subshells under the same sshd know this variable and take effect downwards.

  • unset variable name: cancel the variable

environment variable configuration file

  • Configuration file for system environment variables

    • /etc/profile : This file presets several important variables, such as PATH, USER, LOGNAME, MAIL, INPUTRC, HOSTNAME, HISTSIZE, umask, etc.
    • /etc/bashrc : This file mainly presets umask and PS1. This PS1 is the string in front of us when we enter the command.
  • Configuration file for user environment variables

    • .bash_profile This file is the file name of a user's personalized path and environment variables. Each user can use this file to enter their own shell information, and when the user logs in, the file is executed only once.
    • .bashrc This file contains bash information specific to your shell and is read when you log in or every time you open a new shell.
    • .bash_history This file is used to record command history.
    • .bash_logout This file is executed when you exit the shell, and you can put some cleanup work into this folder.

Guess you like

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