Linux Command Quick Reference Guide (2nd Edition) learning

Chapter 1, we need to know the command line related matters

Table 1-1 How to use special characters in the file name characters
character Suggest
/ Never use. Can not escape
\ You must be escaped. Avoid using
_ It must not be used as a file or directory name of the first character
[] You must be escaped. Avoid using
{} You must be escaped. Avoid using
* You must be escaped. Avoid using
? You must be escaped. Avoid using
' You must be escaped. Avoid using
" You must be escaped. Avoid using
<Space> You must be escaped. Usually can not be avoided, but try to avoid

 

Table 1-2 and matching the wildcard meanings
symbol meaning
* Matches zero or more arbitrary characters
Matches any single character
[] Matching a set of single character
{} String and scope {jpg, png}

 clear: Reset screen

Chapter 2, the file system navigation

ls command Detailed
ls Lists the files and folders
ls path List Folder Contents
ls /home/*.wmv Use wildcards to list the contents of a folder
ls -R/ls --recursive View the list of files in subfolders
ls -1/ls --format=single-column To display the content list row
ls -m / ls = COMM --format Display the contents of a comma-separated list
ls -a/ls -all View hidden files and folders
ls -A View does not appear. .. and hidden folders
ls -F/ls --classfy

The type of visual display file

character meaning
* executable file
/ table of Contents
@ Symbolic link file
| FIFO (also referred to as a named pipe)
= Sockets
ls --color

Display content in a variety of colors

colour meaning
The default text color shell Trivial File
green executable file
blue table of Contents
Fuchsia Symbolic link file
yellow FIFO
Fuchsia Sockets
red Compressed files (.tar, .zip, .deb, .rpm)
Fuchsia Image files (.jpg, .gif, .png, .tiff)
Fuchsia Audio files (.mp3, .ogg, .wav)
ls -l / ls = long --format

Lists permissions, ownership, and other information

character file type
_ Trivial File
_ executable file
d table of Contents
l Symbolic link file
s Sockets
b Block device
c Character device
p Named Pipes (AKA FIFO)

Allow Read w r x allows rewriting allowed to perform - in what position represents what can not

Members of the owner / group (root) / Other user

 ls -r / ls --reverse Reverse display file contents
 ls -t/ls --sort=time Sort content by date and time
ls -S/ls --sort=size Sort the contents by file size
ls -h/ls --human-readable A k, M, G displays the file size
ls -i 理解Linux存储文件的方式显示文件索引节点号
pwd

显示当前目录路径

pwd -P/pwd --physical 显示目标路径

pwd -L/pwd --logical 显示逻辑路径

cd

切换路径

cd - 切换到之前路径

 第3章、创建和消毁

touch命令

touch a.txt 将文件修改为当前时间
touch -t

将文件修改为任意所需的时间

-t[[CC]YY]MMDDhhmm[.ss]

字符 含义
CC 4位年份数字中前2位字符
YY 2位数字的年份:
1、如果是00~68,假设年份的前2位数字是20
2、如果是69~99,假设年份的前2位数字是19
如果没有,那假设为当前年份
MM 月份(01~12)
DD 日期(01-31)
hh 小时(01~23)
mm 分钟(00~59)
ss 秒钟(00~59)

 

touch notexist.txt 创建空文件notexist.txt

 

mkdir 命令
mkdir new 创建新目录

mkdir -p tets/test

mkdir --parents test/test

创建新目录以及必要的子目录

  

  cp命令

 cp a.txt a_copy.txt

 cp 源文件 复制后路径

 cp 源文件 .(在当前目录创建源文件快捷方式)

复制文件
 cp *  使用通配符复制文件
 cp -v/cp  --verbose  显示复制文件的过程
 cp -i/cp --interactive  防止在复制是覆盖重要文件
cp -r/cp --recursive 复制目录以及子文件
cp -a/cp --archive/cp -dpr/cp --no-dereference --preserve -recursive 为建立完善副本而将文件复制到另外的一个目录

 

mv命令

mv a/a a/b

mv a/a .

移动文件和文件夹

mv a b

重命名文件和文件夹

a如果是软链接加上/代表软链接指向的目录

 

ln命令
ln a.txt b.txt 创建指向另一个文件或目录的链接

sudo ln -s /var/www /www

sudo ln -s /var/www .

sudo ln -s /var/www

创建软链接
unlink a.txt 移除链接

 

硬链接与软链接区别
类型 硬链接 软链接
链接指向 索引节点 名称
链接到目录
跨文件系统链接
移动源文件 链接有效 链接断开
更改目标的名称 链接有效 链接断开 
 删除链接  目标仍然存在*   目标仍然存在*
链接的索引节点  与目标相同 与目标不同
存储空间 ~4KB

 

rm 命令
rm a.txt 删除文件
rm *.txt 使用通配符删除文件
rm -i 防止删除关键文件
rmdir path 删除空目录
rm -rf/rm --recursive --force          删除文件和非空目录

第4章学习命令

man命令[manual(手册)]
man ls

查找ls命令相关信息

NAME 命令名称及功能简要说明
SYNOPSIS 用法说明,包括可用的选项
DESCRIPTION 命令功能的详细说明,可能包括每一个选项的意义
OPTIONS 说明每一项的意义
FILES 此命令相关的配置文件
BUGS 已经错误,以及如何汇报错误
COPYRIGHT 版权信息
SEE ALSO 参见
man -f/man --whatis/whatis 基于命令名称来快速弄清其功能
 man -k/man --apropos/apropos 基于其功能搜索命令
 man [1-2] passwd  读取特定页数的手册

 

info命令
info info 学习info命令
info -d 添加包含info格式帮助文档的目录
info -f 指定要读取的info格式的帮助文档
info -n 指定首先访问的info帮助文件的节点
 info按键
? 显示info的常用快捷键
N 显示(相对于本节点的)下一节点的文档内容
P 显示(相对于本节点的)下一节点的文档内容
U 进入当前命令所在的主题
M 敲M键后输入命令的名称就可以查看该命令的帮助文档了
G 敲G键后输入主题名称,进入该主题
L 回到上一个访问的页面
SPACE 向前滚动一页
BACKUP/DEL 向后滚动一页
Q 退出info

 

whereis 命令
whereis kword 查找命令的可执行文件、源文件、手册路径
whereis -b 只查找二进制文件路径
whereis -m 只查找手册路径

whereis -s

只查找源文件路径

 

which命令
which kword 查找将要运行命令的路径
which -a kword/whereis -s kword 显示kword命令全部路径

 

type命令
type ls

shell如何解释命令

alias 别名
keyword 关键字,Shell保留字
function 函数,Shell函数
builtin 内建命令,Shell内建命令
file 文件,磁盘文件,外部命令
type -t ls builtin

Guess you like

Origin www.cnblogs.com/miaosj/p/11276793.html