Linux常用命令之目录操作相关命令
1.pwd命令
pwd命令用于显示用户当前所处的工作目录,格式为“pwd [选项]”。
[root@centos7 ~]# pwd
/root
2.cd命令
cd命令用于切换工作路径,格式为“cd [目录名称]”。
[root@centos7 ~]# cd /etc/
[root@centos7 etc]# pwd
/etc
目录特殊符号
符号 | 含义 |
---|---|
~ | 家目录 |
. | 本级目录 |
. . | 上级目录 |
[root@centos7 etc]# cd ~ #从当前目录直接切换到家目录
[root@centos7 ~]# pwd
/root
[root@centos7 etc]# cd .. #从当前目录切换到上一级目录
[root@centos7 /]# pwd
/
3.ls命令
ls命令用于显示目录中的文件信息,格式为“ls [选项] [文件] ”。
ls常用选项
选项 | 含义 |
---|---|
-a | 显示目录下所有文件,包括隐藏文件 |
-d | 显示目录本身,常与-l一起使用查看目录属性 |
-h | 以K/M/G为单位显示文件大小 |
-l | 以列表格式列出文件的详细信息(权限/属性) |
CentOS中,ll就是ls -l的别名。
[root@centos7 data]# ls
awk_test.txt data1 date.txt test
[root@centos7 data]# ls -a
. .. awk_test.txt data1 date.txt test
[root@centos7 data]# ls -d
.
[root@centos7 data]# ls -ld
drwxr-xr-x 3 root root 67 May 9 23:05 .
[root@centos7 data]# ll
total 8
-rw-r--r-- 1 root root 268 Jan 10 12:13 awk_test.txt
drwxr-xr-x 2 root root 6 May 9 23:05 data1
-rw-r--r-- 1 root root 0 May 9 23:11 date.txt
-rw-r--r-- 1 root root 234 Dec 28 14:34 test