Common instructions
instruction | effect |
---|---|
pwd | Show current path |
tree | List the contents of the tree in a tree |
tree aaa | Display the content of aaa files in a tree shape |
ls | List files or folders in the directory |
ls -a | Show all files |
-l | Use longer format to list details ls -l |
-h | Use -l to display the file size in a user-friendly way ls -l -h |
Switch directory
instruction | effect |
---|---|
cd | Switch directory |
cd / | Root directory |
cd ~ some cd | Back to home directory |
cd - | Back to the last location |
cd … | Parent directory |
cd . | Current directory |
cd path | Switch to the specified path |
Create delete changes
instruction | effect |
---|---|
mkdir xxx | Create Folder |
mkdir -p a/b/c/d | Create folders recursively |
touch xxx | Create a file |
gedit xxx | Open the xxx file for editing. Not all Linux distributions support this command |
rm xxx | Deleted files or folders are not recoverable |
rm -i xxx | Add delete tips |
rm -ra | Recursively delete everything in a and a |
Copy move
instruction | effect |
---|---|
cp aaa acopy | Copy aaa source file path acopy target file path |
cp -v and aa acopy | You can see the copy process |
cp -i aaa acopy | You will be prompted to confirm before overwriting the file |
cp -r aaa acopy | Copy directory If the source file is a directory file, all subdirectories and files in the directory will be copied recursively |
cp -a aaa acopy | Copy the original attribute is usually used when copying the directory to retain the link file attribute and recursively copy |
mv aaa xxx | Move source path target path |
mv -i aaa xxx | Add tips |
mv -v aaa xxx | Show moving process |
mv old file name new file name | Move rename in a directory |
other
instruction | effect |
---|---|
clear or control l | Clear screen |
tab键 | Autocomplete |
which xx | View the location of the instruction |
control c | Terminate the execution of instructions |
control shift = | Enlarge the font displayed on the terminal |
control shift - | Reduce the font displayed on the terminal |
View files or merge file contents
instruction | effect |
---|---|
cat xxx | View file xxx |
cat -n xxx | Add numbers for each line starting from 1 |
cat -b xxx | Number non-blank lines |
cat -s xxx | Only one continuous blank line is displayed |
cat xxx aaa | Connect files xxx and aaa |
more xxx | 查看xxx文件内容的一部分 |
more +num xxx | num为数字 从num行开始查看xxx文件内容 |
more -p xxx | 先清屏再显示xxx文件内容 |
more -s xxx | 连续的空行 只显示一行 |
快捷键 | … |
空格 | 查看下一屏 |
回车 | 查看一行 |
control b | 查看上一屏 |
control f | 查看下一屏 |
q | 退出 |
指令扩展
指令 | 作用 |
---|---|
cal | 显示当前月的日历 |
cal -3 | 显示当前月以及上下月 |
cal -y | 显示一年 |
cal-j | 一年中的第xx天当前天数 |
cal 1970 | 显示1970年日历 |
date | 当前年月日和时间 |
date “+%Y年” | 当前年份 |
date “+%Y年%m” | 当前年月 |
date “+%F” | 当前年月日 |
histroy | 查看历史指令 |
histroy 30 | 显示最近使用的30条指令 |
!10 | 再重新执行一次曾经使用过的编号为10的指令 |