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
/usr/bin/java -XX:MaxPermSize=256m -Dpermissive-script-security.enabled=true -jar /home/jenkins/jenkins.war
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