云计算学习资料分享:type查看命令

本文深入解析了Linux中如何使用type命令查看各种命令的类型,包括别名、内置命令、关键字及文件路径;并通过file命令展示了如何检查文件类型,如文本、二进制、管道、设备和链接文件;最后,通过stat命令详细介绍了如何获取文件的完整属性信息,如名称、大小、权限等。

type 查看命令类型,例如该命令是alias,还是内置命令,还是某个文件,还是关键字

哪种神仙:天上还是地上,还是水里游的

[root@tianyun ~]# type ll

ll is aliased to `ls -l --color=auto'

[root@tianyun ~]# type ls

ls is aliased to `ls --color=auto'

[root@tianyun ~]# type cd

cd is a shell builtin //builtin内置命令

[root@tianyun ~]# type for

for is a shell keyword //keyword关键字

[root@tianyun ~]# type useradd

useradd is /usr/sbin/useradd

[root@tianyun ~]# type -a ls //-a列出该命令所有类型

ls is aliased to `ls --color=auto'

ls is /usr/bin/ls

file 查看文件类型,例如文本文件,二进制文件,管道文件,设备文件,链接文件

人,神,魔,妖

[root@tianyun ~]# file /etc/hostname

/etc/hostname: ASCII text

[root@tianyun ~]# file /dev/sda

/dev/sda: block special

[root@tianyun ~]# file /dev/zero

/dev/zero: character special

stat 文件的详细属性,例如文件的名称,大小,权限,atime,ctime,mtime

人身高,体重,性别,年龄,道行

[root@tianyun ~]# stat /etc/hostname

File: '/etc/hostname'

Size: 22 Blocks: 8 IO Block: 4096 regular file

Device: fd00h/64768d Inode: 68703440 Links: 1

Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)

Access: 2017-07-25 11:11:14.257652134 +0800

Modify: 2017-07-25 10:21:34.175003119 +0800

Change: 2017-07-25 10:21:34.176003171 +0800

转载于:https://www.cnblogs.com/qianfengcs/p/11245879.html

Linux文件查找与压缩干货 云计算干货 Linux系统配置及服务管理文件查找 文件查找 简介 which :命令查找 find: 文件查找,针对文件名 locate:文件查找,依赖数据库 一、命令文件查找 一、查找ls 命令的位置 # which ls //从PATH环境变量 或者 # whereis vim 二、任意文件 find 语法 find [path...] [options] [expression] [action] 命令 路径 选项 表达式 动作 ①按文件名: [root@qianfeng ~]# find /etc -name "hosts" [root@qianfeng ~]# find /etc -iname "hosts" find /etc -iname "HOSTS" -i忽略大小写 i可以忽略大小写来查找 [root@qianfeng ~]# find /etc -iname "hos*" 心中有爱(i),什么都找得到 结果输出 /etc/hosts 文件查找成功 ②按文件大小: [root@qianfeng ~]# find /etc -size +5M 文件>5M 这里“size”是大小意思 [root@qianfeng ~]# find /etc -size 5M 文件=5M [root@qianfeng ~]# find /etc -size -5M 文件<5M ③指定查找的目录深度: [root@qianfeng ~]# find / -maxdepth 3 -a -name "ifcfg-en*" 这里maxdepth是深度 后面的数字是几级目录 [root@qianfeng ~]# find / -maxdepth 4 -a -name "ifcfg-en*" ④按文件属主、属组找: [root@qianfeng ~]# find /home -user aaa // 属主是aaa的文件 [root@qianfeng ~]# find /home -group hr // 属组是hr组的文件 ⑤按文件类型: [root@qianfeng ~]# find /tmp -type f f普通文件 文件type关键词 [root@qianfeng ~]# find /dev -type b b块设备文件 ⑥按文件权限: [root@qianfeng ~]# find . -perm 644 -ls 关键词perm -ls 是find的动作之一,精确权限 ⑦找到后处理的动作 ACTIONS: 找到后删除 # find /etc -name "qwer.txt" -delete 找到后复制 # find /etc -name "ifcfg*" -ok cp -rvf {} /tmp \; cp -rvf {} /tmp 对比cp /etc/passwd /tmp/etc1 找到的文件 连接符 前面找到的文件 结束符 文件打包及压缩 tar命令是Unix/Linux系统中备份文件的可靠方法, 几乎可以工作于任何环境中,它的使用权限是所有用户。 建议针对目录 打包,压缩 语法:tar 选项 压缩包名称 源文件 ===打包,压缩=== # tar -cf etc.tar /etc # tar -czf etc-gzip.tar.gz /etc/ //z是gzip # tar -cjf etc-bzip.tar.bz /etc/ //j是bzip # tar -cJf etc-xzip.tar.xz /etc/ //J是xzip 观察三个包的体积。 # ll -h etc* -rw-r--r--. 1 root root 11M 10月 14 10:07 etc-gzip.tar.gz -rw-r--r--. 1 root root 8.9M 10月 14 10:08 etc-bzip.tar.bz -rw-r--r--. 1 root root 7.6M 10月 14 10:08 etc-xzip.tar.xz 压缩速度和压缩体积成反比。 解压,解包 查看,并没有解压 # tar -tf etc.tar //t查看f文件名 解压缩 # tar xf etc3.tar.xz # tar -xvf etc2.tar.bz2 -C /tmp //-C重定向到//tmp目录
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值