一周第五次课(12月15日)

一周第五次课(12月15日)
2.1/2.2 系统目录结构
2.3 ls命令
2.4 文件类型
2.5 alias命令

系统目录结构:

[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# ls /
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost ~]# ls /root//.ssh/authorized_keys
/root//.ssh/authorized_keys
[root@localhost ~]# useradd adkee
[root@localhost ~]# ls /home/adkee
[root@localhost ~]# yum install -y tree
已加载插件:fastestmirror
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): base/7/x86_64/group_gz | 156 kB 00:00
(2/4): extras/7/x86_64/primary_db | 145 kB 00:00
(3/4): updates/7/x86_64/primary_db | 4.5 MB 00:00
(4/4): base/7/x86_64/primary_db | 5.7 MB 00:03
Determining fastest mirrors
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=====================================================================
Package 架构 版本 源 大小
=====================================================================
正在安装:
tree x86_64 1.6.0-10.el7 base 46 k

事务概要
=====================================================================
安装 1 软件包

总下载量:46 k
安装大小:87 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
tree-1.6.0-10.el7.x86_64.rpm 的公钥尚未安装
tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-3.1611.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : tree-1.6.0-10.el7.x86_64 1/1
验证中 : tree-1.6.0-10.el7.x86_64 1/1

已安装:
tree.x86_64 0:1.6.0-10.el7

完毕!
[root@localhost ~]#

