shallow丿ovemysql
[root@localhost ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost ~]# echo $LANG en_US.UTF-8
[root@localhost ~]# env XDG_SESSION_ID=8 HOSTNAME=localhost.localdomain SELINUX_ROLE_REQUESTED= TERM=xterm SHELL=/bin/bash HISTSIZE=5000 SSH_CLIENT=192.168.9.1 2272 22 SELINUX_USE_CURRENT_RANGE= SSH_TTY=/dev/pts/0 USER=root 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=01;05;37;41: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:*.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:*.jpg=01;35:*.jpeg=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:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36: MAIL=/var/spool/mail/root PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin PWD=/root LANG=en_US.UTF-8 SELINUX_LEVEL_REQUESTED= HISTCONTROL=ignoredups SHLVL=1 HOME=/root LOGNAME=root SSH_CONNECTION=192.168.9.1 2272 192.168.9.134 22 LESSOPEN=||/usr/bin/lesspipe.sh %s XDG_RUNTIME_DIR=/run/user/0 _=/usr/bin/env [root@localhost ~]# set #set查看系統和用戶自定義變量 #系統和用戶自定義變量
[root@localhost ~]# a=111 [root@localhost ~]# echo $a 111 [root@localhost ~]# set | grep 111 _=111 a=111
[root@localhost ~]# a="'a b c'" [root@localhost ~]# echo $a 'a b c' [root@localhost ~]# a='"a b c"' [root@localhost ~]# echo $a "a b c"
[root@localhost ~]# a="a$bc" [root@localhost ~]# echo $a a [root@localhost ~]# a='a$bc' [root@localhost ~]# echo $a a$bc
[root@localhost ~]# a=1 [root@localhost ~]# b=2 [root@localhost ~]# echo $a$b 12
[root@localhost ~]# c='a$bc' [root@localhost ~]# echo $c a$bc [root@localhost ~]# c=a$bc [root@localhost ~]# echo $c a [root@localhost ~]# c="a$b"c [root@localhost ~]# echo $c a2c
[root@localhost ~]# w 15:49:26 up 8:38, 2 users, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 13:01 6.00s 0.45s 0.00s w root pts/1 15:49 6.00s 0.02s 0.02s -bash [root@localhost ~]# echo $SSH_TTY /dev/pts/0
打開另外一個終端web
[root@localhost ~]# w 15:49:12 up 8:37, 2 users, load average: 0.00, 0.01, 0.05 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root pts/0 13:01 32.00s 0.45s 0.45s -bash root pts/1 15:49 0.00s 0.03s 0.01s w [root@localhost ~]# echo $SSH_TTY /dev/pts/1
[root@localhost ~]# hello=world [root@localhost ~]# echo $hello world
打開另外一個終端sql
[root@localhost ~]# echo $hello
返回原來的終端下,打開一個bashshell
[root@localhost ~]# bash [root@localhost ~]# pstree bash: pstree: command not found
[root@localhost ~]# yum provides "/*/pstree" Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn epel/x86_64/filelists_db | 9.8 MB 00:00:11 extras/7/x86_64/filelists_db | 494 kB 00:00:01 psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system Repo : base Matched from: Filename : /usr/bin/pstree [root@localhost ~]# yum install -y psmisc Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel/x86_64/metalink | 6.3 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 updates/7/x86_64/primary_db | 3.6 MB 00:00:03 Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package psmisc.x86_64 0:22.20-15.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================== Package Arch Version Repository Size =================================================================================================== Installing: psmisc x86_64 22.20-15.el7 base 141 k Transaction Summary =================================================================================================== Install 1 Package Total download size: 141 k Installed size: 475 k Downloading packages: psmisc-22.20-15.el7.x86_64.rpm | 141 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : psmisc-22.20-15.el7.x86_64 1/1 Verifying : psmisc-22.20-15.el7.x86_64 1/1 Installed: psmisc.x86_64 0:22.20-15.el7 Complete!
[root@localhost ~]# pstree systemd─┬─NetworkManager───2*[{NetworkManager}] ├─agetty ├─auditd───{auditd} ├─avahi-daemon───avahi-daemon ├─crond ├─dbus-daemon───{dbus-daemon} ├─firewalld───{firewalld} ├─iprdump ├─iprinit ├─iprupdate ├─lvmetad ├─master─┬─pickup │ └─qmgr ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd───bash───bash───pstree │ └─sshd───bash ├─systemd-journal ├─systemd-logind ├─systemd-udevd └─tuned───4*[{tuned}]
這裏咱們經過├─sshd─┬─sshd───bash───bash───pstree能夠看到,咱們sshd遠程登陸得到了一個bash,經過bash上面打開了一個子shell,經過這個bash咱們又運行了pstree這個進程bash
[root@localhost ~]# echo $hello [root@localhost ~]# exit exit [root@localhost ~]# pstree systemd─┬─NetworkManager───2*[{NetworkManager}] ├─agetty ├─auditd───{auditd} ├─avahi-daemon───avahi-daemon ├─crond ├─dbus-daemon───{dbus-daemon} ├─firewalld───{firewalld} ├─iprdump ├─iprinit ├─iprupdate ├─lvmetad ├─master─┬─pickup │ └─qmgr ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd───bash───pstree │ └─sshd───bash ├─systemd-journal ├─systemd-logind ├─systemd-udevd └─tuned───4*[{tuned}] [root@localhost ~]# echo $hello world
[root@localhost ~]# export hello=world [root@localhost ~]# echo $hello world [root@localhost ~]# bash [root@localhost ~]# echo $hello world [root@localhost ~]# bash [root@localhost ~]# echo $hello world
打開另外一個終端less
[root@localhost ~]# pstree systemd─┬─NetworkManager───2*[{NetworkManager}] ├─agetty ├─auditd───{auditd} ├─avahi-daemon───avahi-daemon ├─crond ├─dbus-daemon───{dbus-daemon} ├─firewalld───{firewalld} ├─iprdump ├─iprinit ├─iprupdate ├─lvmetad ├─master─┬─pickup │ └─qmgr ├─polkitd───5*[{polkitd}] ├─rsyslogd───2*[{rsyslogd}] ├─sshd─┬─sshd───bash───bash───bash │ └─sshd───bash───pstree ├─systemd-journal ├─systemd-logind ├─systemd-udevd └─tuned───4*[{tuned}] [root@localhost ~]# echo $hello
這是由於兩個終端都不屬於同一個sshd,他們區別開來,並不衝突dom
返回原來的終端ssh
[root@localhost ~]# export a=123 [root@localhost ~]# echo $a 123 [root@localhost ~]# exit exit [root@localhost ~]# echo $a
[root@localhost ~]# echo $hello world [root@localhost ~]# unset hello [root@localhost ~]# echo $hello
不一樣用戶登陸,全局變量只對當前用戶的shell和子shell生效,若要其餘用戶生效則能夠到/etc/profile進行修改配置ide
當前用戶下的目錄svg
[root@localhost ~]# vi .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH
. ~/.bashrc與source ~/.bashrc的做用是同樣的,加載配置文件
[root@localhost ~]# vi .bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
[root@localhost ~]# vi /etc/bashrc /PS1 [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " [root@localhost ~]#cd /etc/sysconfig/network-scripts/ [root@localhost /network-scripts]## echo $PS1 [\u@\h \W]\$
這裏PS1的u表示當前用戶,h爲主機名,W爲絕對路徑最後一個目錄
[root@localhost ~]# PS1='[\u@\h \w]\$' [root@localhost ~]# cd /etc/sysconfig/network-scripts/ [root@localhost /etc/sysconfig/network-scripts]# [root@localhost /etc/sysconfig/network-scripts]# PS1='\u@\h \w\$' root@localhost /etc/sysconfig/network-scripts# root@localhost /etc/sysconfig/network-scripts# PS1='<\u@\h \w>\$' <root@localhost /etc/sysconfig/network-scripts>#
甚至還能夠帶顏色顯示
root@localhost:/etc/sysconfig/network-scripts# PS1='[\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]]\$' [root@localhost:/etc/sysconfig/network-scripts]#
有PS1,那麼也有PS2,而PS2如運行mysql等程序時,則會進入PS2界面
[root@localhost:~]# echo $PS2 > [root@localhost:~]# for i in `seq 1 10` > do > echo $i > done 1 2 3 4 5 6 7 8 9 10 [root@localhost:~]# for i in `seq 1 10`; do echo $i; done 1 2 3 4 5 6 7 8 9 10 [root@localhost:~]# PS2="#" [root@localhost:~]# echo $PS2 # [root@localhost:~]# for i in `seq 1 10` #do #echo $i #done 1 2 3 4 5 6 7 8 9 10