下面这些是平时经常会用到的命令,命令并不完全但是是最实用的。
终端快捷键
指令 |
作用 |
CTRL + C |
中断并杀死进程 |
CTRL + L |
清空内容 |
CTRL + R |
搜索历史命令 |
Tab |
补全命令 |
CTRL + Shift + C |
复制内容 |
CTRL + Shift + V |
粘贴内容 |
系统信息
指令 |
作用 |
uname -a |
显示基本系统信息 |
cat /etc/release |
显示基本的发行信息 |
hostname |
电脑名称 |
whoami |
当前登录的用户名 |
文件和目录列表
指令 |
作用 |
pwd |
显示当前工作目录 |
ls |
列出目录中的文件 |
ls -a |
包含以开头的文件。或“隐藏”文件 |
ls -la |
显示所有文件的日期和大小信息 |
ls -lS |
按文件大小排序,从大到大 |
ls -lSr |
按文件大小排序,从小到大 |
ls -lt |
按修改时间排序,从新到旧 |
ls -ltr |
按修改时间排序,最新倒数 |
ls -lh |
显示Kilo,Mega,Giga中的文件大小 |
tree |
以树状格式列出目录内容 |
tree -L N |
以树状格式列出目录的内容,限制为N个级别 |
目录操作
指令 |
作用 |
cd path/to/directory |
更改当前工作目录 |
mkdir directory |
建立目录 |
mkdir -p /path/to/directory |
创建目录和子目录 |
rmdir directory |
删除一个空目录 |
rm -rv directory |
递归删除目录及其下的所有内容 |
cp -rv directory destination-directory |
将目录复制到新位置 |
mv -r directory destination-directory |
将目录移到新位置 |
mv directory new-directory |
重命名目录 |
文件操作
指令 |
作用 |
rm file |
删除档案 |
rm -rf diretory |
删除目录下所有文件 |
cp file destination/directory |
将文件复制到目标目录 |
mv file destination/directory |
将文件移到目标目录 |
mv file new-file |
重命名文件 |
压缩解压
指令 |
作用 |
tar -cf archive.tar file1 file2 file3 |
创建普通的tar存档 |
tar -czf archive.tar.gz file1 file2 file3 |
创建gzip存档 |
tar -cjf archive.tar.bz file1 file2 file3 |
创建bzip tar存档 |
tar -xf archive.tar |
提取普通tar存档 |
tar -xzf archive.tar.gz |
提取gzip存档 |
tar -xjf archive.tar.bz |
提取bzip tar存档 |
zip -r archive.zip directory/ file1 file2 file3 |
创建zip存档 |
unzip archive.zip |
提取zip存档 |
磁盘,目录和文件磁盘的使用情况/大小
指令 |
作用 |
df -h |
显示所有文件系统磁盘空间使用情况 |
du -hs /path/to/directory |
显示目录大小 |
du -hd N /path/to/directory |
显示子目录的大小N级深 |
ls -lh /path/to/directory |
显示Kilo,Mega,Giga中的文件大小 |
搜索
指令 |
作用 |
find path/to/directory -iname "*.jpg" |
在目录及其子目录中查找文件 |
grep -r "foo" /path/to/directory |
递归查找包含字符串的文件 |
进程管理
指令 |
作用 |
ps -ef /(/用分隔符代替) grep process-name |
查找具有进程名称的进程并为其获取进程ID |
kill process-id |
用process-id终止进程 |
kill -9 process-id |
用id process-id强制终止进程 |
top |
列出正在运行的进程,例如Windows Task Manager |
开发者工具
指令 |
作用 |
nm |
列出目标文件中的符号,等效于Windows dumpbin.exe |
ldd |
列出共享库的依赖关系,等效于Windows depends.exe |
远程操作
指令 |
作用 |
ssh user@host |
使用安全外壳连接到远程计算机 ssh |
scp path/to/local/file user@host:path/to/remote/directory |
将本地文件复制到远程计算机 |
scp user@host:path/to/remote/file path/to/local/directory |
将远程文件复制到本地计算机 |
scp -r path/to/local/directory user@host:path/to/remote/directory |
将本地目录递归复制到远程计算机 |
scp -r user@host:path/to/remote/directory path/to/local/directory |
将远程目录递归复制到本地计算机 |
实用工具
指令 |
作用 |
history |
列出最近运行的命令 |
man command |
命令的帮助页面 |
clear |
清除终端屏幕 |
常用命令后续还会逐渐添加完善,有啥遗漏的也希望大家可以留言评论。
文章评论