0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

命令

Posted at

一:linux

1.文件与目录操作

pwd:查看当前路径
ls:列出当前目录下的所有文件(包括目录)
ls -l:列出文件的详细属性
ls -a:显示隐藏文件
ls -la:显示所有文件及其属性
cd 目录名.后缀:进入指定目录
cd .. :返回上一级目录
touch 文件名:创建空文件
mkdir 文件夹名:创建目录
rm 文件名:删除文件
rm -r 文件夹名:删除目录及其内容
cp 原文件 目标文件:复制文件
mv 原路径 目标路径:移动或重命名文件或目录
chmod +x 文件:给文件添加执行权限(常用于shell脚本)

2.文件查看与编辑

cat 文件名:查看文件内容(可用tab补全)
head 文件名:查看文件前几行(默认前10行)
head lines=2 文件名:查看前两行内容
tail 文件名:查看文件最后几行(默认后10行)
less 文件名:分页查看文件可滚动
vim 文件名:使用Vim编辑文件,i进入编辑,Esc退出编辑,:wq保存退出
echo 内容:打印内容

3.系统与查找

ps -ef:查看当前所有进程
top:实时查看系统资源使用情况
grep "关键字" 文件:搜索文件中包含关键字的行
find 路径 -name 文件名:查找指定路径下的文件
df -h:查看磁盘空间使用情况
du -sh 目录名:查看目录大小

二:git

1.初始化与克隆

①新建本地仓库 git init
②克隆远程仓库 git clone 仓库地址

2. 添加提交

①添加所有修改文件到暂存区 git add .
②提交暂存区内容 git commit -m "提交的信息"

3.推送与拉取

①推送到远程仓库 git push
②拉取并合并远程代码 git pull

4.分支

①查看本地分支 git branch
②创建分支 git branch 分支名
③切换分支 git checkout 分支名
④创建并切换分支 git checkout -b 分支名
⑤合并指定分支到当前分支 git merge 分支名
⑥删除分支 git branch -d 分支名

5.其他命令

①将文件从暂存区移除 git reset HEAD 文件名
②将当前分支变基到目标分支 git rebase 分支名
③给当前提交打标签(发布版本用) git tag 版本号

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?