系列文章目录
如果本文对你们的开发之路有所帮助,请帮忙点个赞,您的支持是我坚持写博客的动力
前言
上一文教会了大家CentOS 安装,本文将手把手教大家熟悉CentOS 常用指令
文件 目录操作命令
cd 路径命令
命令 | 含义 |
---|---|
cd /home | 移动目录 |
cd ~ | 移动到家目录 |
cd … | 返回上一层目录 |
cd / | 返回根目录 |
init 5 | 图形化 |
init 6 | 重启 |
cd /home 移动目录
[root@localhost janyxe]# cd /home/
[root@localhost home]#
cd ~ 移动到家目录
root用户,cd ~ 相当于 cd /root
普通用户,cd ~ 相当于cd /home/当前用户名
root 用户
[root@localhost home]# cd ~
[root@localhost ~]# pwd
/root
普通用户
[root@localhost ~]# su janyxe
[janyxe@localhost root]$ cd ~
[janyxe@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[janyxe@localhost ~]$ pwd
/home/janyxe
cd … 返回上一层目录
[janyxe@localhost ~]$ pwd
/home/janyxe
[janyxe@localhost ~]$ cd ..
[janyxe@localhost home]$ pwd
/home
cd 返回根目录
[janyxe@localhost home]$ cd /
[janyxe@localhost /]$ pwd
/
[janyxe@localhost /]$
ls 显示清单命令
命令 | 含义 |
---|---|
ls /dir | 显示文件夹下全部文件 |
ls -a | 显示文件的详情信息,包括显示隐藏文件 |
ls -l | 显示当前目录及所有子目录信息 |
ls /dir 显示文件夹下全部文件
[janyxe@localhost /]$ ls /home/
janyxe
支持可多路径查看
[janyxe@localhost /]$ pwd
/
[janyxe@localhost /]$ ls / /home/
/:
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
/home/:
janyxe
ls -a 显示文件的详情信息,包括显示隐藏文件
[janyxe@localhost ~]$ ls -a
. .bash_profile .dbus .esd_auth Music Videos
.. .bashrc Desktop .ICEauthority Pictures .viminfo
.bash_history .cache Documents .local Public .Xauthority
.bash_logout .config Downloads .mozilla Templates
ls -l 显示当前目录及所有子目录信息
[janyxe@localhost ~]$ ls -l
total 0
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Desktop
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Documents
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Downloads
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Music
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Pictures
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Public
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Templates
drwxr-xr-x. 2 janyxe janyxe 6 Apr 27 02:00 Videos
vi 编辑文件命令
命令 | 含义 |
---|---|
vi fileName | 新建,编辑文件命令 |
vi fileName 新建,编辑文件命令
[janyxe@localhost ~]$ vi new.sh
vi 的两种工作模式:命令模式,编辑模式
进入vi后伟命令模式,按键盘i
或INS
按键进入编辑模式
按ESC
切回命令模式
命令模式不能编辑文件,只能输入命令
-
命令模式
-
编辑模式
vi 命令模式命令
命令 | 含义 |
---|---|
:w | 保存当前文档 |
:q | 直接退出 |
:wq | 先保存后退出 |
:wq | 强制先保存后退出 |
mv 移动命令
命令 | 含义 |
---|---|
mv file /dir | 移动文件 |
mv file file1 | 修改文件名 |
mv /dir /dir2 | 修改文件夹名称 |
mv file /dir 移动文件
[janyxe@localhost ~]$ mv new.sh new
mv file file1 修改文件名
[janyxe@localhost ~]$ cd new/
[janyxe@localhost new]$ ls
new.sh
[janyxe@localhost new]$ mv new.sh new1.sh
[janyxe@localhost new]$ ls
new1.sh
mv /dir /dir2 修改文件夹名称
[janyxe@localhost ~]$ ls
Desktop Documents Downloads Music new Pictures Public Templates Videos
[janyxe@localhost ~]$ mv new new1
[janyxe@localhost ~]$ ls
Desktop Documents Downloads Music new1 Pictures Public Templates Videos
总结
本文主要介绍了一些常见的CentOS 文件常用命令
如果本文对你们的开发之路有所帮助,请帮忙点个赞,您的支持是我坚持写博客的动力。