Linux常用命令汇总

文章目录

整理如下,随时补充更新:

Linux系统命令

内存相关

bash 复制代码
# 查看内存占用最高的进程
ps aux --sort=-%mem | head
ps aux --sort=-%cpu | head

top,按照M按照内存排序,按下P按照CPU排序,按下E转换为KB/MB/GB

文件相关

bash 复制代码
# 查看当前磁盘占用
df -h

# 查看当前目录大小
du -sh

# 查看当前目录下第一层文件夹的大小,按照由大到小排序
du -sh * | sort -rh (文件过多的话,可以加 | less)

# 同上,但可以指定层级
du -lh --max-depth=1 | sort -rh

# 查看进程打开的文件
lsof | grep xxx (记得加上grep,否则返回的数据会很多)

Git

bash 复制代码
# 查看全局配置和远程仓库地址
git config --global --list 
git remote -v

# 修改全局配置
git config --global user.name "renxing" 
git config --global user.email "renxing@qq.com"
git config --global alias.s status # 起个别名,之后可以用 git s 代替 git status,下同
git config --global alias.c checkout
git config --global alias.d diff
git config --global alias.p pull

Git常用的shell脚本

shell 复制代码
# git提交代码,并直接合并到 test 分支 的shell脚本
# 运行方式: sh git-push-merge-test.sh 提交代码的备注信息

#提交本地代码
if [ ! -n "$1" ] ;then
   mark="修改"
else
   mark=$1
fi

git pull
git add .
git commit -m "$mark"
git push

#获取当前分支名称
now_branch=$(git branch --show-current)
echo $now_branch

#切换到test分支,然后合并当前分支,push后,再次回到当前分支
git checkout test
git pull
git merge $now_branch
git push
git checkout $now_branch
相关推荐
~狂想家~29 分钟前
Ubuntu20.04安装和配置Samba实现Win11下共享文件夹
linux·ubuntu·samba
ansondroider33 分钟前
Ubuntu 抽取系统制作便于chroot的镜像文件
linux·ubuntu·chroot
羚羊角uou1 小时前
【Linux】编辑器vim和编译器gcc/g++
linux·运维·编辑器
努力一点9481 小时前
ubuntu22.04系统入门 linux入门 简单命令基础复习 实现以及实践
linux·运维·服务器·ubuntu·gpu算力
帅帅梓2 小时前
Linux性能检测与调优
linux·运维·php
van叶~2 小时前
Linux网络-------3.应⽤层协议HTTP
linux·网络·http
花小璇学linux3 小时前
imx6ull-驱动开发篇5——新字符设备驱动实验
linux·驱动开发·imx6ull·嵌入式软件
饭碗的彼岸one3 小时前
重生之我在10天内卷赢C++ - DAY 1
linux·开发语言·c++·经验分享·笔记·学习方法
Asuicao3 小时前
ansible巡检脚本
linux·运维·ansible
被遗忘的旋律.3 小时前
Linux驱动开发笔记(五)——设备树(下)——OF函数
linux·驱动开发·笔记