linux(十)目录相关命令ll、pwd、cd(1)

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: Linux的常用基本命令,大概先了解下他目录相关的命令,linux的目录其实就是windows下的文件夹,文件夹,是windows系统引入的一个概念。这个大概了解一下。

Linux的常用基本命令,大概先了解下他目录相关的命令,linux的目录其实就是windows下的文件夹,文件夹,是windows系统引入的一个概念。这个大概了解一下。

一:查看目录下的文件的命令ll/ls

1:ls命令

(1):ls -a 查看所有文件,包含隐藏文件

ruby

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -a
.  ..  .cache  libaio-0.3.109-13.el7.x86_64.rpm  libaio-devel-0.3.109-13.el7.x86_64.rpm  oci8-2.2.0.tgz  oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm  oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

注:文件名前边有.的都是隐藏文件

 

(2):ls -l 查看文件详情

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -l
total 53748
drwxr-xr-x  2 root root     4096 Aug 26 10:50 ./
drwxr-xr-x 23 root root     4096 Jul  7 16:13 ../
-rw-r--r--  1 root root        0 Aug 26 10:50 .cache
-rw-r--r--  1 root root    24744 Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r--  1 root root    13176 Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
-rw-r--r--  1 root root   196449 Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r--  1 root root 54172532 Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r--  1 root root   612416 Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(3):ls -lh 查看文件详细信息,以人类可读的形式显示文件大小,h单独使用是没有效果的,只有配合l使用的时候,才能发挥其效果。

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -lh
total 53M
-rw-r--r-- 1 root root  25K Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root  13K Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root 192K Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r-- 1 root root  52M Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root 599K Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(4):ls -A 查看除 . .. 之外的所有文件及目录的信息

ruby

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -A
.cache  libaio-0.3.109-13.el7.x86_64.rpm  libaio-devel-0.3.109-13.el7.x86_64.rpm  mysql  oci8-2.2.0.tgz  oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm  oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

查看详细信息的话,可以组合使用

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -lA
total 53744
-rw-r--r-- 1 root root        0 Aug 26 10:50 .cache
-rw-r--r-- 1 root root    24744 Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root    13176 Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
drwxr-xr-x 2 root root     4096 Aug 26 11:03 mysql
-rw-r--r-- 1 root root   196449 Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r-- 1 root root 54172532 Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root   612416 Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(5):ls -lF 查看目录的时候并输出文件类型:“*”表示具有可执行权限的普通文件,“/”表示目录,“@”表示符号链接,“|”表示命令管道FIFO,“=”表示sockets套接字。当文件为普通文件时,不输出任何标识。

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -lF
total 53744
-rw-r--r-- 1 root root    24744 Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root    13176 Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
drwxr-xr-x 2 root root     4096 Aug 26 11:03 mysql/
-rw-r--r-- 1 root root   196449 Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r-- 1 root root 54172532 Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root   612416 Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(6):ls -m 以逗号分隔字符

ruby

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -m
libaio-0.3.109-13.el7.x86_64.rpm, libaio-devel-0.3.109-13.el7.x86_64.rpm, mysql, oci8-2.2.0.tgz, oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm, oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(7):ls -I 显示文件索引节点号(inode)。一个索引节点代表一个文件;

ruby

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -i
 262184 libaio-0.3.109-13.el7.x86_64.rpm        1323947 mysql            269376 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
 269478 libaio-devel-0.3.109-13.el7.x86_64.rpm   269375 oci8-2.2.0.tgz   269476 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(8):ls -n:以用户识别码和群组识别码替代其名称;

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -ln
total 53744
-rw-r--r-- 1 0 0    24744 Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 0 0    13176 Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
drwxr-xr-x 2 0 0     4096 Aug 26 11:03 mysql
-rw-r--r-- 1 0 0   196449 Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r-- 1 0 0 54172532 Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 0 0   612416 Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(9):ls -R 递归显示当前目录下的所有文件,注意,递归显示所有,这个命令很耗资源

