【Linux】ls命令

1 在Linux环境下找不到ll命令

~/.bashrc文件中添加


# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
#定义ll命令
alias ll='ls -l'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

2 ll时间格式化

Linux默认时间格式,查看不够直观。例如

drwx------  2 nobody root    6 Jan 28  2022 client_body_temp
drwxr-xr-x  3 root   root 4096 Sep 15 14:15 conf
drwx------  2 nobody root    6 Sep 10  2019 fastcgi_temp
drwxr-xr-x 29 root   root 8192 Jun 15  2022 html
drwxr-xr-x  2 root   root    6 Nov  8 08:29 logs
drwx------  3 root   root   15 Jul 27 11:15 proxy_cache
drwx------ 12 nobody root   96 Sep 10  2019 proxy_temp
drwxr-xr-x  2 root   root   19 Sep 10  2019 sbin
drwx------  2 nobody root    6 Sep 10  2019 scgi_temp
drwxr-xr-x  3 root   root   80 Jun  9  2020 ssl
drwx------  2 nobody root    6 Sep 10  2019 uwsgi_temp

ll --time-style="+%Y-%m-%d %H:%M:%S"

total 16
drwx------  2 nobody root    6 2022-01-28 15:06:39 client_body_temp
drwxr-xr-x  3 root   root 4096 2023-09-15 14:15:01 conf
drwx------  2 nobody root    6 2019-09-10 14:22:29 fastcgi_temp
drwxr-xr-x 29 root   root 8192 2022-06-15 09:19:56 html
drwxr-xr-x  2 root   root    6 2023-11-08 08:29:41 logs
drwx------  3 root   root   15 2023-07-27 11:15:55 proxy_cache
drwx------ 12 nobody root   96 2019-09-10 14:46:43 proxy_temp
drwxr-xr-x  2 root   root   19 2019-09-10 14:07:50 sbin
drwx------  2 nobody root    6 2019-09-10 14:22:29 scgi_temp
drwxr-xr-x  3 root   root   80 2020-06-09 14:09:20 ssl
drwx------  2 nobody root    6 2019-09-10 14:22:29 uwsgi_temp

将配置添加的环境变量中

echo "export TIME_STYLE='+%Y-%m-%d %H:%M:%S'" >> ~/.bashrc

3 ls其他常用命令

#显示所有文件,包含隐藏文件
ls -a
#列出当前目录下所有文件以及目录的详细信息(包含子目录内容)
ls -lR
#按照时间倒排
ls -ltr
#列出当前目录下文件详细信息并可读大小显示文件大小
ls -lh

posted @ 2023-11-08 09:06  二月无雨  阅读(45)  评论(0编辑  收藏  举报