The most commonly used Linux commands in work, necessary to troubleshoot problems

Status query

View memory

free optional parameter -m -g

The most commonly used Linux commands in work, necessary to troubleshoot problems

Disk usage

df optional parameter -h

The most commonly used Linux commands in work, necessary to troubleshoot problems
The most commonly used Linux commands in work, necessary to troubleshoot problems

Observe which application port is used (detailed output information, no output if not occupied)

lsof -i: port number

For example, check which program is occupied by 8080

The most commonly used Linux commands in work, necessary to troubleshoot problems

If it is occupied, the occupied program will be output, otherwise no output

Text manipulation

The text operation commands can be combined at will with the pipe character to play the biggest role

cat

Directly output all the contents of the file. When the file content is large, you can use grep to filter

cat fileName

more

more fileNmae

Enter (roll down one line)

Space (scroll down one screen)

Q (Exit command)

B (scroll up one screen)

less

less fileName

PageUp key to page up

PageDown key to page down

tail

View the last line of the file, the last 10 lines of the default array

# Output the last 100 lines of the file 
tail -n 100 fileName
# View the last content of the file in real time, generally used to view the log in real time
tail -f fileName

head

Similar to tail, output header

head fileName 
# The first 100 lines of the output file
head -n 100 fileName

uniq

To deduplicate the content, only the adjacent and the same deduplication, if you want to deduplicate globally, you need to sort by sort first

# File sort and deduplication 
cat fileName | sort | uniq
# File sort and deduplication, and output the number of occurrences of each line
cat file | sort | uniq -c

sort

Sort the content, the data is arranged in lexicographic order, if you want to sort by value, add -n option

cat fileName | sort

wc

# How many lines in the file 
wc -l fileName
# How many words in the file
wc -w fileName
# How many bytes in the file
wc -c fileName
# How many characters in the file
wc -m fileName

Can be combined with pipe

cat fileName | wc -l

grep

The first form

grep [option] [pattern] [file1,file2]

For example, find the line containing content in show.txt

grep content show.txt

The second form

command | grep [option] [pattern]

If viewing a service information

ps -ef | seized mongo

For example, find the line containing content in show.txt

cat show.txt | grep content

The internet

Remote file transfer scp

First ensure that the server and ssh can jump to each other

Command format

scp -r source directory username @ip: target directory

The role of the -r parameter is to recursively copy the source directory, and the subdirectories and files in the copied directory

scp -r ~/app hadoop@hadoop001:~/
scp -r ~/app hadoop@hadoop002:~/
## 分发环境变量
scp ~/.bash_profile hadoop@hadoop001:~/
scp ~/.bash_profile hadoop@hadoop002:~/

Check if the network is connected

ping www.baidu.com

Check if the port is open

ping www.baidu.com -p 80

download file

wget file address



Guess you like

Origin www.cnblogs.com/winson-317/p/12684985.html