当前位置:网站首页>Rhcsa third day notes
Rhcsa third day notes
2022-07-03 20:30:00 【Hao Yikai】
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 )
: Last row mode
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
: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 )
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
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
边栏推荐
- In 2021, the global revenue of syphilis rapid detection kits was about US $608.1 million, and it is expected to reach US $712.9 million in 2028
- It is discussed that the success of Vit lies not in attention. Shiftvit uses the precision of swing transformer to outperform the speed of RESNET
- Implementation of stack
- How can the outside world get values when using nodejs to link MySQL
- Gee calculated area
- Virtual machine installation deepin system
- Strange way of expressing integers (expanding Chinese remainder theorem)
- thrift go
- jvm jni 及 pvm pybind11 大批量数据传输及优化
- Reinforcement learning - learning notes 1 | basic concepts
猜你喜欢
LabVIEW training
强化学习-学习笔记1 | 基础概念
19、 MySQL -- SQL statements and queries
In 2021, the global revenue of syphilis rapid detection kits was about US $608.1 million, and it is expected to reach US $712.9 million in 2028
Qt6 QML Book/Qt Quick 3D/基础知识
String and+
AI enhanced safety monitoring project [with detailed code]
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022
Exercises of function recursion
Network security Kali penetration learning how to get started with web penetration how to scan based on nmap
随机推荐
Apprentissage intensif - notes d'apprentissage 1 | concepts de base
Global and Chinese market of rubidium standard 2022-2028: Research Report on technology, participants, trends, market size and share
阻塞非阻塞和同步异步的区分 参考一些书籍
Ruby replaces gem Alibaba image
Cannot load driver class: com. mysql. cj. jdbc. Driver
In 2021, the global foam protection packaging revenue was about $5286.7 million, and it is expected to reach $6615 million in 2028
Camera calibration (I): robot hand eye calibration
19、 MySQL -- SQL statements and queries
Global and Chinese markets of lithium chloride 2022-2028: Research Report on technology, participants, trends, market size and share
Don't be afraid of no foundation. Zero foundation doesn't need any technology to reinstall the computer system
How to improve data security by renting servers in Hong Kong
2.7 format output of values
Popularize the basics of IP routing
【c】 Digital bomb
Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~
Day6 merge two ordered arrays
Get log4net log file in C - get log4net log file in C
Strange way of expressing integers (expanding Chinese remainder theorem)
Cap and base theory
Class loading process