[root@localhost ~]# tree / -L 2
/
├── bin -> usr/bin
├── boot
│   ├── config-3.10.0-514.el7.x86_64
│   ├── grub
│   ├── grub2
│   ├── initramfs-0-rescue-e5521977f6cf481884c79eae3eb99766.img
│   ├── initramfs-3.10.0-514.el7.x86_64.img
│   ├── initramfs-3.10.0-514.el7.x86_64kdump.img
│   ├── initrd-plymouth.img
│   ├── symvers-3.10.0-514.el7.x86_64.gz
│   ├── System.map-3.10.0-514.el7.x86_64
│   ├── vmlinuz-0-rescue-e5521977f6cf481884c79eae3eb99766
│   └── vmlinuz-3.10.0-514.el7.x86_64
├── dev
│   ├── agpgart
│   ├── autofs
│   ├── block
│   ├── bsg
│   ├── btrfs-control
│   ├── bus
│   ├── cdrom -> sr0
│   ├── char
│   ├── console
│   ├── core -> /proc/kcore
│   ├── cpu
│   ├── cpu_dma_latency
│   ├── crash
│   ├── disk
│   ├── dmmidi
│   ├── dri
│   ├── fb0
│   ├── fd -> /proc/self/fd
│   ├── full
│   ├── fuse
│   ├── hidraw0
│   ├── hpet
│   ├── hugepages
│   ├── initctl -> /run/systemd/initctl/fifo
│   ├── input
│   ├── kmsg
│   ├── log
│   ├── loop-control
│   ├── mapper
│   ├── mcelog
│   ├── mem
│   ├── midi
│   ├── mqueue
│   ├── net
│   ├── network_latency
│   ├── network_throughput
│   ├── null
│   ├── nvram
│   ├── oldmem
│   ├── port
│   ├── ppp
│   ├── ptmx
│   ├── pts
│   ├── random
│   ├── raw
│   ├── rtc -> rtc0
│   ├── rtc0
│   ├── sda
│   ├── sda1
│   ├── sda2
│   ├── sda3
│   ├── sg0
│   ├── sg1
│   ├── shm
│   ├── snapshot
│   ├── snd
│   ├── sr0
│   ├── stderr -> /proc/self/fd/2
│   ├── stdin -> /proc/self/fd/0
│   ├── stdout -> /proc/self/fd/1
│   ├── tty
│   ├── tty0
│   ├── tty1
│   ├── tty10
│   ├── tty11
│   ├── tty12
│   ├── tty13
│   ├── tty7
│   ├── tty8
│   ├── tty9
│   ├── ttyS0
│   ├── ttyS1
│   ├── ttyS2
│   ├── ttyS3
│   ├── uhid
│   ├── uinput
│   ├── urandom
│   ├── usbmon0
│   ├── usbmon1
│   ├── usbmon2
│   ├── vcs
│   ├── vcs1
│   ├── vcs2
│   ├── vcs3
│   ├── vcs4
│   ├── vcs5
│   ├── vcs6
│   ├── vcsa
│   ├── vcsa1
│   ├── vcsa2
│   ├── vcsa3
│   ├── vcsa4
│   ├── vcsa5
│   ├── vcsa6
│   ├── vfio
│   ├── vga_arbiter
│   ├── vhci
│   ├── vhost-net
│   ├── vmci
│   ├── vsock
│   └── zero
├── etc
│   ├── adjtime
│   ├── aliases
│   ├── aliases.db
│   ├── alternatives
│   ├── anacrontab
│   ├── asound.conf
│   ├── audisp
│   ├── audit
│   ├── bash_completion.d
│   ├── bashrc
│   ├── binfmt.d
│   ├── centos-release
│   ├── centos-release-upstream
│   ├── chkconfig.d
│   ├── chrony.conf
│   ├── chrony.keys
│   ├── cron.d
│   ├── cron.daily
│   ├── cron.deny
│   ├── cron.hourly
│   ├── cron.monthly
│   ├── crontab
│   ├── cron.weekly
│   ├── crypttab
│   ├── csh.cshrc
│   ├── csh.login
│   ├── dbus-1
│   ├── default
│   ├── depmod.d
│   ├── dhcp
│   ├── DIR_COLORS
│   ├── DIR_COLORS.256color
│   ├── DIR_COLORS.lightbgcolor
│   ├── dnsmasq.conf
│   ├── dnsmasq.d
│   ├── dracut.conf
│   ├── dracut.conf.d
│   ├── e2fsck.conf
│   ├── environment
│   ├── ethertypes
│   ├── exports
│   ├── favicon.png -> /usr/share/icons/hicolor/16x16/apps/fedora-logo-icon.png
│   ├── filesystems
│   ├── firewalld
│   ├── fonts
│   ├── fstab
│   ├── fuse.conf
│   ├── gcrypt
│   ├── GeoIP.conf
│   ├── GeoIP.conf.default
│   ├── gnupg
│   ├── GREP_COLORS
│   ├── groff
│   ├── group
│   ├── group-
│   ├── grub2.cfg -> ../boot/grub2/grub.cfg
│   ├── grub.d
│   ├── gshadow
│   ├── gshadow-
│   ├── gss
│   ├── host.conf
│   ├── hostname
│   ├── hosts
│   ├── hosts.allow
│   ├── hosts.deny
│   ├── init.d -> rc.d/init.d
│   ├── inittab
│   ├── inputrc
│   ├── iproute2
│   ├── issue
│   ├── issue.net
│   ├── kdump.conf
│   ├── kernel
│   ├── krb5.conf
│   ├── krb5.conf.d
│   ├── ld.so.cache
│   ├── ld.so.conf
│   ├── ld.so.conf.d
│   ├── libaudit.conf
│   ├── libnl
│   ├── libuser.conf
│   ├── locale.conf
│   ├── localtime -> ../usr/share/zoneinfo/Asia/Shanghai
│   ├── login.defs
│   ├── logrotate.conf
│   ├── logrotate.d
│   ├── machine-id
│   ├── magic
│   ├── makedumpfile.conf.sample
│   ├── man_db.conf
│   ├── mke2fs.conf
│   ├── modprobe.d
│   ├── modules-load.d
│   ├── motd
│   ├── mtab -> /proc/self/mounts
│   ├── my.cnf
│   ├── my.cnf.d
│   ├── NetworkManager
│   ├── networks
│   ├── nsswitch.conf
│   ├── nsswitch.conf.bak
│   ├── openldap
│   ├── opt
│   ├── os-release
│   ├── pam.d
│   ├── passwd
│   ├── passwd-
│   ├── pkcs11
│   ├── pki
│   ├── plymouth
│   ├── pm
│   ├── polkit-1
│   ├── popt.d
│   ├── postfix
│   ├── ppp
│   ├── prelink.conf.d
│   ├── printcap
│   ├── profile
│   ├── profile.d
│   ├── protocols
│   ├── python
│   ├── rc0.d -> rc.d/rc0.d
│   ├── rc1.d -> rc.d/rc1.d
│   ├── rc2.d -> rc.d/rc2.d
│   ├── rc3.d -> rc.d/rc3.d
│   ├── rc4.d -> rc.d/rc4.d
│   ├── rc5.d -> rc.d/rc5.d
│   ├── rc6.d -> rc.d/rc6.d
│   ├── rc.d
│   ├── rc.local -> rc.d/rc.local
│   ├── rdma
│   ├── redhat-release -> centos-release
│   ├── resolv.conf
│   ├── resolv.conf.save
│   ├── rpc
│   ├── rpm
│   ├── rsyslog.conf
│   ├── rsyslog.d
│   ├── rwtab
│   ├── rwtab.d
│   ├── sasl2
│   ├── securetty
│   ├── security
│   ├── selinux
│   ├── services
│   ├── sestatus.conf
│   ├── shadow
│   ├── shadow-
│   ├── shells
│   ├── skel
│   ├── ssh
│   ├── ssl
│   ├── statetab
│   ├── statetab.d
│   ├── subgid
│   ├── subuid
│   ├── sudo.conf
│   ├── sudoers
│   ├── sudoers.d
│   ├── sudo-ldap.conf
│   ├── sysconfig
│   ├── sysctl.conf
│   ├── sysctl.d
│   ├── systemd
│   ├── system-release -> centos-release
│   ├── system-release-cpe
│   ├── tcsd.conf
│   ├── terminfo
│   ├── tmpfiles.d
│   ├── tuned
│   ├── udev
│   ├── vconsole.conf
│   ├── virc
│   ├── vmware-tools
│   ├── wpa_supplicant
│   ├── X11
│   ├── xdg
│   ├── xinetd.d
│   ├── yum
│   ├── yum.conf
│   └── yum.repos.d
├── home
│   └── adkee
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── media
├── mnt
├── opt
├── proc
│   ├── acpi
│   ├── asound
│   ├── buddyinfo
│   ├── bus
│   ├── cgroups
│   ├── cmdline
│   ├── consoles
│   ├── cpuinfo
│   ├── crypto
│   ├── devices
│   ├── diskstats
│   ├── dma
│   ├── driver
│   ├── execdomains
│   ├── fb
│   ├── filesystems
│   ├── fs
│   ├── interrupts
│   ├── iomem
│   ├── ioports
│   ├── irq
│   ├── kallsyms
│   ├── kcore
│   ├── keys
│   ├── key-users
│   ├── kmsg
│   ├── kpagecount
│   ├── kpageflags
│   ├── loadavg
│   ├── locks
│   ├── mdstat
│   ├── meminfo
│   ├── misc
│   ├── modules
│   ├── mounts -> self/mounts
│   ├── mpt
│   ├── mtrr
│   ├── net -> self/net
│   ├── pagetypeinfo
│   ├── partitions
│   ├── sched_debug
│   ├── schedstat
│   ├── scsi
│   ├── self -> 2404
│   ├── slabinfo
│   ├── softirqs
│   ├── stat
│   ├── swaps
│   ├── sys
│   ├── sysrq-trigger
│   ├── sysvipc
│   ├── timer_list
│   ├── timer_stats
│   ├── tty
│   ├── uptime
│   ├── version
│   ├── vmallocinfo
│   ├── vmstat
│   └── zoneinfo
├── root
│   └── anaconda-ks.cfg
├── run
│   ├── auditd.pid
│   ├── chronyd.pid
│   ├── console
│   ├── crond.pid
│   ├── cron.reboot
│   ├── dbus
│   ├── dhclient-ens33.pid
│   ├── faillock
│   ├── firewalld
│   ├── initramfs
│   ├── lock
│   ├── log
│   ├── mount
│   ├── netreport
│   ├── NetworkManager
│   ├── plymouth
│   ├── ppp
│   ├── sepermit
│   ├── setrans
│   ├── sshd.pid
│   ├── syslogd.pid
│   ├── systemd
│   ├── tmpfiles.d
│   ├── tuned
│   ├── udev
│   ├── user
│   ├── utmp
│   └── xtables.lock
├── sbin -> usr/sbin
├── srv
├── sys
│   ├── block
│   ├── bus
│   ├── class
│   ├── dev
│   ├── devices
│   ├── firmware
│   ├── fs
│   ├── hypervisor
│   ├── kernel
│   ├── module
│   └── power
├── tmp
│   └── systemd-private-a132f84ffdba4b81bf750a6cee0f61d3-vmtoolsd.service-hMfPh4
├── usr
│   ├── bin
│   ├── etc
│   ├── games
│   ├── include
│   ├── lib
│   ├── lib64
│   ├── libexec
│   ├── local
│   ├── sbin
│   ├── share
│   ├── src
│   └── tmp -> ../var/tmp
└── var
├── adm
├── cache
├── crash
├── db
├── empty
├── games
├── gopher
├── kerberos
├── lib
├── local
├── lock -> ../run/lock
├── log
├── mail -> spool/mail
├── nis
├── opt
├── preserve
├── run -> ../run
├── spool
├── tmp
└── yp

