My Linux Study Notes (4)
Files and directories Quick commonly used commands
on one | command | option | English correspondence | For work |
---|---|---|---|---|
0 | ls | list | View the contents of the current folder | |
-a | all | View all contents of the current folder (including hidden content) | ||
-l | list | Display file details in a list | ||
-h | humanized | With -l displays the file size in a humane way | ||
1 | pwd | print work directory | View current folder | |
2 | cd | change directory | Change directory | |
Switching home directory | ||||
- | Switch back and forth between the two most recent working directory | |||
3 | touch | touch | Create a directory or file modification time | |
4 | mkdir | make directory | Create a directory | |
-p | Create a directory recursively | |||
5 | rm | remove | To delete a file or directory | |
-f | force | Forcibly remove non-existent file does not prompt | ||
-r | Recursively delete the contents of the directory, delete the folder will be added | |||
6 | tree | tree | A tree chart lists the file directory structure | |
-d | directory | Display only a directory | ||
7 | cp | copy | Copy the file or content | |
-i | inform | Prompt before overwriting files | ||
-r | Recursively copy a folder | |||
8 | mv | move | Move files / directories or naming their weight | |
-i | inform | Prompt before overwriting files | ||
9 | cat | concatenate | View / create files, merge, append the contents of the file | |
-b | Non-blank line output line number | |||
-n | Output line numbers for all lines | |||
10 | more | more | Split-screen display file contents | |
空格 | The next display screen | |||
|
The next line | |||
-b | back | Display the previous line | ||
-f | forward | The next display screen | ||
-q | quit | drop out | ||
/word | Search word string | |||
11 | grep | Find mode / regular expressions | ||
-n | Display matching lines and line number | |||
-v | Line shows the text does not contain a match | |||
-i | ignore | Ignore case | ||
12 | echo | echo | In the terminal display, generally redirected in conjunction |
Terminal Shortcuts
- Enlarge Font: CTRL+ shift+=
- Decrease font: CTRL+-
- Autocomplete:Tab
- If the input is not ambiguous, the system auto-complete
- If there is ambiguity, then click Tab, you will be prompted
- Switching previously used command:↑ ↓
- 退出选择,病不想执行当前选中命令:CTRL + c
概析
ls
命令格式: command [-option]
Linux文件或目录名称最长可以有256个字符,以 . 开头的文件为隐藏文件,需要用 -a来查看
-a、-l、-h:
联合使用:
通配符的使用
通配符 | 含义 |
---|---|
* | 代表任意个数个字符 |
? | 代表任意一个字符 |
[abc] | 匹配a、b、c中任意一个 |
pwd
命令格式 command
打印当前工作目录
cd
命令格式 command parameter
命令 | 含义 |
---|---|
cd | 切换到家目录 |
cd ~ | 切换到家目录 |
cd . | 保持当前目录不变 |
cd.. | 切到上一级目录 |
cd - | 在最近两次工作目录间切换 |
相对路径和绝对路径
- 相对路径在输入路径时,最前面不是 / 或者 ~ ,表示相对当前目录所在的目录位置
- 绝对路径 在输入路径时,最前面是 / 或者 ~,表示从根目录/家目录开始的具体目录位置
touch
- 创建文件或修改文件时间
如果文件 不存在,可以创建一个空白文件
如果文件 已经存在,可以修改文件的末次修改日期
mkdir
命令格式 command [-option] parameter
rm
命令格式 command [-option] parameter
使用 rm 删除的文件不能恢复
tree
命令格式 command [-option] [parameter]
cp
命令格式 command [-option] parameter(源) parameter(目标)
- cp 命令的功能是将给出的 文件 或 目录 复制到另一个 文件 或 目录 中,相当于 DOS 下的 copy 命令
mv
命令格式 command [-option] parameter(源) parameter(目标)
- mv 命令可以用来 移动 文件 或 目录 ,也可以给 文件或目录重命名
cat
命令格式 command [-option] parameter
more
命令格式 command [-option] parameter
cat 适合内容较少的文件
more 适合内容较多的文件
grep
命令格式 command [-option] parameter parameter
常用的两种模式查找
参数 含义 ^a 寻找以a开头的行 b$ 寻找以b结尾的行
echo
命令格式 command parameter
重定向 > 和 >>
- Linux 允许将命令执行结果 重定向到一个 文件
- 将本应显示在终端上的内容 输出/追加 到指定文件中
其中 >
表示输出,会覆盖文件原有的内容>>
表示追加,会将内容追加到已有文件的末尾
管道 |
- Linux 允许将 一个命令的输出 可以通过管道 做为另一个命令的输入
- 可以理解现实生活中的管子,管子的一头塞东西进去,另一头取出来,这里 | 的左右分为两端,左端塞东西(写),右端取东西(读)
常用的管道命令有: - more:分屏显示内容
- grep:在命令执行结果的基础上查询指定的文本