当前位置:网站首页>Common UNIX Operation and maintenance commands of shell
Common UNIX Operation and maintenance commands of shell
2022-07-01 04:38:00 【Moshow Zhengkai】
1、 Find all in the directory to .zip The last file is moved to the specified directory .
find . -name “*.zip” -exec mv {} ./backup/ ;
2、 Find the current directory 30 Days ago, it was greater than 100M Of log File and delete .
find . -name “*.log” –mtime +30 –typef –size +100M | xargs rm –rf {};
3、 Batch decompress the current directory to .zip At the end of all the files to the specified directory .
for i in
find . –name "*.zip" –type f
do
unzip –d $i /data/www/
done
annotation :for i in (command);do … done by for A common format for loops , among i As a variable , You can specify that .
4、 Write a script to find the last creation time is 3 Days ago, , Suffix is *.log And delete .
find . -mtime +3 -name “*.log” | xargs rm -rf {};
5、 Write a script to make a directory larger than 100k Move your file to /tmp Next
find . -size +100k -exec mv {} /tmp;
6、 How to determine whether a directory exists , If it doesn't exist, create a new one , Print information if it exists .
if [ ! –d /data/backup/ ];then
mkdir –p /data/backup/
else
echo “ directory already exists ”
fi
-d Representative directory
7、 Replace the directory in the file
sed ‘s:/usr/local:/tmp:g’ test.txt
perhaps
sed -i ‘s//usr/local//tmp/g’ test.txt
8、sed Common commands
How to get rid of the beginning . character :
sed -i ‘s/^.//g’ test.txt
Add a... At the beginning of the line a character :
sed ‘s/^/a/g’ test.txt
Add a... At the end of the line a character :
sed ‘s/$/a/’ tets.txt
Add a... After a specific line z character :
sed ‘/rumen/az’ test.txt
Add a c character :
sed ‘/rumenz/ic’ test.txt
9、sed Another usage is to find the current line , Then modify the parameters after the line
sed -i ‘/SELINUX/s/enforcing/disabled/’ /etc/selinux/config
sed Colon mode , It means that /tmp Change to /tmp/abc/.
sed -i ‘s:/tmp:/tmp/abc/:g’ test.txt
10、 Statistics Nginx Access log Top of the list of visits 20 Of ip Address
cat access.log |awk ‘{print $1}’|sort|uniq -c |sort -nr |head -20
annotation :sort Sort 、uniq( Check and delete the repeated rows and columns in the text file )
11、 Modify the text to ab Replace the ending with cd:
sed -e ‘s/ab$/cd/g’ b.txt
12、 Network packet capture :tcpdump
# Grab 56.7 adopt 80 Packets requested by the port .
tcpdump -nn host 192.168.56.7 and port 80
# exclude 0.22 80 port
tcpdump -nn host 192.168.56.7 or ! host 192.168.0.22 and port 80
13、 Statistics bash_history Most commonly used 20 Bar command
history | awk ‘{print $2}’ | sort | uniq -c | sort -k1,1nr | head -10
14、 Configure firewall scripts , Only remote hosts are allowed to access local 80 port
iptables -F
iptables -X
iptables -A INPUT -p tcp --dport 80 -j accept
iptables -A INPUT -p tcp -j REJECT
perhaps
iptables -A INPUT -m state --state NEW-m tcp -p tcp --dport 80 -j ACCEPT
边栏推荐
- 如何看待智慧城市建设中的改变和机遇?
- 嵌入式系統開發筆記80:應用Qt Designer進行主界面設計
- "Target detection" + "visual understanding" realizes the understanding of the input image
- Measurement of quadrature axis and direct axis inductance of three-phase permanent magnet synchronous motor
- 【深度学习】(4) Transformer 中的 Decoder 机制,附Pytorch完整代码
- Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
- [Master / slave] router election in DD message
- Learn Chapter 20 of vue3 (keep alive cache component)
- Leetcode learning - day 36
- In the innovation community, the "100 cities Tour" of the gold warehouse of the National People's Congress of 2022 was launched
猜你喜欢

Internet winter, how to spend three months to make a comeback
![[send email with error] 535 error:authentication failed](/img/58/8cd22fed1557077994cd78fd29f596.png)
[send email with error] 535 error:authentication failed
![[pat (basic level) practice] - [simple simulation] 1064 friends](/img/37/0ef0f8aae15ae574be1d76c97497c9.jpg)
[pat (basic level) practice] - [simple simulation] 1064 friends
![[ue4] event distribution mechanism of reflective event distributor and active call event mechanism](/img/44/6a26ad24d56ddd5156f3a31fa7e0b9.jpg)
[ue4] event distribution mechanism of reflective event distributor and active call event mechanism

Extension fragment

"Target detection" + "visual understanding" realizes the understanding of the input image

Mallbook: how can hotel enterprises break the situation in the post epidemic era?

Odeint et GPU

嵌入式系统开发笔记79:为什么要获取本机网卡IP地址

Class and object finalization
随机推荐
TASK04|數理統計
Concurrent mode of different performance testing tools
[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached
2022 t elevator repair new version test questions and t elevator repair simulation test question bank
TASK04|数理统计
Shell之分析服务器日志命令集锦
Day 52 - tree problem
NFT: utilisez EIP - 2981 pour commencer un voyage de redevances NFT
Learn Chapter 20 of vue3 (keep alive cache component)
NFT: start NFT royalty journey with eip-2981
【发送邮件报错】535 Error:authentication failed
Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
Custom components in applets
Haskell lightweight threads overhead and use on multicores
2022 polymerization process test questions and simulation test
2022 a special equipment related management (elevator) simulation test and a special equipment related management (elevator) certificate examination
JD intelligent customer service Yanxi intention system construction and intention recognition technology introduction
什么是权限?什么是角色?什么是用户?
做网站数据采集,怎么选择合适的服务器呢?
Maixll dock quick start