基础命令
cd ..
cd /home
ls -l
pwd
ifconfig
halt
reboot
su - user
文件操作
mkdir /home/study
touch a.txt
cat a.txt
vim a.txt
mv a.txt /home/study
cp a.txt /home
rm -rf /home/a.txt
chmod 751 a.txt
du -sh /home
du -h --max-depth=1 /path/to/directory
df -h
进程操作
tail -300f spring.log
ps -ef | grep helloworld.jar
kill -9 [pid]
lsof -i:[port]
lsof -p [pid]
grep "字符串"
wc -l
lsof -p [pid] | wc -l
ll /proc/[pid]/cwd
whereis nginx
java 操作
nohup java -jar helloworld.jar >/dev/null 2>&1 &
jstack
jps
jstat -gcutil [pid] 1000 5
jmap -heap [pid]
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof
jmap -dump:format=b,file=dump.hprof 14660
jmap -histo pid | head -n20
配置
ln -s /home/startup.sh /etc/init.d/
ln -s /usr/local/jvm/jdk1.8.0_303/ /usr/jdk
sudo vim /etc/profile
export JAVA_HOME=/usr/jdk
export PATH=$JAVA_HOME/bin
source /etc/profile
su - username
source /etc/profile
中间件命令
/usr/local/bin/redis-server /user/local/redis/redis.conf
问题排查
free -h
top -o %MEM -b -n 1 | grep java | awk '{print "PID: "$1" \t 虚拟内存: "$5" \t 物理内存: "$6" \t 共享内存: "$7" \t CPU使用率: "$9"% \t 内存使用率: "$10"%"}'
lsof -p pid | grep cwd
ulimit -a
iptable抓包
sudo tcpdump -i any 'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack != 0' and port 8080
sudo tcpdump -i any -nn port 6789
tcpdump -i eth1 'tcp[tcpflags] = tcp-syn'
tcpdump -i eth1 'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack != 0'
sed -n '/2022-11-18 07:42:00/,/2022-11-18 08:00:00/p' spring.log >newlog.log
支持宋体
![linux字体文件夹](https://img-blog.csdnimg.cn/104a5f1b09264a3e97bcaaa40077ca25.png)
sudo fc-cache -f -v