ps: 随时补充,仅列举最常用命令。
文件系统相关:
- 切换目录: cd / pushd / popd / dir
- 查看当前目录位置:pwd
- 查看当前目录内容: ls -alh
- 查看当前目录总大小:du -sh
- 查看当前目录子目录大小: du -lh --max-depth=1 | sort -hr
- 查看文件属性:stat ~/.bashrc
- 复制:cp -r src dest; install …
- 删除:rm -rf test
- 创建软链接:ln -sf /root/test testlink
- 编辑文件:vi; vim; nano; gedit; echo “append text” >> test
- 查看文件:cat; less -R; more; head -n1; tail -n1; tail -f; tailf;
- 查找文件:find / -name .git
- 查找包含关键词到文件:grep -nR bashrc
- 查看可执行程序链接库:ldd ./a.out
- 查找命令所在位置:which cat
系统资源相关:
- 查看系统内核:uname -a
- 查看系统发行版本:cat /etc/os-release
- 查看进程:ps -ef | grep root
- 查看资源使用率:top
- 查看内存:free -h; cat /proc/meminfo
- 查看磁盘:df -h
- 查看挂载:mount
网络相关:
- 查看ip:ip a; ifconfig
- 连通性测试:ping
- 下载资源:wget -O dest.zip https://127.0.0.1/src.zip
- 查看资源:curl www.baidu.com
- 远程登录ssh:ssh root@127.0.0.1
- 远程传输文件:scp -r root@127.0.0.1:/root/ ./test/
yum包管理相关(centos):
- 安装软件包:yum install -y git
- 卸载软件包:yum remove git
- 软件包开发版后缀:-devel
apt包管理相关(debian/ubuntu):
- 更新apt仓库:apt-get update
- 升级系统:apt-get upgrade
- 安装软件包:apt-get install -y git
- 卸载软件包:apt-get …
- 软件包开发版后转:-dev
dnf包管理相关(fedaro/centos8):
pacman包管理相关(archlinux):
rpm包管理相关:
- 安装软件包:rpm -ivh …
deb包管理相关:
- 安装软件包:dpkg -i …
pip包管理相关:
- 查看已安装软件包:pip3 list
- 安装软件包:pip3 install numpy
- 卸载软件包:pip3 uninstall numpy
git相关:
- 查看git状态:git status
- 查看git分支:git branch -avv
- 更新当前分支:git pull
- 更新其他分支:git fetch ?
- 签出git分支:git checkout origin/dev -b my_dev
- 保存修改状态:git stash
- 恢复修改状态:git stash apply
- 增加待提交:git add .
- 提交:git commit -m “new commit”
- 推送新提交:git push
docker相关:
- 根据Dockerfile构建镜像:docker build -t your_name/git:latest . |& tee build.log
- 拉取镜像:docker pull centos:7
- 推送镜像:docker push your_name/git:latest
- 查看本地镜像:docker images; docker image ls
- 运行镜像:docker run -dit --name test --privileged=true -v /root/data:/root/data -p 80:80 centos:7 /usr/sbin/init
- 查看镜像状态:docker ps -a
- 执行镜像:docker exec -it test /bin/bash
- 停止镜像:docker stop test
- 启动镜像:docker start test
- 重启镜像:docker restart test
- 移除镜像:docker rm test
gdb相关:
- 使用gdb加载程序:gdb ./a.out
- 运行程序:r --argument_of_a_out
- 查看堆栈:bt
- 继续运行:n