Linux basis - documents related to command

Linux basis - documents related to command

Create and delete operations

touch

Create a file or modify files Time
1. If the file does not exist , you can create a blank file.
2. If the file shall be subject to exist , you can modify the last modification date of the file.
Here Insert Picture Description

mkdir

Create a new directory

Options meaning
-p Create directories recursively

The name of the new directory can not be the current directory has a directory or a file with the same name

Creating multiple directories
Here Insert Picture Description
can not be the same name
Here Insert Picture Description

rm

Delete files or directories
using the rm command to be careful, because they can not recover the deleted files

parameter meaning
-f Force delete, ignore the file does not exist, without prompting
-r Contents recursively delete a directory, delete the folder must be added to this parameter

Here Insert Picture Description
Delete files on the desktop to the end of the 1
Here Insert Picture Description
to delete all files on the desktop
Here Insert Picture Description

Copy and move files

No. command English correspondence effect
01 tree [directory name] tree A tree chart lists the file directory structure
02 cp source file destination copy Copy the file or directory
03 mv source file destination move Move a file or directory / rename files or directories

tree

tree command to list the files in the directory structure in a tree diagram

Options meaning
-d Display only a directory

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

cp

cp command function is to give the files or directories to copy to another file or directory , the equivalent of the DOS Copy command is.

Options meaning
-f Existing target files directly overwritten without prompt
-i Prompt before overwriting files
-r If the source file is given a directory file, then cp will copy recursively all directories and files in the directory, the target file must be a directory name

Here Insert Picture Description
or
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

mv

mv 命令可以用来移动 文件目录,也可以给文件或目录重命名

选项 含义
-i 覆盖文件前提示

查看文件内容

序号 命令 对应英文 作用
01 cat 文件名 concatenate 查看文件内容、创建文件、文件合并、追加文件内容等功能
02 more 文件名 more 分屏显示文件内容
03 grep 搜索文本文件名 grep 搜索文本文件内容

cat

cat 命令可以用来查看文件内容、创建文件、文件合并、追加文件功能等功能。
cat 会一次显示所有的内容,适合查看内容较少的文本文件。

选项 含义
-b 对非空输出行编号
-n 对输出的所有行编号

Linux中还有一个 nl 的命令和 cat -b 的效果等价
Here Insert Picture Description
Here Insert Picture Description
把文档内容变长后:
Here Insert Picture Description
Here Insert Picture Description

-b 和 -n 选项输出行号

Here Insert Picture Description
Here Insert Picture Description

more

more 命令可以用于分屏显示文件内容,每次只显示一页内容。
适合于查看内容较多的文本文件
使用more的操作键:

操作键 功能
空格键 显示手册页的下一屏
Enter 键 一次滚动手册页的一行
b 回滚一屏
f 前滚一屏
q 退出
/word 搜索 word 字符串

Here Insert Picture Description

把文档内容变长后:
Here Insert Picture Description
Here Insert Picture Description

grep

Linux 系统中 grep 命令是一种强大的文本搜索工具。
grep 允许对文本文件进行模式查找,所谓模式查找,又被称为正则表达式。

选项 含义
-n 显示匹配行及行号
-v 显示不包含匹配文本的所有行(相当于求反)
-i 忽略大小写

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
常用的两种模式查找

参数 含义
^a 行首,搜索以a开头的行
ke$ 行尾,搜索以ke结束的行

Here Insert Picture Description
Here Insert Picture Description
显示行号
Here Insert Picture Description
Here Insert Picture Description

其他

echo 文字内容

echo parameter specifies the text displayed in the terminal, and is usually redirected in combination
Here Insert Picture Description

Redirect> and >>

Linux allows the command execution result redirected to a file
to be displayed in the present content output / additional terminal on the specified file in
which:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
additional content
Here Insert Picture Description

Pipeline |

Linux allows the output of a command can be through the pipeline as the input of another command
can be understood in real life tube, the tube is a plug stuff in, take out the other end, where | is divided into left and right ends of the left end plug things ( write), the right to take things (read)
commonly used for piping commands there:
More: split-screen display content
grep: command execution on the basis of the results of the query specified text
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

He published 185 original articles · won praise 8 · views 9940

Guess you like

Origin blog.csdn.net/linjiayina/article/details/104433065