<05>linux Text-based operations
Basics of text manipulation:
cat--text Simple View command, can only see the last screen of information
cat-n/<path>/file--Display Line numbers
more--Page view text content
less--Page view, more useful than more
head--Partial View command to view the header of the text
HEAD/ETC/PASSWD--View the first 10 rows by default
Head-3/etc/passwd--First 3 rows
tail--partial view command to see the end of text
TAIL/ETC/PASSWD--View the last 10 rows by default
Tail-3/etc/passwd--last 3 lines
Tail-f/var/log/message--See the latest updates
grep filtering commands
#grep root/etc/passwd--filter root keyword in passwd
#grep-I root/etc/passwd--ignoring case
#grep-N-I root/etc/passwd--ignores case and enters line number
#grep-V root/etc/passwd-v In addition to the root keyword
# grep-v ' ^$ '/etc/passwd^$ empty line
# grep ' ^root '/etc/passwd^root starts with root
# grep ' bash$ '/etc/passwdbash$ ends with bash
# Cat/etc/vsftpd/vsftpd.conf | Grep-v ' ^# ' | Grep-v ' ^$ '
View vsftpd.conf and filter out comment files and blank lines that begin with #
Linux Information collection command:
Uname-r kernel version
Uname-n Host Name
Uname-a All information
Free-m use of memory and swap partitions
DF-H displays the partitions that have been mounted, displaying the capacity in M units
DF-TH Displays the file systems for the partitions and partitions that have been mounted
Df-i displays the number of partitions and file nodes already mounted
PS aux
-A shows other user-initiated processes
-U initiates the process for the user and the time it starts
-X view your own processes in the system
-F shows the parent-child relationship of a process
Ps-elf
-E Show All processes
-L Long format
-F Full format
pstree--viewing processes in a tree-like manner
Pstree-aunlp
-A Show All
-U enable process user identity
-N Displays the process number numerically
-l display start command in long format
-P Process ID
top--viewing process status in a dynamic manner
Querying a user process root--> u
Query that process consumes CPU up to P
Query that process takes up memory--M
Kill Process--K
Change the display frequency--D
Top-p PID
A terminal
# PS aux | grep top
A different terminal
#top k 9 [15]
Pgrep viewing a process with a keyword
Pgrep-l bash with keyword view process
Pgrep-l BA
Pgrep-l TTY
Pkill Kill a process with a keyword
Pkill-9 bash--force kills a process that contains the BASH keyword in a startup command
Pkill-15-t tty1--shut down all processes in the Tty1 terminal in the normal way
Pgrep-u RPC portmap--kills the boot portmap process as RPC (pgrep-u root httpd)
Pkill-hup syslogd--Let the process restart and reload the configuration file--not advocating use
PKILL-1 syslogd--Let the process restart and reload the configuration file
PKILL-9/15 sshd (Service sshd restart)
Kill sends a signal to the process based on the process ID
Kill PID sends a normal shutdown signal (15 signal is sent by default)
kill-15 pid hair process normal shutdown signal
Kill-9 PID process sends a forced exit signal
Kill-1 | -hup--Let the process restart and reload the configuration file
# Cat >heizi.txt <<END|| EOT
> Hello,word
> END
| piping
CAT/ETC/PASSWD |grep-n-V "^#" > Heizi.txt
View the passwd document and filter the lines beginning with # and display the line number and redirect to Heizi.txt
This article is from the Linux Learning Summary blog, so be sure to keep this source http://helloheizi.blog.51cto.com/10275907/1656607
<05>linux Text-based operations