Python全栈 Linux基础之2.Linux终端命令简介

一、终端命令格式及帮助文档

1.终端命令的格式:

command [options] [parameter]
command [-options] [parameter]
命令名称 选项 传递给命令的参数

注意:
[ ] 代表内容可选填;
选项前面有 -,参数前面没有。
常见命令:
ls
文件列表。

Desktop    Downloads         Music     Public     Videos
Documents  examples.desktop  Pictures  Templates

pwd
当前路径。

/home/xxx

~ 表示家目录
clear
清屏。

2.help&&man

–help帮助文档:
command --help
显示command命令的帮助信息。

ls --help

打印

用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

必选参数对长短选项同时适用。
  -a, --all			不隐藏任何以. 开始的项目
  -A, --almost-all		列出除... 以外的任何项目
      --author			与-l 同时使用时列出每个文件的作者
  -b, --escape			以八进制溢出序列表示不可打印的字符
      --block-size=SIZE      scale sizes by SIZE before printing them; e.g.,
                               '--block-size=M' prints sizes in units of
                               1,048,576 bytes; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information);
                               with -l: show ctime and sort by name;
                               otherwise: sort by ctime, newest first
  -C                         list entries by columns
      --color[=WHEN]         colorize the output; WHEN can be 'always' (default
                               if omitted), 'auto', or 'never'; more info below
  ...
  -1                         list one file per line.  Avoid '\n' with -q or -b
      --help		显示此帮助信息并退出
      --version		显示版本信息并退出

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).

使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。

退出状态:
 0  正常
 1  一般问题 (例如:无法访问子文件夹)
 2  严重问题 (例如:无法使用命令行参数)
...

man使用手册:
man command
查询command命令的使用手册(man是manual的缩写,是Linux提供的手册)。

man ls

显示:
man command
手册中的操作按键

操作按键 功能
空格键 显示下一页
回车键 显示下一行
b back,显示上一页
f forward,向前和空格效果一样
q quit,退出

二、最常用的Linux命令

1.常用命令

命令 功能
ls list,列表显示当前目录下的内容
pwd print wrok directory ,查看当前所在路径
cd 路径名称 change directory,跳转到指定路径
touch 文件名称 创建这个文件
mkdir 文件夹名称 make directory, 创建这个文件夹
rm 文件名 remove,删除指定的文件
clear 清屏

注意:
rm无法删除文件夹,删除文件夹要用rm -r xxx
通过终端删除文件不会保存到回收站,直接彻底删除。

2.练习

到桌面下:

cd Desktop

再到Documents:

cd /home/corley/Documents

创建新文件:

touch 123.txt
touch 124.txt
touch 125.txt

创建新文件夹:

mkdir 123

查看123文件夹中的文件:

cd 123
pwd ls

删除文件:

rm 125.txt

回到桌面删除文件夹:

rm -r 123

三、终端常用快捷键

终端常用快捷键速查表

快捷键 功能
Tab 自动补全
ctrl + shift + + 放大字体
ctrl + - 缩小字体
Ctrl + Alt + t 打开终端窗口
Ctrl + a 光标移动到开始位置
Ctrl + e 光标移动到最末尾
Ctrl + k 删除此处至末尾的所有内容
Ctrl + u 删除此处至开始的所有内容
Ctrl + d 删除当前字符
Ctrl + h 删除当前字符前一个字符
Ctrl + w 删除此处到左边的单词
Ctrl + y 粘贴由Ctrl+u, Ctrl+d, Ctrl+w删除的单词
Ctrl + l 相当于clear,即清屏
Ctrl + r 查找历史命令
Ctrl + b 向回移动光标
Ctrl + f 向前移动光标
Ctrl + t 将光标位置的字符和前一个字符进行位置交换
Ctrl + & 恢复 ctrl+h 或者 ctrl+d 或者 ctrl+w 删除的内容
Ctrl + S 暂停屏幕输出
Ctrl + Q 继续屏幕输出
Ctrl + ← 光标移动到上一个单词的词首
Ctrl + → 光标移动到下一个单词的词尾
Ctrl + p 向上显示缓存命令
Ctrl + n 向下显示缓存命令
Ctrl + d 关闭终端
Ctrl + c 终止进程/命令
Shift + 上或下 终端上下滚动
Shift + PgUp/PgDn 终端上下翻页滚动
Ctrl + Shift + n 新终端
alt + F2 输入gnome-terminal打开终端
Shift + Ctrl + T 打开新的标签页
Shift + Ctrl + W 关闭标签页
Shift + Ctrl + C 复制
Shift + Ctrl + V 粘贴
Alt + 数字 切换至对应的标签页
Shift + Ctrl + N 打开新的终端窗口
Shift + Ctrl + Q 管壁终端窗口
Shift + Ctrl + PgUp/PgDn 左移右移标签页
Ctrl + PgUp/PgDn 切换标签页
F1 打开帮助指南
F10 激活菜单栏
F11 全屏切换
Alt + F 打开 “文件” 菜单(file)
Alt + E 打开 “编辑” 菜单(edit)
Alt + V 打开 “查看” 菜单(view)
Alt + S 打开 “搜索” 菜单(search)
Alt + T 打开 “终端” 菜单(terminal)
Alt + H 打开 “帮助” 菜单(help)

快捷键不用死记硬背,要形成肌肉记忆

发布了59 篇原创文章 · 获赞 238 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/CUFEECR/article/details/104074292