centos7的目录结构(linux所有的都是文件)
bin ---- 命令,二进制文件的存放目录
boot ----- 系统引导程序+系统的内核
dev ---- 设备 硬盘,光驱
etc ---- 存储系统或者服务的配置文件
home ---- 普通用的家目录
lib ----- 库文件存放目录
lib64 ---- 库文件的存放目录(64位系统)
media ---- linux识别的设备,比如u盘等,挂这个目录
mnt ----- 临时的挂载点目录
opt ----- 第三方的软件安装在整理
proc ----- 虚拟目录,显示内存中的信息(进场,内核的信息)
root ----- root的家目录
run ----- 放的启动的东西
sbin --- 超级命令,只用root用户才能用的命令
srv ----- service的缩写,存放的是一些启动后需要的数据
sys ------ 虚拟目录,内存信息
tmp ----- 临时文件的存放位置
usr ---- 存放用户的程序
var ----- 存放经常变化的文件,比如日志等
文件系统常用的命令
1.pwd 显示当前所在的路径
解释: pwd= print working directory 显示当前所在的目录
[root@localhost ~]
/root
2.cd切换目录结构
cd = change directory 改变目录信息
/目录 表示绝对路径 目录/ 表示相当路径
[root@localhost ~]
[root@localhost etc]
/etc
[root@localhost etc]
[root@localhost home]
/home
[root@localhost home]
[root@localhost home]
[root@localhost etc]
[root@localhost sysconfig]
三种方式:
cd ~
cd /root
cd
cd -
../ 返回一级
../../ 返回两级
../../../../../../ 很多个是返回到根路径 /
3.mkdir创建目录信息
mkdir = make directory
[root@localhost /]
-bash: cd: /oldboy: No such file or directory
[root@localhost /]
[root@localhost /]
[root@localhost oldboy]
/oldboy
[root@localhost oldboy]
mkdir: cannot create directory ‘/oldboy/olddog/jason’: No such file or directory
[root@localhost oldboy]
[root@localhost oldboy]
[root@localhost oldboy]
[root@localhost jason]
/oldboy/olddog/jason
[root@localhost jason]
[root@localhost /]
[root@localhost /]
[root@localhost god]
/oldboy/oldgirl/god
4.touch创建文件
[root@localhost tank]
[root@localhost oldboy]
/oldboy
[root@localhost oldboy]
[root@localhost oldboy]
oldboy.txt olddog oldgirl
[root@localhost oldboy]
[root@localhost oldboy]
jason jj
5.ls检查文件或者文件目录是否存在,并且列出目录下面的文件
ls = list
ls检查文件或者文件目录是否存在
[root@localhost /]
[root@localhost godsee]
god2.txt god3.txt godlover god.txt
[root@localhost godsee]
god.txt
[root@localhost godsee]
[root@localhost godsee]
total 12
-rw-r--r--. 1 root root 136 Mar 25 14:38 god2.txt
-rw-r--r--. 1 root root 143 Mar 25 14:39 god3.txt
drwxr-xr-x. 3 root root 18 Mar 25 14:18 godlover
-rw-r--r--. 1 root root 6 Mar 25 14:47 god.txt
[root@localhost godsee]
[root@localhost godsee]
total 12
drwxr-xr-x. 3 root root 18 Mar 25 14:18 godlover
-rw-r--r--. 1 root root 136 Mar 25 14:38 god2.txt
-rw-r--r--. 1 root root 143 Mar 25 14:39 god3.txt
-rw-r--r--. 1 root root 6 Mar 25 14:47 god.txt
[root@localhost godsee]
[root@localhost godsee]
total 12
-rw-r--r--. 1 root root 6 Mar 25 14:47 god.txt
-rw-r--r--. 1 root root 143 Mar 25 14:39 god3.txt
-rw-r--r--. 1 root root 136 Mar 25 14:38 god2.txt
drwxr-xr-x. 3 root root 18 Mar 25 14:18 godlover
[root@localhost godsee]
[root@localhost godsee]
. .. god2.txt god3.txt godlover god.txt
ls -a 表示查看当前文件夹底下的所有文件,包括隐藏文件
6 cat查看文件信息的命令
[root@localhost godsee]
hello
[root@localhost godsee]
[root@localhost godsee]
456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456
123
456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456456
[root@localhost godsee]
[root@localhost godsee]
[root@localhost godsee]
hello
[root@localhost godsee]
7 echo 将信息进行输出
[root@localhost oldboy]
hello world
[root@localhost oldboy]
[root@localhost oldboy]
jason.txt lxx.txt oldboy.txt olddog oldgirl oldgirl.txt
[root@localhost oldboy]
hello world
[root@localhost oldboy]
[root@localhost oldboy]
hello world
[root@localhost oldboy]
[root@localhost oldboy]
hello world
8 cp复制
cp = cope
语法格式: cp 参数(可选) 要复制的信息 复制到什么位置
[root@localhost godsee]
[root@localhost godsee]
god2.txt god3.txt god4.txt god5.txt godlover god.txt
[root@localhost godsee]
[root@localhost godlover]
hosts rain
[root@localhost godlover]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@localhost godlover]
cp: cannot create regular file ‘godlover/’: Not a directory
[root@localhost godlover]
cp: overwrite ‘/godsee/godlover/hosts’? y
[root@localhost godlover]
[root@localhost sysconfig]
cp: omitting directory ‘/etc/sysconfig/’
[root@localhost sysconfig]
[root@localhost sysconfig]
[root@localhost oldgirl]
sysconfig tank
[root@localhost oldgirl]
[root@localhost sysconfig]
/oldboy/oldgirl/sysconfig
cp的参数:
-r 进行递归复制
-p 拷贝是时候属性保存不变
-d 和链接相关的文件
-a == -drp
[root@localhost oldboy]
123
456
[root@localhost oldboy]
[root@localhost oldboy]
hosts jason.txt jason.txt.bak lxx.txt oldboy.txt olddog oldgirl oldgirl.txt
[root@localhost oldboy]
[root@localhost oldboy]
hosts jason.txt.bak lxx.txt oldboy.txt olddog oldgirl oldgirl.txt
[root@localhost oldboy]
[root@localhost oldboy]
hosts jason.txt jason.txt.bak lxx.txt oldboy.txt olddog oldgirl oldgirl.txt
[root@localhost oldboy]
123
456
[root@localhost oldboy]
cp: overwrite ‘/oldboy/oldgirl/sysconfig/ip6tables-config’? y
cp: overwrite ‘/oldboy/oldgirl/sysconfig/iptables-config’? y
cp: overwrite ‘/oldboy/oldgirl/sysconfig/cbq/avpkt’? ^C
[root@localhost oldboy]
9 mv 剪切命名
mv --move
对文件或者文件夹进行剪切(移动)
语法格式:mv 要移动的文件或者文件夹 移动到什么位置
[root@localhost oldboy]
[root@localhost oldboy]
[root@localhost test]
[root@localhost test]
[root@localhost test]
[root@localhost test]
[root@localhost shanghai]
heihei.txt
[root@localhost shanghai]
[root@localhost test]
[root@localhost oldboy]
hosts jason.txt jason.txt.bak lxx.txt oldboy.txt olddog oldgirl oldgirl.txt shanghai
[root@localhost oldboy]
[root@localhost oldboy]
hosts jason.txt jason.txt.bak lxxsb.txt oldboy.txt olddog oldgirl oldgirl.txt shanghai
10.rm命令(删除)
rm = remove
语法: rm 参数 要删除的数据信息
[root@localhost ~]
[root@localhost oldboy]
hosts jason.txt jason.txt.bak lxxsb.txt oldboy.txt olddog oldgirl oldgirl.txt shanghai
[root@localhost oldboy]
rm: remove regular file ‘jason.txt.bak’? y
[root@localhost oldboy]
hosts jason.txt lxxsb.txt oldboy.txt olddog oldgirl oldgirl.txt shanghai
[root@localhost oldboy]
rm: cannot remove ‘shanghai’: Is a directory
[root@localhost oldboy]
rm: descend into directory ‘shanghai’? y
rm: remove regular empty file ‘shanghai/heihei.txt’? y
rm: remove directory ‘shanghai’? y
[root@localhost oldboy]
hosts jason.txt lxxsb.txt oldboy.txt olddog oldgirl oldgirl.txt
[root@localhost oldboy]
[root@localhost oldboy]
[root@localhost oldboy]
hosts jason.txt lxxsb.txt oldgirl oldgirl.txt
rm -rf /
11.vim编辑器
https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11yCmuQx
1 正常模式
vim 文件 进入后就vim的正常模式,从正常如何进入编辑模式,输入 i,o,a,I,O,A,R,都可以,但是
我们只要记住一个i,因为方便记忆。
正常模式底下的命令:
拷贝: yy 粘贴:p
拷贝当前行向下2行,并粘贴
拷贝2行:2yy
粘贴:p
删当前行:
删除:dd
删除当前行与下一行:
删除:2dd
光标移动到最后一行:G
光标移到首行:gg
光标移到第二行:2gg
撤回:u
2 插入模式
进入编辑模式,就可以直接输入内容。
3 命令模式 shift + :
1 查找内容:
:/关键字
2 取消高亮:
:nohl
3 显示行号:
:set nu
4 取消行号
:set nonu
5 没有修改情况下退出
:q
6 如果修改了,但我们不想保存,
:q!
7 如果修改,并且想保存,
:wq
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200327112413631.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxNTA2MTMx,size_16,color_FFFFFF,t_70)