1. 文件管理概述
创建 复制 移动 删除 查看 编辑 压缩
2. 系统的目录结构
Windows
D:\Linux脱产10期视频\基础阶段 反斜线
Linux
所有的文件或者目录的起点或者顶点都是以根开始的 / 斜线
Linux的目录结构就像是一个倒挂的树形结构
必知必会的目录及文件
[root@qls ~]
软连接文件
/bin
/sbin
/lib
/lib64
====
/usr/bin
/usr/sbin
/usr/lib
/usr/lib64
/boot
/dev
/dev/cdrom -> sr0
/dev/null
/dev/zero
/dev/random
/dev/stderr -> /proc/self/fd/2
/dev/stdin -> /proc/self/fd/0
/dev/stdout -> /proc/self/fd/1
/dev/pts/
/dev/sda
/dev/sda1 /
/dev/sda2
/dev/sda3 /boot
/etc
/etc/sysconfig/network-scripts/ifcfg-*
/etc/hosts
/etc/resolv.conf
/etc/fstab
/etc/hostname
/home
/media
/mnt
/opt
/proc
/root
/run
/srv
/sys
/tmp
/usr
/usr/local
/var
/var/log
/var/log/messages
/var/log/secure
/var/tmp
/var/run
3. 路径的定位
包含整个文件名称及文件的位置,这样的定位称之为路径
路径就是对于文件的定位的一种方式
每个目录下都有一个点和两个点,都表示什么意思
.
..
[root@qls usr]
[root@qls usr]
./
.
../
..
什么是绝对路径 什么又是相对路径
绝对路径: 凡是以根开始的路径就是绝对路径 或者以~开头的路径也是绝对路径 ~ === /root ~ == /home/xxx
/usr/local/
相对路径: 不是以根为开头的路径就是相对路径 相对路径是针对当前目录而言的
./local/
local/
4. 文件管理基础命令
1. pwd
[root@qls usr]
/usr
[root@qls usr]
[root@qls local]
/usr/local
2. cd
[root@qls local]
[root@qls ~]
[root@qls ~]
[root@qls ~]
[root@qls ~]
[root@qls ~]
[root@qls /]
[root@qls ~]
[root@qls /]
[root@qls usr]
[root@qls local]
/usr/local
[root@qls local]
[root@qls etc]
/usr/etc
[root@qls usr]
[root@qls etc]
/etc
[root@qls etc]
[root@qls /]
/etc
[root@qls etc]
3. ls
常用选项:
-l
-i
-h
-a
-S
-t
-r
-F
-d
/
*
=
|
[root@qls ~]
anaconda-ks.cfg
[root@qls ~]
anaconda-ks.cfg
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
=== 系统自带的别名 ll === ls -l
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
[root@qls ~]
total 4
134317667 -rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
[root@qls ~]
total 4.0K
-rw-------. 1 root root 1.4K Jul 6 02:17 anaconda-ks.cfg
10月24日 程序员日
[root@qls ~]
total 28
dr-xr-x---. 2 root root 135 Jul 6 09:06 .
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ..
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
[root@qls ~]
total 28
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ..
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
dr-xr-x---. 2 root root 135 Jul 6 09:06 .
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
[root@qls ~]
total 28
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
dr-xr-x---. 2 root root 135 Jul 6 09:06 .
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ..
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
[root@qls ~]
total 28
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ..
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
dr-xr-x---. 2 root root 135 Jul 6 09:06 .
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
[root@qls ~]
total 28
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
dr-xr-x---. 2 root root 135 Jul 6 09:06 .
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ..
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
[root@qls ~]
total 28
dr-xr-x---. 2 root root 135 Jul 6 09:06 ./
dr-xr-xr-x. 17 root root 224 Jul 6 02:16 ../
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
-rw-------. 1 root root 879 Jul 7 18:59 .bash_history
-rw-r--r--. 1 root root 18 Dec 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
-rw-r--r--. 1 root root 100 Dec 29 2013 .cshrc
-rw-r--r--. 1 root root 129 Dec 29 2013 .tcshrc
[root@qls ~]
dr-xr-x---. 2 root root 135 Jul 6 09:06 /root
[root@qls ~]
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@qls ~]
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
4. tree
[root@qls ~]
选项:
-a
-d
-h
-F
/
*
=
|
-L
[root@qls ~]
.
└── anaconda-ks.cfg
0 directories, 1 file
[root@qls ~]
.
├── anaconda-ks.cfg
├── .bash_history
├── .bash_logout
├── .bash_profile
├── .bashrc
├── .cshrc
└── .tcshrc
0 directories, 7 files
[root@qls ~]
/var/log/
├── anaconda
├── audit
├── rhsm
└── tuned
4 directories
[root@qls ~]
/var/log/
├── [ 176] anaconda
│ ├── [ 26K] anaconda.log
│ ├── [3.9K] ifcfg.log
│ ├── [1.5M] journal.log
│ ├── [ 0] ks-script-3PCKae.log
│ ├── [108K] packaging.log
│ ├── [ 29K] program.log
│ ├── [121K] storage.log
│ ├── [275K] syslog
│ └── [ 21K] X.log
[root@qls ~]
5. mkdir
选项:
-p
-v
-m
{}
*
在相同的路径下,不能存在相同的文件名称
在不同的路径下,可以存在相同的文件名称
[root@qls ~]
[root@qls ~]
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
[root@qls ~]
total 20
lrwxrwxrwx. 1 root root 7 Jul 6 02:13 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Jul 6 02:17 boot
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
[root@qls ~]
mkdir: cannot create directory ‘/root/data’: File exists
File exists
解决:
1. 你要创建的目录已经存在,无需再次进行创建
2. 你要创建的目录路径书写错误
[root@qls ~]
[root@qls ~]
mkdir: cannot create directory ‘test/oldboy’: No such file or directory
[root@qls ~]
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
drwxr-xr-x. 3 root root 20 Jul 8 19:57 test
[root@qls ~]
total 0
drwxr-xr-x. 2 root root 6 Jul 8 19:57 oldboy
[root@qls ~]
[root@qls ~]
[root@qls ~]
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy
drwxr-xr-x. 3 root root 20 Jul 8 19:57 test
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data/
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy/
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy /
drwxr-xr-x. 3 root root 20 Jul 8 19:57 test/
[root@qls ~]
[root@qls ~]
mkdir: created directory ‘data01’
[root@qls ~]
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
drwxr-xr-x. 2 root root 6 Jul 8 20:02 data01
drwx------. 2 root root 6 Jul 8 20:04 data02
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy
drwxr-xr-x. 2 root root 6 Jul 8 20:00 oldboy
drwxr-xr-x. 3 root root 20 Jul 8 19:57 test
[root@qls ~]
01 02 03 04 05 06 07 08 09 10
[root@qls ~]
[root@qls ~]
total 0
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data01
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data02
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data03
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data04
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data05
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data06
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data07
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data08
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data09
drwxr-xr-x. 2 root root 6 Jul 8 20:09 data10
[root@qls ~]
a b c d e f g h i j k l m n o p q r s t u v w x y z
[root@qls ~]
a b c d e f g
[root@qls ~]
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[root@qls ~]
[root@qls ~]
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-a
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-b
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-c
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-d
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-e
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-f
drwxr-xr-x. 2 root root 6 Jul 8 20:11 test/oldboy-g
[root@qls ~]
[root@qls ~]
total 4
-rw-------. 1 root root 1429 Jul 6 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jul 8 19:51 data
drwxr-xr-x. 2 root root 6 Jul 8 20:02 data01
drwx------. 2 root root 6 Jul 8 20:04 data02
drwxr-xr-x. 2 root root 6 Jul 8 20:12 data-a
drwxr-xr-x. 2 root root 6 Jul 8 20:12 data-c
drwxr-xr-x. 2 root root 6 Jul 8 20:12 data-d
drwxr-xr-x. 2 root root 6 Jul 8 20:12 data-h
[root@qls ~]
[root@qls ~]
[root@qls ~]
[root@qls ~]
total 4
drwxr-xr-x. 2 root root 6 Jul 8 12:25 a
drwxr-xr-x. 2 root root 6 Jul 8 12:25 A
6. touch
{}
[root@qls ~]
[root@qls ~]
[root@qls ~]
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.js
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.log
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.py
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.sh
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.tar
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.txt
-rw-r--r--. 1 root root 0 Jul 8 12:27 data.xml
[root@qls ~]
[root@qls ~]
-rw-r--r--. 1 root root 0 Jul 8 12:28 data01.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data02.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data03.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data04.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data05.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data06.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data07.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data08.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data09.txt
-rw-r--r--. 1 root root 0 Jul 8 12:28 data10.txt