1.cd /etc
切换到/下etc目录
[root@localhost ~]# cd /etc
[root@localhost etc]#
2.pwd 查看当前目录
[root@localhost etc]# pwd
/etc
3.cd 切换到当前用户的家目录下
cd 目录 切换目录
cd - 切换到上次所在的目录
cd .. 切换到上级目录
cd ~ 切换到当前用户的家目录下
cd ../.. 切换到上两级目录
[root@localhost etc]# cd
[root@localhost ~]# cd -
/etc
[root@localhost etc]# cd ..
[root@localhost /]# cd ~
[root@localhost ~]# cd ../..
[root@localhost /]#
4.ls 用来列出当前目录下的文件或目录信息
ls -l显示文件或者目录的详细信息 ls -l 等价于 ll
-a 显示所有文件,包括以“.”开头的隐藏文件。
-ld 如果参数是目录,以得到目录的详细信息
[root@localhost wang]# ls
wsl
[root@localhost wang]# ls -l
总用量 0
-rw-r--r--. 1 root root 0 3月 23 19:55 wsl
[root@localhost wang]# ls -ld
drwxr-xr-x. 2 root root 17 3月 23 19:55 .
[root@localhost wang]#
5.cat 查看文件内容
-n 显示行号
[root@localhost etc]# cat -n passwd
6.more 分屏显示文件内容
[root@localhost etc]# more passwd
7.less 分屏显示文件内容
[root@localhost etc]# less passwd
8.head 查看文件前十行内容
[root@localhost etc]# head passwd
9.tail 查看文件后十行内容
[root@localhost etc]# tail passwd
10.cp 复制 (copy)
cp /etc/passwd /tmp/passwd
11..管道 | 作用是把前面命令的结果传递给后面的命令
[root@localhost tmp]# head -6 passwd |tail -1
sync:x:5:0:sync:/sbin:/bin/sync
12.wc -l 文件名 统计文件的行数
[root@localhost tmp]# wc -l passwd
42 passwd
13.touch 文件名 创建目录
[root@localhost tmp]# touch wang
14.mkdir 创建目录 (make director)
[root@localhost tmp]# mkdir wsl
-p 创建多级目录,递归的创建目录
[root@localhost ~]# mkdir -p a/b/c/d
[root@localhost ~]# ls
a initial-setup-ks.cfg
15.vim 字处理器,编辑器
末行模式 在编辑模式下按:进入
[root@localhost tmp]# vim wang
123
456
~
~
~
:wq
:q 正常退出
:q!强制退出 不保存退出
:wq 保存退出
:wq! 强制保存退出
: set nu 显示行号
: set nonu 取消行号
16.rm 删除 (remove)
rm 文件 删除文件
[root@localhost tmp]# rm wang
rm:是否删除普通文件 "wang"?y
17.rm -rf 删除目录
[root@localhost tmp]# rm -rf wsl
18.mv 移动(move)
[root@localhost ~]# mv a /etc
19.clear 清屏
[root@localhost ~]# clear
20.uname 查看系统信息
[root@localhost ~]# uname
Linux
21.uname -a 查看系统详细信息
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
22.shutdown [参数] 时间 [警示信息]
-r reboot 重启
-h halt 关机
now 立即关机
hh:mm 小时:分钟
+m 在多少分钟之后关机
[root@localhost ~]# shutdown -h +10
[root@localhost ~]# shutdown -h +10
Shutdown scheduled for 四 2022-03-24 15:41:29 CST, use 'shutdown -c' to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localdomain (Thu 2022-03-24 15:31:29 CST):
The system is going down for power-off at Thu 2022-03-24 15:41:29 CST!
23.history
列出使用过的命令
[root@localhost ~]#history
24.man查看命令的使用方法和帮助信息
[root@localhost ~]#man ls
25.zip文件压缩
[root@localhost ~]# dd if=/dev/zero of=test.txt bs=100M count=8
记录了8+0 的读入
记录了8+0 的写出
838860800字节(839 MB)已复制,10.6606 秒,78.7 MB/秒
[root@localhost ~]# zip test.zip test.txt
adding: test.txt (deflated 100%)
[root@localhost ~]#
26.zip解压缩
-d 指定解压路径
[root@localhost ~]# unzip test.zip -d /tmp/
Archive: test.zip
inflating: /tmp/test.txt
27.添加用户
useradd [选项] 用户名
-c comment 用户的注释性信息
-d home_dir 指定用户的主目录
-e expir_date 禁用账号的日期,格式为YYYY-MM-DD
-f inactive_days 设置账户过期多少天后用户被禁用,如果为0,则立即禁用,如果为-1,则不被禁用
[root@localhost ~]# useradd wang