扩展名; .avi .txt .log .sh 都是扩展名。
扩展名作用;1.Windows: 系统根据不同的扩展名 区分不同类型的文件.
2.Linux: 扩展名是给我们看的。方便人类区分不同类型的文件.
常见扩展名为;.txt 文本文件 .log 日志文件 .conf .cfg 配置文件 .sh .bash 脚本文件(命令大礼包)
常见的文件类型:
— file 普通文件
-d diectory 目录
l softlink 软连接(快捷方式)
b block 设备(块)文件 光盘 硬盘
c character 字符设备(不断向外发出或接受字符)
- file 普通文件分为1.二进制文件(命令)2.文本文件(text) 3.数据文件(data) 压缩包
命令file; 查询文件详细类型
l softlink 软连接/符号链接(快捷方式) 存放源文件的位置
touch /oldboy/oldboy.txt
[root@oldboyedu59 oldboy]# touch /oldboy/oldboy.txt
[root@oldboyedu59 oldboy]# ls -l /oldboy/
total 8
drwxr-xr-x. 3 root root 19 Mar 28 11:57 alex
-rw-r--r-- 1 root root 7 Apr 9 15:08 alex.txt
-rw-r--r-- 1 root root 65 Apr 1 20:52 oldboy.avi
-rw-r--r-- 1 root root 0 Apr 9 15:19 oldboy.txt
-rw-r--r--. 1 root root 0 Mar 28 12:38 oldboy.txt.bak
[root@oldboyedu59 oldboy]# ln -s /oldboy/oldboy.txt /oldboy/oldboy.txt.soft
[root@oldboyedu59 oldboy]# ls -l /oldboy/
total 8
drwxr-xr-x. 3 root root 19 Mar 28 11:57 alex
-rw-r--r-- 1 root root 7 Apr 9 15:08 alex.txt
-rw-r--r-- 1 root root 65 Apr 1 20:52 oldboy.avi
-rw-r--r-- 1 root root 0 Apr 9 15:19 oldboy.txt
-rw-r--r--. 1 root root 0 Mar 28 12:38 oldboy.txt.bak
lrwxrwxrwx 1 root root 18 Apr 9 15:20 oldboy.txt.soft -> /oldboy/oldboy.txt
c character 字符设备(不断向外发出或接受字符)
/dev/urandom 随机字符生成器 (生成随机密码)
/dev/null 黑洞(不断接受信息 )
/dev/zero 白洞(不断发出信息 无法查看)
命令tr参数;-d 删除
[root@oldboyedu59 ~]# echo {a..z} {0..10} > /oldboy/oldboy.txt
[root@oldboyedu59 ~]# cat /oldboy/oldboy.txt
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 0 1 2 3 4 5 6 7 8 9 10
[root@oldboyedu59 ~]# tr 'a-z' 'A-Z' </oldboy/oldboy.txt
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 0 1 2 3 4 5 6 7 8 9 10
[root@oldboyedu59 ~]# tr -d 'a-z' </oldboy/oldboy.txt
0 1 2 3 4 5 6 7 8 9 10
[root@oldboyedu59 ~]# #tr -cd
命令tr参数;-cd 取反
[root@oldboyedu59 ~]# tr -cd 'a-z' </oldboy/oldboy.txt
abcdefghijklmnopqrstuvwxyz[root@oldboyedu59 ~]#
[root@oldboyedu59 ~]# tr -cd 'a-zA-Z0-9' </dev/urandom |head -c 8
xoRe6cQs[root@oldboyedu59 ~]#
软连接命令;ln-s
硬软连接命令;ln
which 显示命令的全路径
whereis:显示命令及其相关文件全路径
yum故障集合
Error: Nothing to do
No package locate available.
当用yum安装软件时出现图中错误时,用yum provides +命令解决查询
yum provides locate
mlocate-0.26-8.el7.x86_64 : An utility for finding files by name
软件包叫mlocate el7(centos7) 64位
Repo : base
Matched from:
Filename : /usr/bin/locate
如果无法上网无法安装时 。也可以用光盘安装
[root@oldboyedu59 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@oldboyedu59 ~]# ls /mnt/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@oldboyedu59 ~]# rpm -ivh /mnt/Packages/mlocate-0.26-8.el7.x86_64.rpm
Preparing... ################################# [100%]
package mlocate-0.26-8.el7.x86_64 is already installed
[root@oldboyedu59 ~]# rpm -qa mlocate
mlocate-0.26-8.el7.x86_64
find;查找目录下的文件
参数-type (类型f.d.l)
[root@oldboyedu59 ~]# find /oldboy -type f -name "oldboy.txt"
/oldboy/alex/lidao/oldboy.txt
/oldboy/oldboy.txt
参数-maxdepth
[root@oldboyedu59 ~]# find / -type d -maxdepth 1
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
warning 警告
-maxdepth 这个参数要放在其他参数之前。
[root@oldboyedu59 ~]# find / -maxdepth 1 -type d
/
/boot
/dev
/proc
/run
/sys
/etc
/root
/var
/tmp
/usr
/home
/media
/mnt
/opt
/srv
/old
/oldboy
/lidao
/oldwang
/newwang
/data
/tmp01
-iname 忽略大小写
[root@oldboyedu59 ~]# find /oldboy/alex/ -type f -name "oldboy*.txt"
/oldboy/alex/lidao/oldboy.txt
/oldboy/alex/oldboy01.txt
/oldboy/alex/oldboy02.txt
/oldboy/alex/oldboy03.txt
/oldboy/alex/oldboy04.txt
/oldboy/alex/oldboy05.txt
[root@oldboyedu59 ~]# find /oldboy/alex/ -type f -iname "oldboy*.txt"
/oldboy/alex/lidao/oldboy.txt
/oldboy/alex/oldboy01.txt
/oldboy/alex/oldboy02.txt
/oldboy/alex/oldboy03.txt
/oldboy/alex/oldboy04.txt
/oldboy/alex/oldboy05.txt
/oldboy/alex/OLDboy01.txt
/oldboy/alex/OLDboy02.txt
/oldboy/alex/OLDboy03.txt
/oldboy/alex/OLDboy04.txt
/oldboy/alex/OLDboy05.txt
[root@oldboyedu59 ~]#
参数-size根据大小查找文件(M必须大写)
xargs;将标准输入转换成命令行参数
root@oldboyedu59 ~]# echo {1..10} >/oldboy/sf.txt
[root@oldboyedu59 ~]# cat /oldboy/sf.txt
1 2 3 4 5 6 7 8 9 10
[root@oldboyedu59 ~]# xargs -n2 </oldboy/sf.txt
1 2
3 4
5 6
7 8
9 10
tar 打包压缩命令
创建压缩包参数;zcvf
z代表gzip工具进行压缩 ,c create创建包, v verbose 显示过程 f 指定压缩包 (放在最后)