首页 > 系统相关 >Linux目录结构、查看目录命令

Linux目录结构、查看目录命令

时间:2023-01-05 09:12:26浏览次数:38  
标签:查看 cd sysconfig etc pwd Linux root 目录 localhost


### 一、Linux目录结构

​        设计哲学:

​                一切皆文件!!!!!

```

​        /    根目录

​                /root

​                        root用户的家目录/宿主目录

​                /home

​                        普通用户的家目录/宿主目录

​                                userA  ---------  /home/userA

​                                userB  --------  /home/userB

​                /etc        

​                        应用程序的配置文件

​                /dev

​                        存储设备文件(磁盘、分区)

​                /boot

​                        内核、启动配置文件

​                /proc

​                        动态文件, 包括记录CPU、内存、网卡、进程等的使用情况的文件

​                /lib64

​                        库文件, 保证某应用程序可正常运行的

​                /opt

​                        用户的工作目录,保存下载工具、软件、文档

​                /tmp

​                        临时目录
```





### 二、命令提示符

​        调大字体   ctrl + shift +

​        调小字体   ctrl  -  



```
[root@localhost ~] #

​        root:  当前登录系统的用户名

​        localhost: 默认的主机名

​        ~:   当前目录, ~ 当前用户的家目录  

​        #:  管理员     $:  普通用户
```





## 三、文件目录基本管理指令

### 1、切换、查看目录  

格式:

```
# cd [目录名称]
```

```
[root@localhost ~]# cd /etc/sysconfig/
[root@localhost sysconfig]# pwd    //查看当前工作目录
/etc/sysconfig


[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /etc/
[root@localhost etc]# pwd
/etc
[root@localhost etc]# cd
[root@localhost ~]#
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /
[root@localhost /]# cd etc/
[root@localhost etc]# pwd
/etc



[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /etc/sysconfig/
[root@localhost sysconfig]# pwd
/etc/sysconfig
[root@localhost sysconfig]# cd
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /etc/
[root@localhost etc]# cd sysconfig/
[root@localhost sysconfig]# pwd
/etc/sysconfig



[root@localhost sysconfig]# pwd
/etc/sysconfig
[root@localhost sysconfig]# cd
[root@localhost ~]#
[root@localhost ~]# pwd
/root



[root@localhost ~]# cd /etc/sysconfig/
[root@localhost sysconfig]# pwd
/etc/sysconfig
[root@localhost sysconfig]# cd ..
[root@localhost etc]# pwd
/etc
[root@localhost etc]# cd ..
[root@localhost /]# pwd
/
[root@localhost /]# cd ..
```



### 2、查看目录下的文件

```
# ls [选项] [目录名称]
```

```
[root@localhost /]# pwd
/
[root@localhost /]# ls

[root@localhost /]# cd /tmp/
[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# ls

[root@localhost tmp]# ls /tmp/

[root@localhost tmp]# ls /root/
```



常用选项:

```
1) -a     查看目录下的所有文件

[root@localhost ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .config  .dbus    Documents  .esd_auth      initial-setup-ks.cfg  Music     Public   .tcshrc    Videos    .Xauthority
..  .bash_history    .bash_profile  .cache   .cshrc   Desktop  Downloads  .ICEauthority  .local                Pictures  .redhat  Templates  .viminfo



2) -lh    显示文件的详细信息

[root@localhost ~]# ls -l
total 8
-rw-------. 1 root root 2193 Dec 15 00:42 anaconda-ks.cfg

​    第一个字符:  文件类型

​            普通文件 -

​            目录    d

​            软链接文件        l

​            块设备文件        b        磁盘、分区

​            字符设备文件    c        键盘、显示器、打印机

​    2193        文件大小,单位Bytes字节

​    Dec 15 00:42        最后一次修改时间

[root@localhost ~]# ls -l /etc/fstab
-rw-r--r--. 1 root root 465 Dec 14 22:08 /etc/fstab
[root@localhost ~]#
[root@localhost ~]# ls -l /etc/passwd
-rw-r--r--. 1 root root 2209 Dec 14 23:15 /etc/passwd



3) -d 查看目录的详细信息

[root@localhost ~]# ls -ldh /etc/
drwxr-xr-x. 142 root root 8.0K Dec 14 23:15 /etc/



4) -S   按文件大小排序显示

[root@localhost ~]# ls -lhS /tmp/



5) -t   按文件修改时间排序

[root@localhost ~]# ls -lht /tmp/
```

标签:查看,cd,sysconfig,etc,pwd,Linux,root,目录,localhost
From: https://www.cnblogs.com/nhxuan/p/17026535.html

相关文章