Shell Learning 15 days (Shell characteristics 1/2) - 02day

Characteristics (a) Shell of

1) Switch user su - and without su - What is the difference? User login process involves the shell configuration file Detailed

Plus - on behalf of a user's shell environment enable switch, without, on behalf of the user to switch directly using the current account shell environment. That there is no landing switch users shell, which is the difference login shell with the nologin shell. Particular attention here login shell & nologin shell with / etc / passwd inside the / bin / bash & / sbin / nologin is not a concept Kazakhstan. passwd inside the / sbin / nologin represent this does not give him time user login shell environment.

The default switch user enter the user's home directory, home directory if no shell environment configuration file (three, rpm -qc bash can be listed.), Then -bash4.1- $ prompt appears. Solution Copy the following three files to their home directory. The default account with useradd will create a copy of these three files in the / home / account. You can also change the passwd file in the user's home directory and shell with usermod. Details man usermod

/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc

Next, we understand the shell configuration files in the user login process involved:

1-1)  / etc / Profile and / etc / bashrc is a system-level configuration file, the user can perform landing

        ~ / .Bash_profile and ~ / .bashrc is a user-level configuration file, the user can perform landing

        ~ / .Bash_logout and ~ / .bash_history is a user-level configuration file, execute when the user exits.

1-2) If the user login shell landed in a way, then the / etc / profile / etc / bashrcand ~ / .bashrc will be loaded.

        If the user logged on as the nologin shell mode, then only load / etc / bashrc and ~ / .bashrc

Will execute ~ / .bash_history and ~ / exit when landing Either way .bash_logout

2) GNU / Bash shell Other features

2-1) commands and files automatically filled

          Can be achieved bash-completion-2.1-6.el7.noarch installed automatically filled function, available rpm -qa | grep bash-com inquiry

2-2) Command History function

          Up and down keys, exclamation mark! (Exclamation mark at the beginning of the execution history is in order, commonly used in the script):

          ! number (number command numbered in history)

          ! string (found inside the historical record recently executed a command string to begin with)

           ! $ (Last argument on a command)

           !! (previous command)

2-3) function alias alias unalias

           Specifies the aliases in the current shell, want to permanently written on the inside .bashrc

2-4) shortcut function

Shell Shortcuts

  1. ESC + . Finally, a paste command parameters to the current position
  2. ESC + b Command statement forward one word.
  3. ESC + f After a shift command statement word
  4. Ctrl + e Cursor to the end of the command
  5. Ctrl + a Move the cursor to the command line first
  6. Ctrl + bBackward one character, equal to <-the left arrow
  7. Ctrl + fForward one character, equal ->right arrow
  8. Ctrl + k Delete all the characters before the cursor
  9. Ctrl + u Delete light-second behind all the characters

2-5) before and after the job control table

      (&: Nohup into the background with the bash &: the system into the background  BG fg PS pgrep pkill the kill killall Top pstree Screen ) at say, today and in the test & nohup when found close the terminal is not in the process of nohup a, So now I re-discovered the use of landing after the terminal is ps -l command which is to look at this command shell process, certainly not before pulling off management process. Please pa aux it! Commands are not familiar with really evil ah!

I did not use the above screen before too, this time to learn to understand it: As the long length, reference links:

https://blog.csdn.net/han0373/article/details/81352663

https://www.ibm.com/developerworks/cn/linux/l-cn-screen/#icomments

In the centos5

    ctrl + alt + (F1-F6) to switch the character interface, ctrl + alt + F7 switches to graphical interface

In centos6, in centos7

    Switching ctrl + alt + (F2-F6) to the character interface, ctrl + alt + F1 is switched to the graphical interface


2-6) Input and output redirection

0 obtain input standard input / proc / self / fd from the keyboard / 0 
standard output 1 output to the screen (i.e., console) / proc / self / fd / 1 
error output to the screen 2 (i.e., console) / proc / self / fd / 2 

About redirect, cat << EOF> out and the cat> out << EOF effect is the same. The following Liezi can explain:

这部分内容很多,我参考了其他作者的文章,直接链接: https://blog.csdn.net/xx_ay/article/details/104288342

 

2-7) 管道和tee管道

ip addr | grep 'inet' | grep eth0

ip addr | grep 'inet' | tee test | grep eth0   覆盖

ip addr | grep 'inet' | tee -a test | grep eth0  -a 追加

tee管道将命令输出重定向到指定文件但是不会截流。命令输出依然会输出到指定设备。比如很直观的以下命令:

[hujianmei@localhost ~]$ date > date1.txt
[hujianmei@localhost ~]$ cat date1.txt
2020年 02月 12日 星期三 23:13:44 CST
[hujianmei@localhost ~]$ date |tee date1.txt
2020年 02月 12日 星期三 23:14:12 CST
[hujianmei@localhost ~]$

 

 

 

 

 

20200212

今天的学习进度比较慢。原本计划的shell特性内容只完成了1/2,所以明天还要继续shell特性这部分的学习~

发布了15 篇原创文章 · 获赞 0 · 访问量 3043

Guess you like

Origin blog.csdn.net/xx_ay/article/details/104275892