# # # managing input and Output # # # #
In a Linux system, the correct output number is 1 and the error output number is 2.
Use the student user to execute the find/etc-name passed command, because the permissions of the student user issue occurs as follows:
[[email protected] desktop]$ find /etc/ -name passwdfind: '/etc/pki/CA/ Private ': permission denied # #报错: No power to enter # #find: ' /etc/pki/rsyslog ': permission deniedfind: '/etc/dhcp ': permission deniedfind: '/ Etc/lvm/archive ': permission deniedfind: '/etc/lvm/backup ': permission deniedfind: '/etc/lvm/cache ': permission deniedfind: '/etc/selinux/targeted/modules/active ': permission denied/etc/passwd # #正确输出 # #find: '/etc/ Audit ': permission denied/etc/pam.d/passwdfind: '/ETC/POLKIT-1/RULES.D ': Permission deniedfind: '/etc/polkit-1/localauthority ': permission deniedfind: '/etc/firewalld ': permission deniedfind: '/etc/ipsec.d ': permission deniedfind: '/etc/audisp ': permission deniedfind: ' /etc/vmware-tools/guestproxydata/trusted ': permission deniedfind: '/ETC/GRUB.D ': permission deniedfind: '/etc/libvirt ': permission deniedfind: '/etc/cups/ssl ': permission deniedfind: '/ETC/SUDOERS.D ': permission denied[[email protected] desktop]$
Find/etc-name passwd > File # #重定向正确输出 # #
Find/etc-name passwd 2> File # #重定向错误输出 # #
Find/etc-name passwd &> File # #重定向所有输出 # #
Note:>,2>,&> is the command output to overwrite the original content of file files;
> File # #清空文件file # #
Find/etc-name passwd >> File # #追加正确输出 # #
Find/etc-name passwd 2>> File # #追加错误输出 # #
Find/etc-name passwd &>> File # #追加所有输出 # #
Note:>>,2>>,&>> only appends the command output to the file content, and does not overwrite the original content;
| Pipe character: The function of a pipe character is to change the output of the previous command into the input of the command after the pipe character
Example: Ls/bin | Wc-l # #统计ls/bin command output number of lines # #
[Email protected] desktop]$ Ls/bin | Wc-l1962[[email protected] desktop]$
The wrong output in the system cannot be passed through the pipe character, but with 2>&1 you can turn the wrong output number from 2 to 1
Tee copy output to specified location
Example: Date |tee file |wc-l # #tee命令复制date命令的输出到file中, and statistics output line
Number # #
[[Email protected] desktop]$ Date | Tee File | Wc-l1[[email protected] desktop]$ cat Filethu Mar 2 20:05:14 CST 2017[[email protected] desktop]$
# # # #Vim#
Vim's three modes: edit mode, command mode, visual mode
Enter edit mode (that is, insert mode):
I # #光标所在位置插入 # #
L # #光标所在行行首 # #
A # #光标所在字符的下一个位置 # #
A # #光标所在行行尾 # #
o # #光标所在行下一行 # #
O # #光标所在行上一行 # #
S # #删除光标所在字符插入 # #
S # #删除光标所在行插入 # #
Command mode:
/keyword # #搜索关键字 # #
n Match down, n up match
: Number # #移动到指定的行 # #
G # #文件最后一行 # #
GG # #文件第一行 # #
: Set Nu # #行号添加 # #
: Set Nonu # #取消行号 # #
: Set Mouse=a # #添加鼠标选择 # #
: Set Cursorline # #行线显示 # #
Note: Permanent setup requires adding parameters to Vim's configuration file/ETC/VIMRC
: Q # #当用vim打开文件但没有对字符作任何操作时可直接退出 # #
: q! # #当用vim打开文件并对字符作操作, quit all operations Exit # #
: Wq # #保存退出 # #
: wq! # #强行保存退出, effective for Superuser and file owner # #
Copying of characters
YL # #复制一个字母 # #
Y3L # #复制3个字母 # #
YW # #复制一个单词 # #
y3w # #复制3个单词 # #
YY # #复制一行 # #
Y3Y # #复制3行 # #
P # #复制完成后按 "P" Paste # #
2. Deletion of characters
DL # #删除一个字母 # #
D3L # #删除3个字母 # #
DW # #删除一个单词 # #
d3w # #删除3个单词 # #
DD # #删除一行 # #
D3D # #删除3行 # #
3. Cutting of characters
CL # #剪切一个字母 # #
C3L # #剪切3个字母 # #
CW # #剪切一个单词 # #
c3w # #剪切3个单词 # #
C3C # #剪切3行 # #
ESC---> P # #剪切过后会进入到插入模式, be sure to exit the insert when you perform the Paste action
Mode # #
4. Bulk modification of characters
:%s/original character/replacement character # #只替换每一行中出现的第一个原有字符 # #
:%s/original character/replace character/g # #替换所有 # #
:%s/\t//g # #把全文的tab键替去掉, \ t = Tab key # #
:%s/^\ *//g # #把全文行首的空格去掉, "^\ *" means empty > at the beginning of the line # #
:%s/^\#\ */#/g # #把全文 # After the space removed # #
Visual mode:
Press "CTRL + V" in command mode to enter the visual mode, where you can select the characters in the visual mode
Split Screen function
Ctrl+w S # #上下分屏 # #
Ctrl+w v # #左右分屏 # #
Ctrl+w C # #关闭光标所在屏幕 # #
Ctrl+w up or Down # #光标移动到指定屏幕 # #
: SP File2 # #同时编辑当前文件和file2 # #
Bulk Add characters
CTRL + V into visual mode
----> select the column to which you want to add characters
----> Press "I" to enter insert mode, write the characters to be added
----> Press ESC
Add:
Vimtutor # #vim的手册
: Q # #退出vimtutor
# # # #gedit# #
CTRL + N # #在gedit中打开一个新的tab # #
Ctrl+s # #保存文件 # #
Ctrl+o # #打开文件 # #
Ctrl+x # #剪切字符 # #
Ctrl + V # #粘贴字符 # #
CTRL + C # #复制字符 # #
Yelp Help:gedit # #gedit的图形手册 # #
Linux operation and Maintenance management UNIT4