Personally commonly used linux command notes

Some commonly used linux command records and backups collected by individuals

Firewall
//Open port 8080

firewall-cmd --zone=public --add-port=8080/tcp --permanent 

// restart the firewall

firewall-cmd --reload

filter port process

netstat -tnlp | grep 3001
ps -ef | grep 3000

View process status

ps -aux | grep java

View the ports occupied by the process

netstat -tnlp | grep java

lsof can list open files and list information about files opened by processes on the system.

lsof -i -P | grep java

Modify the user and user group to which the file belongs (R: including all subfiles)

chown -vR user:user up-sys/

Modify file permissions (R: include all subfiles)

chmod -R 777 fileName

check disk space

df-lh

ll | grep ".x" | awk -F ' ' '{print $2}' | sort -n | uniq  -c

Soft link (when creating a soft link, there is no need to create a folder)

ln -s fileName newFileName

​Result: newFileName => fileName

hide log

set +o history

open hidden log

set -o history

compression

tar -cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg 
tar -czf jpg.tar.gz *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz
 tar -cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2
tar -cZf jpg.tar.Z *.jpg   //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux
zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

decompress

tar -xvf file.tar //解压 tar包
tar -xzvf file.tar.gz //解压tar.gz
tar -xjvf file.tar.bz2   //解压 tar.bz2
tar -xZvf file.tar.Z   //解压tar.Z
unrar e file.rar //解压rar
unzip file.zip //解压zip

scp upload file

scp -P 12349 upload_file username@server

-r folder

clean disk - clean log (redirect empty file)

[root@hb logs]# > catalina.out   

Guess you like

Origin blog.csdn.net/a0405221/article/details/128056805