Linux命令收集

本文全面介绍了Linux环境下常用的系统管理命令,包括查看系统信息、内存使用情况、启动服务、查找文件等,旨在帮助Linux用户高效完成日常运维工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 is x)
  • f — filename of the archive file
  • z — filter archive through gzip (remove this option to create a .tar file)
  • v, --verbose verbosely list files processed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值