307 directories, 301 files
[root@localhost ~]# 

命令:
#ls 列取文件目录
#ls /root/   root 用户家目录
#useradd adkee   创建普通用户:adkee
#ls /usr/bin/  /usr.sdin/  /bin/  /sdin/这几都是命令目录

#ls /boot/ 系统启动文件目录

#ls /dev/ 系统特有的硬件设备文件目录
#ls /etc/ 系统配置文件目录
#ls /home/用户家目录
#ls /lib  /lib64  系统库文件

#ldd 查看依赖关系
# yum install -y tree 安装 tree 命令
#man tree    man 提示命令用法
# tree / -L 2 查看文件上下关系(竖型)

 

目录:
命令保存目录
#ls /usr/bin/
#ls /usr/sbin/
#ls /bin/sbin/

系统配置文件目录
#ls /etc/

系统 进程·访问·零时文件·缓存 目录
#ls /var/

编辑的服务 目录
#ls /usr/local/

 

ls命令:

root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -i anaconda-ks.cfg
67147370 anaconda-ks.cfg

[root@localhost ~]# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -la
总用量 32
drwx------. 3 root root 147 11月 19 22:10 .
dr-xr-xr-x. 17 root root 244 12月 13 12:23 ..
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg
-rw-------. 1 root root 6284 12月 14 15:20 .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 .cshrc
drwx------. 2 root root 187 12月 14 14:12 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@localhost ~]# ls -ld /root
drwx------. 3 root root 147 11月 19 22:10 /root

