1.pwd
查看当前所在的位置 print working directory
| 查看当前root用户默认所在的位置 |
| [root@centos ~]# pwd 输入命令 |
| /root 显示绝对路径 |
| [root@centos ~]# |
2.ls
| ls |
| |
| 语法格式: |
| ls 直接回车 |
| ls 目录 |
| 参数选项: ls -l 显示文件的详细信息 |
| ls -l 有个外号: ll 当我们执行ll时实际系统为我们执行的是ls -l |
| |
| 注意: 以颜色区分 白色的为普通文件 类似windows的.txt文件 |
| 蓝色为目录 |
| |
| ls 直接回车 查看当前 |
| |
| [root@centos ~] |
| anaconda-ks.cfg |
| [root@centos ~] |
| |
| |
| ls 指定查看/目录下所有文件 |
| [root@centos ~] |
| bin dev home lib64 mnt proc run srv tmp var |
| boot etc lib media opt root sbin sys usr |
| [root@centos ~] |
3.cd
| 切换路径 change directory |
| 语法结构: |
| cd 目录 |
| cd /目录/目录/目录 |
案例
| 进入到/opt目录 绝对路径 |
| |
| [root@centos ~] |
| [root@centos opt] |
| [root@centos /] |
| / |
| [root@centos /] |
| [root@centos /] |
| [root@centos /] |
| |
| [root@centos /] |
| -bash: cd: /o: No such file or directory |
| [root@centos opt] |
| 进入到深层目录/etc/sysconfig/ |
| [root@centos ~]# cd /etc/sysconfig/ |
| [root@centos sysconfig]# pwd |
| /etc/sysconfig |
| [root@centos sysconfig]# |
| 然后快速回到家目录 |
| 方法1: cd直接回车 |
| [root@centos sysconfig]# cd |
| [root@centos ~]# |
| 方法2: 使用绝对路径回家 |
| [root@centos sysconfig]# pwd |
| /etc/sysconfig |
| [root@centos sysconfig]# cd /root |
| [root@centos ~]# pwd |
| /root |
| 方法3: 使用~回家 |
| [root@centos sysconfig]# cd ~ |
| [root@centos ~]# |
4.mkdir
| 创建目录 make directory语法结构: |
| mkdir zzz |
| mkdir -p zzz/test/www |
案例
| 在当前目录创建一个test目录 |
| |
| [root@centos ~] |
| [root@centos ~] |
| total 8 |
| -rw-------. 1 root root 1522 Feb 22 16:41 anaconda-ks.cfg |
| -rw-r--r--. 1 root root 158 Feb 24 10:55 hosts |
| drwxr-xr-x. 2 root root 6 Feb 24 11:18 test |
| |
| [root@centos ~] |
| mkdir: cannot create directory ‘test’: File exists |
| |
| mkdir 无法创建目录test 文件已存在 |
5.touch
| 创建普通文件 摸 类似windows创建的txt文档 |
| 如果不存在则创建 |
| 如果文件存在则更新文件的时间,不影响文件内容 |
| 语法结构: |
| touch 文件 |
| touch 文件1 文件2 文件3 |
| touch /opt/test.txt |
案例
| 在当前创建一个test.txt |
| [root@centos ~]# touch test.txt |
| [root@centos ~]# |
| [root@centos ~]# ll |
| total 0 |
| -rw-r--r--. 1 root root 0 Feb 24 12:00 test.txt |
6.tree
| tree命令: |
| |
| [root@centos ~] |
| /opt/ |
| ├── bbs |
| │ ├── 1.txt |
| │ └── 2.txt |
| ├── blog |
| │ ├── 1.txt |
| │ └── 2.txt |
| └── www |
| ├── 1.txt |
| └── 2.txt |
| |
| 3 directories, 6 files |
| |
| |
| [root@centos ~] |
| /opt/ |
| ├── bbs |
| ├── blog |
| └── www |
7.帮助手册man help
| |
| |
| man 空格 命令 |
| 空格: 一次翻一页 |
| f : 一次往下翻一页 |
| b : 一次网上翻一页 |
| ↓ : 一次一行 |
| ↑ : 一次一行 |
| q : 退出帮助 quit |
| |
| |
| |
| help cd |
8.shutdown
| [root@centos ~]# shutdown # 关机 |
| [root@centos ~]# poweroff # 立刻关机 |
| [root@centos ~]# halt # 立刻关机 |
| [root@centos ~]# init 0 # 立刻关机 |
| [root@centos ~]# reboot # 重启操作系统 |
| |
| |
| |
| [root@centos ~]# shutdown -c # 取消关机 |
| [root@centos ~]# shutdown -h 5 # 5分钟后关机 |
| [root@centos ~]# shutdown -h now # 立刻关机 |
9.重启
| reboot |
| |
| init 6 |
| |
| shutdown -r |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)