本文共 2736 字,大约阅读时间需要 9 分钟。
ls命令是linux下最常见的命令。ls命令是list的缩写,可以使用ls查询当前目录下的文档(包括目录、文件夹、文件权限),相当于windows下的dir命令;
1.命令格式:ls [选项] [目录名]2.常用参数[root@shu001 ~]# ls -l总用量 4-rw-------. 1 root root 1418 11月 9 03:33 anaconda-ks.cfg
-la #查询详细信息,包括隐藏文件(以.开头的文件名为隐藏文件)
[root@shu001 ~]# ls -la总用量 28dr-xr-x---. 4 root root 159 11月 30 20:25 .dr-xr-xr-x. 17 root root 224 11月 9 03:32 ..-rw-------. 1 root root 1418 11月 9 03:33 anaconda-ks.cfg-rw-------. 1 root root 1718 12月 14 01:21 .bash_history-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc-rw-r--r--. 1 root root 100 12月 29 2013 .cshrcdrwxr-----. 3 root root 19 11月 30 20:25 .pkidrwx------. 2 root root 80 11月 9 22:14 .ssh-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@shu001 ~]# ls -i33582978 anaconda-ks.cfg
当我们使用ls -l 查询文件详细信息时,最左侧的一列,第一个字符表示文件的类型;
另外,我们用ls -al 可以查看当前目录下的所有文件,这是我们可以看到"."和".."这两个文件其实"."就是代表当前目录".."就是代表上级目录
alias命令就是别名命令,我们还可以使用alias来自定义命令;
查询系统中有哪些alias,通过查询我们可以看到我们车间的mv命令、cp命令都是通过alias命令来定义的;[root@shu001 ~]# aliasalias cp='cp -i'alias egrep='egrep --color=auto'alias fgrep='fgrep --color=auto'alias grep='grep --color=auto'alias l.='ls -d .* --color=auto'alias ll='ls -l --color=auto'alias ls='ls --color=auto'alias mv='mv -i'alias rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
定义一个新的命令;
alias [新命令]='[原始命令格式]'[root@shu001 ~]# alias shu32='ls -lha'[root@shu001 ~]# shu32总用量 28Kdr-xr-x---. 4 root root 159 11月 30 20:25 .dr-xr-xr-x. 17 root root 224 11月 9 03:32 ..-rw-------. 1 root root 1.4K 11月 9 03:33 anaconda-ks.cfg-rw-------. 1 root root 1.7K 12月 14 01:21 .bash_history-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc-rw-r--r--. 1 root root 100 12月 29 2013 .cshrcdrwxr-----. 3 root root 19 11月 30 20:25 .pkidrwx------. 2 root root 80 11月 9 22:14 .ssh-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc#新建一个命令shu32,相当于使用ls -lha命令;
取消别名命令
unalias [新命令]unalias shu32
转载于:https://blog.51cto.com/shuzonglu/2051009