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
|
||||||||||||||||||||
ls --color | Display content in a variety of colors
|
||||||||||||||||||||
ls -l / ls = long --format | Lists permissions, ownership, and other information
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]
|
||||||||||||||||
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命令相关信息
|
||||||||||||||||
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按键 |
|
whereis 命令 | |
whereis kword | 查找命令的可执行文件、源文件、手册路径 |
whereis -b | 只查找二进制文件路径 |
whereis -m | 只查找手册路径 |
whereis -s |
只查找源文件路径 |
which命令 | |
which kword | 查找将要运行命令的路径 |
which -a kword/whereis -s kword | 显示kword命令全部路径 |
type命令 | |||||||||||
type ls | shell如何解释命令
|
||||||||||
type -t ls | builtin |