linux_shell

来源:互联网 发布:手机不能连接数据网络 编辑:程序博客网 时间:2024/05/22 05:33
uname -a
cat  /etc/redhat-release


ps -aux | grep skynet
ps -el | grep skynet
top | grep skynet
head -n ?


查看端口是否开放:
netstat -ntlp  | grep 3306
netstat -anp | grep 6379


压缩
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


解压
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




centos 7 防火墙
查看已经开放的端口:
firewall-cmd --list-ports
开启端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --zone=public --add-port=27017/tcp --permanent
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=9999/tcp --permanent
firewall-cmd --zone=public --add-port=10000/tcp --permanent
#重启firewall
firewall-cmd --reload


使profile立即生效:
. /etc/profile

source /etc/profile








查看硬盘:df -h
查看内存: free -m
查看cpu:  cat /proc/cpuinfo


通常会加参数h来直观显示大小,会使用G、M等来显示大文件
ll -h


du -h --max-depth=1 work/testing/*


grep 同时满足多个关键字和满足任意关键字
① grep -E "word1|word2|word3"   file.txt
   满足任意条件(word1、word2和word3之一)将匹配。
② grep word1 file.txt | grep word2 |grep word3
   必须同时满足三个条件(word1、word2和word3)才匹配。
grep 排除多个关键字
grep -v 'word1|word2'






Linux下高并发socket最大连接数所受的各种限制:
ulimit -n
内存限制:
ulimit -a | grep memory




kill -s 9 1827




Linux释放内存
释放网页缓存(To free pagecache):
sync; echo 1 > /proc/sys/vm/drop_caches
释放目录项和索引(To free dentries and inodes):
sync; echo 2 > /proc/sys/vm/drop_caches
释放网页缓存,目录项和索引(To free pagecache, dentries and inodes):
sync; echo 3 > /proc/sys/vm/drop_caches




查看内存情况:
more /proc/meminfo