[root@localhost ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .ssh
.. .bash_history .bash_profile .cshrc .tcshrc

[root@localhost ~]# ls -lta
总用量 32
-rw-------. 1 root root 6284 12月 14 15:20 .bash_history
drwx------. 2 root root 187 12月 14 14:12 .ssh
dr-xr-xr-x. 17 root root 244 12月 13 12:23 ..
drwx------. 3 root root 147 11月 19 22:10 .
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg
-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 .cshrc
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@localhost ~]# ls -d
.
[root@localhost ~]# ls -ld
drwx------. 3 root root 147 11月 19 22:10 .

 

ls常用命令:

ls -l 查看当前目录详细信息

ls -i    iload 

ls -a 查看目录全部文件包括隐藏的文件

ls -t 安时间顺序排序

ls -h》-lh 查看文件大小

ls -d 列出目录

 

 

文件类型:
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -i anaconda-ks.cfg
67147370 anaconda-ks.cfg

[root@localhost ~]# ls -lh anaconda-ks.cfg
-rw-------. 1 root root 1.4K 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -la
总用量 32
drwx------. 3 root root 147 11月 19 22:10 .
dr-xr-xr-x. 17 root root 244 12月 13 12:23 ..
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg
-rw-------. 1 root root 6284 12月 14 15:20 .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 .cshrc
drwx------. 2 root root 187 12月 14 14:12 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@localhost ~]# ls -ld /root
drwx------. 3 root root 147 11月 19 22:10 /root

[root@localhost ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .ssh
.. .bash_history .bash_profile .cshrc .tcshrc

[root@localhost ~]# ls -lta
总用量 32
-rw-------. 1 root root 6284 12月 14 15:20 .bash_history
drwx------. 2 root root 187 12月 14 14:12 .ssh
dr-xr-xr-x. 17 root root 244 12月 13 12:23 ..
drwx------. 3 root root 147 11月 19 22:10 .
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg
-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 .cshrc
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
[root@localhost ~]# ls -d
.
[root@localhost ~]# ls -ld
drwx------. 3 root root 147 11月 19 22:10 .
[root@localhost ~]# man ls
[root@localhost ~]# ll
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls

[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls

 

 

 

文件类型:
[root@localhost ~]# ls -la
dr-xr-xr-x. 1 root root
-rw-r--r--. 1 root root
crw-------. 1 root root
brw-rw----. 1 root root
srw-rw-rw-. 1 root root
lrwxrwxrwx 1 root root

 

(D) 目录

 

(-) 普通文件

 

(C) 字符设备文件

 

(B) 硬设备文件

 

(S) socket

 

(L) 软连接

 

 

alias命令:

# which  ls    查看别名

# alias admin='ls -lha' 创建一个别名
# unalias admin 删除别名


[root@localhost ~]# ll
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 1406 11月 10 22:32 anaconda-ks.cfg

[root@localhost ~]# ls ll ^C

[root@localhost ~]# which ll
alias ll='ls -l --color=auto'
/usr/bin/ls

[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls

[root@localhost ~]# which man
/usr/bin/man

[root@localhost ~]# which yum
/usr/bin/yum

[root@localhost ~]# alias
alias 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'

[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@localhost ~]# alias admin='ls -lha'
[root@localhost ~]# admin
总用量 32K
drwx------. 3 root root 147 11月 19 22:10 .
dr-xr-xr-x. 17 root root 244 12月 13 12:23 ..
-rw-------. 1 root root 1.4K 11月 10 22:32 anaconda-ks.cfg
-rw-------. 1 root root 6.2K 12月 14 15:20 .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 .cshrc
drwx------. 2 root root 187 12月 14 14:12 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc

[root@localhost ~]# unalias admin

[root@localhost ~]# admin
-bash: admin: 未找到命令
[root@localhost ~]#

 

posted @ 2017-12-15 12:24  两颗白菜  阅读(202)  评论(1编辑  收藏  举报