linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录、文件夹、文件权限),查看目录信息等等

[[email protected]_168_102_centos /]# ls
bin   data  etc   lib    lost+found  mnt  proc  sbin     srv  tmp  var
boot  dev   home  lib64  media       opt  root  selinux  sys  usr

ls –a:显示所有文件,包含.开头的隐藏文件

[[email protected]_168_102_centos /]# ls -a
.             .readahead_collect  dev   lib64       opt   selinux  usr
..            bin                 etc   lost+found  proc  srv      var
.autofsck     boot                home  media       root  sys
.autorelabel  data                lib   mnt         sbin  tmp

ls –l:列出文件的详细信息

[[email protected]_168_102_centos tmp]# ls -l
total 24
drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
srwxrwxrwx 1 root    root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root    root  105 Aug  2 11:36 ap_1002.pid
-rw------- 1 root    root    0 Aug  2 09:48 ap_1004.pid
-rw------- 1 root    root  103 Aug  2 11:36 ap_1005.pid
-rw------- 1 root    root    0 Aug  2 10:51 ap_1007.pid
-rw------- 1 root    root    0 Aug  2 10:09 ap_1008.pid
-rw------- 1 root    root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi

d //文件类型  rwxr-xr-x //文件权限 3 //硬链接数 wanghan //属主 root //属组 4096 Aug  4 20:41 //最近一次修改时间 wanghan //文件名

ls –d:显示目录自身的信息,结合-l使用直接查看目录自身详细信息

[[email protected]_168_102_centos etc]# ls -d
.
[[email protected]_168_102_centos etc]# ls -ld
drwxr-xr-x 75 root root 4096 Aug  9 03:28 .
[[email protected]_168_102_centos etc]#

ls -r:逆序显示

drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
srwxrwxrwx 1 root    root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root    root  105 Aug  2 11:36 ap_1002.pid
-rw------- 1 root    root    0 Aug  2 09:48 ap_1004.pid
-rw------- 1 root    root  103 Aug  2 11:36 ap_1005.pid
-rw------- 1 root    root    0 Aug  2 10:51 ap_1007.pid
-rw------- 1 root    root    0 Aug  2 10:09 ap_1008.pid
-rw------- 1 root    root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:41 wanghan
[[email protected]_168_102_centos tmp]# ls -rl
total 24
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:41 wanghan
drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi
-rw------- 1 root    root    0 Aug  4 13:58 ap_1014.pid
-rw------- 1 root    root    0 Aug  2 10:09 ap_1008.pid
-rw------- 1 root    root    0 Aug  2 10:51 ap_1007.pid
-rw------- 1 root    root  103 Aug  2 11:36 ap_1005.pid
-rw------- 1 root    root    0 Aug  2 09:48 ap_1004.pid
-rw------- 1 root    root  105 Aug  2 11:36 ap_1002.pid
srwxrwxrwx 1 root    root    0 Aug  9 10:05 agent_cmd.sock
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
[[email protected]_168_102_centos tmp]#

ls -R:同时显示其下子目录文件

[[email protected]_168_102_centos tmp]# cd a
[[email protected]_168_102_centos a]# ls
b
[[email protected]_168_102_centos a]# ls -R
.:
b

./b:
c

./b/c:
d

./b/c/d:
e

./b/c/d/e:
f

./b/c/d/e/f:
abcd

./b/c/d/e/f/abcd:
[[email protected]_168_102_centos a]#

ls -h:以容易理解的方式显示文件大小

[[email protected]_168_102_centos tmp]# ls -l
total 24
drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:41 wanghan
[[email protected]_168_102_centos tmp]# ls -lh
total 24K
drwxr-xr-x 2 wanghan root 4.0K Aug  4 21:21 2014-08-04-212053
drwxr-xr-x 3 wanghan root 4.0K Aug  4 20:45 a
drwxr-xr-x 2 wanghan root 4.0K Aug  4 20:44 ceshi
drwxr-xr-x 3 wanghan root 4.0K Aug  4 20:41 wanghan

ls -i:显示出文件inode号

[[email protected]_168_102_centos tmp]# ls -li
total 24
458762 drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
458767 drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
458758 srwxrwxrwx 1 root    root    0 Aug  9 10:05 agent_cmd.sock
458755 -rw------- 1 root    root  105 Aug  2 11:36 ap_1002.pid
458756 -rw------- 1 root    root    0 Aug  2 09:48 ap_1004.pid
458759 -rw------- 1 root    root  103 Aug  2 11:36 ap_1005.pid
458760 -rw------- 1 root    root    0 Aug  2 10:51 ap_1007.pid
458757 -rw------- 1 root    root    0 Aug  2 10:09 ap_1008.pid
458761 -rw------- 1 root    root    0 Aug  4 13:58 ap_1014.pid
458766 drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi
458764 drwxr-xr-x 3 wanghan root 4096 Aug  4 20:41 wanghan
// 458764 inode号

