1,查看内核版本信息:
uname -a
2,查看发行版本信息:
cat /etc/issue
cat /etc/redhat-release
cat /etc/centos-release
3,sudo执行上条没有权限的命令
sudo !!
4,ssh登陆和退出
ssh jenkins@test.com
~.
5,查看内存使用
free -m
6,启动指定服务
sudo service start jenkins
sudo service start httpd
7,查看当前系统时间
date
date -R
8,查找当前文件夹和其子文件夹中含有特定名称的文件
find . -name "*ds.xml"
find . | grep ds.xml
tree -P "*ds.xml"
9,查找当前文件夹和其子文件夹中含有特定内容的文件
grep -rnw . -e 'hello'
-r or -R is recursive
-n is line number
-w stands for match the whole word
grep -rnw . -e 'hello' --include \*.xml
10, 查找出特定内容并删除
grep -rlw . -e 'test' | xargs rm -fv
grep - search text in files.
-F - treat the string as is, ignore possible regular expressions.
-R - recursive search.
-l - only print filenames.
xargs - give the output to the next program.
rm - remove.
-f - force (don't ask "Are you sure?").
-v - is optional, it will pring the files that were removed.
11, java命令行直接启动war
nohup java -Xms2g -Xmx5g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/jenkins/.jenkins/logs/ -Djava.rmi.server.hostname=team-platops -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=11099 -Dcom.sun.management.jmxremote.rmi.port=11099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dpermissive-script-security.enabled=true -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -jar /home/jenkins/jenkins.war --logfile=/home/jenkins/.jenkins/logs/jenkins.log --extractedFilesFolder=/tmp &
12, 删除指定大小的文件
find . -type f -size +6M -delete
find . -name "*.tif" -type f -size -2k -delete
13. 仅列出前n个文件
ls | head -10
14. 查看文件行数
wc -l catalina.out
15. 清除buffer & cache
free && sync && echo 3 > /proc/sys/vm/drop_caches && free
16.查看当前目录下一级子文件和子目录占用的磁盘容量
du -lh --max-depth=1
17. 统计当前文件夹(目录)大小,并按文件大小排序:
du -sh * | sort -n
18. tar
tar -czvf test.tar.gz testfolder
tar -czvf test.tar.gz test1.txt test2.txt
tar -tzf test.tar.gz
tar -xzf test.tar.gz
c
— create an archive file (as opposed to extract, which isx
)f
— filename of the archive filez
— filter archive throughgzip
(remove this option to create a.tar
file)- v, --verbose verbosely list files processed