当前位置:网站首页>Rhcsa Road
Rhcsa Road
2022-07-01 16:34:00 【Omniscient magical conch】
On the third day
Look at the catalog file : ls
View the contents of the text file
cat Output the contents of the file to the terminal , View file contents ( positive sequence )
-n View the contents of the file and display the label
tac Output the contents of the file to the terminal , View file contents ( Show in reverse order )
more Generally, large files can be displayed in pages through the terminal window , Finally, all contents are output to the terminal to view and display
less Open reading , Pagination display , Exit needs to pass q
? keyword perhaps / keyword
n Match keywords up
N Match keywords down
head View the first ten lines of information in the file
-n Specify the number of lines to display
-n 3
tail View the last ten lines of the file
-n 3
-f follow Append the contents of the display file ctrl+c
tail -f /var/log/messages
Text editing
1.nano
2.vi / vim *** Text editor
The last line of the terminal
Display a new file or file name with a few lines and characters or no information ( Execute convenient commands )
--insert--- ( Edit file contents )
Command mode :
dd Deletes the line where the cursor is located
d+enter Delete the line where the cursor is located and the next line of the cursor
dG Delete the line where the cursor is located and all lines at the end of the document
dgg Delete the line where the cursor is located and all lines at the beginning of the document
d^ Delete the cursor to the beginning of the line , Does not contain cursor characters
d$ Delete cursor to end of line , Contains the character of the cursor
x Delete cursor character
G Jump to the end of the document
gg Jump to the beginning of the document
4G Jump to line four
^ Head of line
$ At the end of the line
yy Copy
4yy Copy a total of four lines starting from the cursor
cc shear
4cc Cut a total of four lines starting from the cursor
p Paste ( Paste on the next line of the cursor )
u Undo to the left ( Return to the last editing status )
ctrl+r redo ( Undo right , Return to the state of recent editing )
Insertion mode :
a Insert content after cursor
A The end of the line where the cursor is located
i Insert content in front of the cursor
I The beginning of the line where the cursor is located
o Enter insertion mode , Add content on the next line of the cursor
O Enter insertion mode , Add content on the line above the cursor
s Delete cursor character , Enter insertion mode
S Deletes the line where the cursor is located , Enter insertion mode
Last row mode :
:q sign out
:q! Forced exit
:w preservation
:wq Save and exit == ZZ Command mode
:wq! Forced save exit
:10 Jump to line 10
:1,10 co 5 Copy 1-10 Go to the first place 5 After line
:g/#/d lookup # And delete
:r FILENMAE Read the contents of the specified file to the next line of the cursor
:%s % Match symbol , Indicates that all rows are matched s Replace the command / Characters to replace / The replaced character / Replace the keywords that are matched for the first time in each line g Replace all matching keywords %s /0/1/g
:set nu According to the line Numbers
:set nonu Cancel the line Numbers
/ keyword Quickly match the content of the line where the keyword is located
:noh Unhighlight
vim -o /etc/passwd /etc/shadow Multiple files horizontally split the display content
-O /etc/passwd /etc/shadow Left and right split screen display of file content
ctrl+w+w
vim + /etc/passwd Open the file and enter the end of the document
3.">" or “>>” Realize file editing
echo Print command
#echo this is test ( Standard I / O commands )
this is test
$ Reference variables
#name=zhangsan
#echo $name
zhangsan
${}
#echo ${name}
zhangsan
$? A command on the exit code is displayed 0 success 1-255 Error status
[[email protected] ~]# echo ${name}
zhangsan
[[email protected] ~]# echo $?
0
[[email protected] ~]# haha
bash: haha: command not found...
Failed to search for file: Cannot update read-only repo
[[email protected] ~]# echo $?
127
| Pipe, ( Take the standard output of the previous command as the standard input of the following command )--- Nameless pipe
Displays the tenth line of a file
#head /etc/passwd | tail -1
eg: Show /etc/passwd file 20-25 The content of the line
**p Identified pipeline file ( name pipes )
Turn on two terminals
1 terminal :
#mkfifo /p1
#echo 123 > /p1
2 terminal :
#cat /p1
123
The three quotation marks are different
' Single quotation marks ' Strong citation , Do not recognize the special meaning of special characters in quotation marks echo '$PS1'
" Double quotes " Weak reference , Identify characters with special meaning , echo “$PS1” --- If it is a variable, there is a difference between single reference and double reference
\ The quotation marks
Command substitutions == $()
[[email protected] /]# echo " All files in the root directory \`ls`"
">" Output redirector ( Write the output result of the previous command to the specified file output )
The redirection character will overwrite the original file
echo helloworld > FILE take helloworld The output result is written to the specified file through the output redirection character , When the file does not exist, it will be created
“>>” Append redirector
Appending a redirection character will not overwrite the original file
echo this is test >> FILENAME
< Enter the redirector
cat < /etc/passwd
head < /etc/passwd
4. File editing << Termination Terminator
[[email protected] /]# cat << EOF View content , Match the terminator to end the input
> this is test -- The standard input
> EOF -- Match to terminator , End standard input
this is test -- Output the contents of the previous standard input to the standard output
---------------------------
[[email protected] /]# cat << EOF > file2
> this is 1
> this is 2
> this is 3
> EOF
[[email protected] /]# cat file2
this is 1
this is 2
this is 3
File descriptor :0 Document standard input character 1 standard ( correct ) Output descriptor 2 Error output descriptor
cat 0< /etc/passwd
cat fff 1> file == cat fff > file
cat fff 2> file
cat fff &> file == cat fff 1> file 2> file == cat fff 1> file 2>&1
cat fff 1> file 2> /dev/null
Commands related to file content processing ---( That's ok )
grep Text filter display command
Command format : grep [-options...] keyword file name ...
#grep root /etc/passwd take /etc/passwd In file root Keyword line print display
-v Reverse filtration , Print and display lines without keywords
-o Show only the matching keywords
-c Displays the number of rows matching the keyword
-i Ignore case
-n Filter and display line numbers
-w Filter by word
-A 2 Display keywords and the next two lines of information
-B 2 Display keywords and the last two lines of information
-C 3 Display keywords and three lines of information
Filter specified files /etc/passwd There will be... In the file nologin The line of the keyword is written to login file , And write in the order of the original file .
[[email protected] /]# grep nologin /etc/passwd > login
Only the key information of one matching file is displayed
[[email protected] /]# grep -v ^# /etc/login.defs | grep -v ^$
Judge /usr/bin Whether there is passwd Executable file
[[email protected] /]# ll /usr/bin | grep -w passwd
-rwsr-xr-x. 1 root root 34512 Aug 12 2018 passwd
^ What does it start with ^q ^#
$ What does it end with a$
^$ Blank line
[] Define the value range , Any single character in this range [1-9] grep ^[0-9] FILENAME The beginning is 0-9 The line of any number shows
[^] ^ Take the opposite ^[^0-9] ^[!0-9]
cut Text content cutting command
-d Specify the delimiter of the file content
-f Specify the intercepted field
#cut -d : -f 1 /etc/passwd
[[email protected] /]# date |cut -d " " -f 6
2022
-c Specify character interception cut -c 1-3 /etc/passwd
wc Text statistics command That's ok Word book Number of bytes file name
-l Just count the lines
-w Just count the number of words
-c Count the number of bytes
-m Count characters
How many users are there in the current system
[[email protected] /]# echo There are users in the current system \wc -l /etc/passwd | cut -d " " -f 1
individual > file There are users in the current system 44 individual
sort Text sorting Sort by character by default
-n Display in ascending order of numerical value
-r Show in reverse order
-t Specify the separator
-k Specified field
-u unique duplicate removal ==sort a.txt | uniq
[[email protected] /]# sort -t : -k 3 -n /etc/passwd
take /etc/passwd The contents of the document are passed through : Split sorts the third field and displays the contents of each line in ascending order
uniq To repeat the order ( Repeat rows adjacent to each other )
-c Displays the number of times each line is repeated
-d Show only recurring lines
-D Show all rows that appear repeatedly
tr Character substitution
echo abcde | tr -t a 1
-c Inverse selection
echo abcde | tr -c abc 0 Take care of abc Replace characters other than with 0 character
abc00
-s Replace consecutive repeated characters with a single character
echo aaaaabcd | tr -s a 1 Will be a continuous number of a Replace the character with a 1 character
-d Delete selected characters
echo abcdef | tr -d abc
边栏推荐
- 2023 spring recruitment Internship - personal interview process and face-to-face experience sharing
- Principle of motion capture system
- Golang爬虫框架初探
- EndeavourOS移动硬盘安装
- Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
- P2893 [USACO08FEB] Making the Grade G(dp&优先队列)
- Sweden announced its decision to exclude Huawei 5g equipment, but Huawei has successfully found a new way out
- Tutorial on the principle and application of database system (002) -- MySQL installation and configuration: MySQL software uninstallation (Windows Environment)
- VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...
- Is it reliable to open an account on flush with mobile phones? Is there any potential safety hazard
猜你喜欢
复杂度相关OJ题(LeetCode、C语言、复杂度、消失的数字、旋转数组)
学会了selenium 模拟鼠标操作,你就可以偷懒点点点了
运动捕捉系统原理
Embedded development: five revision control best practices
process. env. NODE_ ENV
高端程序员上班摸鱼指南
Tutorial on the principle and application of database system (002) -- MySQL installation and configuration: MySQL software uninstallation (Windows Environment)
StoneDB 为国产数据库添砖加瓦,基于 MySQL 的一体化实时 HTAP 数据库正式开源!
[nodemon] app crashed - waiting for file changes before starting...解决方法
普通二本,去过阿里外包,到现在年薪40W+的高级测试工程师,我的两年转行心酸经历...
随机推荐
从大湾区“1小时生活圈”看我国智慧交通建设
Sqlserver query: when a.id is the same as b.id, and the A.P corresponding to a.id cannot be found in the B.P corresponding to b.id, the a.id and A.P will be displayed
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
Tutorial on principles and applications of database system (004) -- MySQL installation and configuration: resetting MySQL login password (Windows Environment)
复杂度相关OJ题(LeetCode、C语言、复杂度、消失的数字、旋转数组)
接口测试框架中的鉴权处理
数据库系统原理与应用教程(001)—— MySQL 安装与配置:MySQL 软件的安装(windows 环境)
Im instant messaging develops a message delivery scheme for 10000 people
VMware virtual machine failed during startup: VMware Workstation is incompatible with hyper-v
怎麼用MySQL語言進行行列裝置?
IM即時通訊開發實現心跳保活遇到的問題
德国iF多项大奖加冕,这副耳机有多强?音珀GTW 270 Hybrid深度评测
数据库系统原理与应用教程(003)—— MySQL 安装与配置:手工配置 MySQL(windows 环境)
IM即时通讯开发万人群聊消息投递方案
She is the "HR of others" | ones character
运动捕捉系统原理
【Hot100】19. 删除链表的倒数第 N 个结点
Telecommuting experience? Let's introduce ourselves ~ | community essay solicitation
部门来了个拿25k出来的00后测试卷王,老油条表示真干不过,已被...