#tree命令:显示磁盘目录结构

[[email protected]_168_102_centos tmp]# tree
.
|-- 2014-08-04-212053
|-- a
|   `-- b
|       `-- c
|           `-- d
|               `-- e
|                   `-- f
|                       `-- abcd
|-- agent_cmd.sock
|-- ap_1002.pid
|-- ap_1004.pid
|-- ap_1005.pid
|-- ap_1007.pid
|-- ap_1008.pid
|-- ap_1014.pid
|-- ceshi
`-- wanghan
    `-- test

11 directories, 7 files
[[email protected]_168_102_centos tmp]#

tree –L #:显示当前目录下指定最大深度的目录结构

[[email protected]_168_102_centos tmp]# tree -L 1
.
|-- 2014-08-04-212053
|-- a
|-- agent_cmd.sock
|-- ap_1002.pid
|-- ap_1004.pid
|-- ap_1005.pid
|-- ap_1007.pid
|-- ap_1008.pid
|-- ap_1014.pid
|-- ceshi
`-- wanghan

4 directories, 7 files
[[email protected]_168_102_centos tmp]# tree -L 2
.
|-- 2014-08-04-212053
|-- a
|   `-- b
|-- agent_cmd.sock
|-- ap_1002.pid
|-- ap_1004.pid
|-- ap_1005.pid
|-- ap_1007.pid
|-- ap_1008.pid
|-- ap_1014.pid
|-- ceshi
`-- wanghan
    `-- test

6 directories, 7 files
[[email protected]_168_102_centos tmp]#

#alias命令:设置指令别名

单独使用alias直接显示当前shell中定义的所哟别名

[[email protected]_168_102_centos tmp]# alias
alias cp=‘cp -i‘
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‘
[[email protected]_168_102_centos tmp]#

定义指令别名:

alias 别名=‘原始指令’

[[email protected]_168_102_centos tmp]# alias test=ls
[[email protected]_168_102_centos tmp]# test
2014-08-04-212053  a  agent_cmd.sock  ap_1002.pid  ap_1004.pid  ap_1005.pid  ap_1007.pid  ap_1008.pid  ap_1014.pid  ceshi  wanghan
[[email protected]_168_102_centos tmp]# alias test=‘ls -l‘
[[email protected]_168_102_centos tmp]# test
total 24
drwxr-xr-x 2 wanghan root 4096 Aug  4 21:21 2014-08-04-212053
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:45 a
srwxrwxrwx 1 root    root    0 Aug  9 10:05 agent_cmd.sock
-rw------- 1 root    root  105 Aug  2 11:36 ap_1002.pid
-rw------- 1 root    root    0 Aug  2 09:48 ap_1004.pid
-rw------- 1 root    root  103 Aug  2 11:36 ap_1005.pid
-rw------- 1 root    root    0 Aug  2 10:51 ap_1007.pid
-rw------- 1 root    root    0 Aug  2 10:09 ap_1008.pid
-rw------- 1 root    root    0 Aug  4 13:58 ap_1014.pid
drwxr-xr-x 2 wanghan root 4096 Aug  4 20:44 ceshi
drwxr-xr-x 3 wanghan root 4096 Aug  4 20:41 wanghan
[[email protected]_168_102_centos tmp]#

取消指令别名:

[[email protected]_168_102_centos tmp]# unalias test
[[email protected]_168_102_centos tmp]# tes

linux学习命令总结④

时间: 2024-11-10 01:31:24

linux学习命令总结④的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组.在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置.普通用户不能将自己的文件改变成其他的属主.其操作权限一般为管理员. 修改文件属主和属组: [[email protected]_168_102_centos ~]# ls -l total 8 drwxr-xr-x 2 wanghan hx 4096 Aug 12 10:32 abe drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab [

linux学习命令总结⑨

#重定向 输出重定向: 1>覆盖输出(1可省略) [[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# ca

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑩②

#fdisk命令:磁盘分区工具 fdisk –l:查看机器所挂硬盘个数及分区情况 [[email protected]_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

linux学习命令总结⑥

#文件名通配 通配符: *:匹配任意长度的任意字符(0到多个) [[email protected]_168_102_centos ~]# ls * 0812080808 2014-05-16: test.log ceshi_1: test: [[email protected]_168_102_centos ~]# ls -ld t* drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test ?:匹配任意单个字符 [[email protected]_1

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8