ruby

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -R
.:
libaio-0.3.109-13.el7.x86_64.rpm  libaio-devel-0.3.109-13.el7.x86_64.rpm  mysql  oci8-2.2.0.tgz  oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm  oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm
./mysql:
1.txt

 

(10):ls –full-time 完整的显示时间

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls --full-time
total 53744
-rw-r--r-- 1 root root    24744 2015-11-25 22:50:54.000000000 +0800 libaio-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root    13176 2015-11-25 22:50:57.000000000 +0800 libaio-devel-0.3.109-13.el7.x86_64.rpm
drwxr-xr-x 2 root root     4096 2020-08-26 11:29:54.073539019 +0800 mysql
-rw-r--r-- 1 root root   196449 2020-08-11 09:08:08.000000000 +0800 oci8-2.2.0.tgz
-rw-r--r-- 1 root root 54172532 2020-08-11 09:12:20.000000000 +0800 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root   612416 2020-08-11 09:12:01.000000000 +0800 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

 

(11):ls -lt 按时间排序显示

sql

复制代码

root@iZijvdp1z0m5q4Z:/opt# ls -lt
total 53744
drwxr-xr-x 2 root root     4096 Aug 26 11:29 mysql
-rw-r--r-- 1 root root 54172532 Aug 11 09:12 oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root   612416 Aug 11 09:12 oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm
-rw-r--r-- 1 root root   196449 Aug 11 09:08 oci8-2.2.0.tgz
-rw-r--r-- 1 root root    13176 Nov 25  2015 libaio-devel-0.3.109-13.el7.x86_64.rpm
-rw-r--r-- 1 root root    24744 Nov 25  2015 libaio-0.3.109-13.el7.x86_64.rpm

 

(12):显示彩色目录

打开/etc/bashrc, 加入如下一行:

bash

复制代码

alias ls="ls --color"

下次启动bash时就可以像在Slackware里那样显示彩色的目录列表了, 其中颜色的含义如下:

  1. 蓝色-->目录
  2. 绿色-->可执行文件
  3. 红色-->压缩文件
  4. 浅蓝色-->链接文件
  5. 灰色-->其他文件

ini

复制代码

ls -tl --time-style=full-iso sshd
ls -ctl --time-style=long-iso

 

最后注意一下,这些命令是可以组合使用的,比如 :ls -lht 就是查看文件详细信息,以人类习惯的方式显示文件大小,以及按照时间排序显示

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
3天前
|
监控 Linux Windows
50个必知的Linux命令技巧,你都掌握了吗?(下)
50个必知的Linux命令技巧,你都掌握了吗?(下)
|
3天前
|
Linux Shell Windows
Linux 常用基本命令
Linux 常用基本命令
|
4天前
|
Ubuntu Linux Shell
linux免交互登陆远程主机并执行命令(密钥对和Expect)
linux免交互登陆远程主机并执行命令(密钥对和Expect)
|
4天前
|
Linux
【Linux】常用命令
【Linux】常用命令
24 0
|
4天前
|
安全 Ubuntu Linux
Linux 网络操作命令Telnet
Linux 网络操作命令Telnet
18 0
Linux 网络操作命令Telnet
|
5天前
|
Linux 数据安全/隐私保护
Linux常用命令实例带注释
Linux常用命令实例带注释
30 0
|
5天前
|
Linux 开发工具 数据安全/隐私保护
Linux(19)常用解压命令记录
Linux(19)常用解压命令记录
9 0
|
8月前
|
安全 关系型数据库 MySQL
Linux学习笔记——Linux基本命令篇(三)
Linux学习笔记——Linux基本命令篇(三)
|
8月前
|
Linux 数据库 数据安全/隐私保护
Linux学习笔记——Linux基本命令篇(二)
Linux学习笔记——Linux基本命令篇(二)
|
8月前
|
Oracle 网络协议 Unix
Linux学习笔记——Linux基本命令篇(一)
Linux学习笔记——Linux基本命令篇(一)