首页 > 其他分享 >学习笔记-第08天-命令合集7

学习笔记-第08天-命令合集7

时间:2023-05-26 14:33:58浏览次数:38  
标签:23 May 合集 08 05 笔记 date root localhost

属性:

人的属性:性别,身高,体重,年龄。

文件的属性:大小,用户,组,权限,创建时间。

[root@localhost ~]# stat /etc/hosts
  File: ‘/etc/hosts’
  Size: 158       	Blocks: 8          IO Block: 4096   regular file
Device: 802h/2050d	Inode: 67109833    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-05-23 07:23:45.977483911 +0800
Modify: 2013-06-07 22:31:32.000000000 +0800
Change: 2023-05-07 20:28:56.812001998 +0800
 Birth: -

最近访问: 2021-05-12 12:13:30  #access访问,浏览,针对内容

最近更改:  2021-05-10 10:31:31  #modify最后更改时间,针对内容

最近改动:  2021-05-10 10:31:31  #change 状态改变,属性改变学习笔记-第08天-命令合集7_文件类型

查看文件属性:

[root@localhost ~]# ls -li
total 32
135116374 -rw-r--r-- 1 root root  74 May 24 05:04 ab.txt
135116371 -rw-r--r-- 1 root root   8 May 24 04:43 a.txt
135116375 -rw-r--r-- 1 root root  87 May 24 05:05 b.txt
 67118104 drwxr-xr-x 2 root root   6 May 23 22:51 dir
   539794 drwxr-xr-x 2 root root   6 May 23 22:46 dir1
 67109271 drwxr-xr-x 2 root root   6 May 23 22:46 dir2
135116367 drwxr-xr-x 2 root root   6 May 23 22:46 dir3
202163968 drwxr-xr-x 2 root root   6 May 23 22:46 dir4
   539797 drwxr-xr-x 2 root root   6 May 23 22:46 dir5
135116365 -rw-r--r-- 1 root root   0 May 23 22:38 oldboy
134320002 -rw-r--r-- 1 root root 104 May 24 04:48 oldboy.txt
135116360 -rw-r--r-- 1 root root  30 May 24 04:13 oldgirl.txt
135116370 -rw-r--r-- 1 root root   0 May 23 22:50 seq
135116368 -rw-r--r-- 1 root root  21 May 24 04:22 seq.txt
135116369 -rw-r--r-- 1 root root  74 May 24 04:58 test.txt
135116373 -rw-r--r-- 1 root root  74 May 24 05:01 u.txt

学习笔记-第08天-命令合集7_bash_02

135116373   -rw-r--r--   1   root  root  74   May   24   05:01  u.txt

1                2          3     4        5     6      7      8       9       10

第1列,索引节点,形态是数字。

第2列,首字符代表文件类型

    中间9个字符,文件权限

    .和selinux(高级安全组件) 相关符号。

第3列,硬链接数。

第4列,用户。

第5列,用户组。

第6列,文件大小(目录不是)。

第7-9列,日期时间。

第10列,文件名。

windows文件类型:根据扩展名来的。

.doc   word文档

.avi  .mp4  视频

-ppt  .md  .txt

Linux文件类型:

Linux下面不根据扩展名确定类型,但是依然会有扩展名,为了给人看。一眼看清楚。系统不识别扩展名,那么系统怎么确定文件类型呢?

ls -li  第2列,首字符代表文件类型切皆文件。

-  普通文件

(白色命令)

d  目录 directory

(浅蓝色命令)

l  软链接文件 link

(快捷方式)

[root@localhost ~]# ls -l /bin
lrwxrwxrwx. 1 root root 7 May  7 20:28 /bin -> usr/bin
[root@localhost ~]# ln -s /etc/hosts /tmp/a.hosts
[root@localhost ~]# cat /tmp/a.hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

学习笔记-第08天-命令合集7_文件类型_03

c  字符设备

[root@localhost ~]# ls /dev/ -l
total 0
crw-rw---- 1 root video    10, 175 May 23 07:23 agpgart
crw------- 1 root root     10, 235 May 23 07:23 autofs
drwxr-xr-x 2 root root         120 May 23 07:23 block
drwxr-xr-x 2 root root          80 May 23 07:23 bsg
crw------- 1 root root     10, 234 May 23 07:23 btrfs-control
drwxr-xr-x 3 root root          60 May 23 07:23 bus
lrwxrwxrwx 1 root root           3 May 23 07:23 cdrom -> sr0
drwxr-xr-x 2 root root        2960 May 23 07:23 char
crw------- 1 root root      5,   1 May 23 07:23 console
lrwxrwxrwx 1 root root          11 May 23 07:23 core -> /proc/kcore
drwxr-xr-x 3 root root          60 May 23 07:23 cpu
crw------- 1 root root     10,  61 May 23 07:23 cpu_dma_latency
crw------- 1 root root     10,  62 May 23 07:23 crash
drwxr-xr-x 5 root root         100 May 23 07:23 disk
crw-rw---- 1 root audio    14,   9 May 23 07:23 dmmidi
drwxr-xr-x 2 root root          80 May 23 07:23 dri
crw-rw---- 1 root video    29,   0 May 23 07:23 fb0
lrwxrwxrwx 1 root root          13 May 23 07:23 fd -> /proc/self/fd
crw-rw-rw- 1 root root      1,   7 May 23 07:23 full
crw-rw-rw- 1 root root     10, 229 May 23 07:23 fuse
crw------- 1 root root    246,   0 May 23 07:23 hidraw0
crw------- 1 root root     10, 228 May 23 07:23 hpet
drwxr-xr-x 2 root root           0 May 23 07:23 hugepages
crw------- 1 root root     10, 183 May 23 07:23 hwrng

学习笔记-第08天-命令合集7_vim_04

b  块设备

[root@localhost ~]# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 May 23 07:23 /dev/sda
brw-rw---- 1 root disk 8, 1 May 23 07:23 /dev/sda1
brw-rw---- 1 root disk 8, 2 May 23 07:23 /dev/sda2

学习笔记-第08天-命令合集7_vim_05

s  socket文件   (进程通信时才会用到)

[root@localhost ~]# ls -l /dev/log
srw-rw-rw- 1 root root 0 May 23 07:23 /dev/log

学习笔记-第08天-命令合集7_文件类型_06

查看文件类型:file

[root@localhost ~]# file /etc/hosts
/etc/hosts: ASCII text
[root@localhost ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aaf05615b6c91d3cbb076af81aeff531c5d7dfd9, stripped
[root@localhost ~]# file /var/log/wtmp
/var/log/wtmp: data

学习笔记-第08天-命令合集7_vim_07

wc 查看行数,字符数等:

-l  查看行数

-L  查看字符数

实践:

[root@localhost ~]# wc -l /etc/hosts
2 /etc/hosts
[root@localhost ~]# echo oldboy|wc -L
6

学习笔记-第08天-命令合集7_文件类型_08

查找命令:

1) which查看二进制命令所在路径:(从PATH环境变量路径里查找)

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

学习笔记-第08天-命令合集7_文件类型_09

特殊注意:

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

学习笔记-第08天-命令合集7_bash_10

2) Whereis查看文件及文件的帮助等的路径:

-b 查看二进制命令所在路径which:

[root@localhost ~]# whereis -b ls
ls: /usr/bin/ls
[root@localhost ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz

学习笔记-第08天-命令合集7_文件类型_11

3)locate查找文件及相关内容(内置数据库,通过updatedb)

[root@localhost ~]# yum install mlocate -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com

学习笔记-第08天-命令合集7_文件类型_12

[root@localhost ~]# locate ls
/usr/share/vim/vim74/compiler/modelsim_vcom.vim
/usr/share/vim/vim74/compiler/onsgmls.vim
/usr/share/vim/vim74/ftplugin/alsaconf.vim
/usr/share/vim/vim74/ftplugin/protocols.vim
/usr/share/vim/vim74/syntax/alsaconf.vim
/usr/share/vim/vim74/syntax/cuplsim.vim
/usr/share/vim/vim74/syntax/lscript.vim
/usr/share/vim/vim74/syntax/lsl.vim
/usr/share/vim/vim74/syntax/lss.vim
/usr/share/vim/vim74/syntax/plsql.vim
/usr/share/vim/vim74/syntax/protocols.vim
/usr/share/yum-cli/utils.py
/usr/share/yum-cli/utils.pyc

学习笔记-第08天-命令合集7_bash_13

4) find查找:

(1)-name  按名字查找

         find 路径 选项1 【参数1】 选项2 【参数2】

按名字查找:

find  /  -name  “hosts”

[root@localhost date]# find / -name "hosts"
/etc/hosts

学习笔记-第08天-命令合集7_文件类型_14


按名字模糊查找:

find  /  -name  “ho*ts”

[root@localhost date]# find / -name "ho*ts"
/etc/hosts

学习笔记-第08天-命令合集7_vim_15

(2) 按类型查找:

-type

-type c

b  block  (buffered)  special

c  character (unbuffered)  special

d  directory

f  regular file

l  symbolic link;

s  socket

查找目录:

[root@localhost ~]# find /root -type d
/root
/root/dir
/root/dir1
/root/dir2
/root/dir3
/root/dir4
/root/dir5

学习笔记-第08天-命令合集7_vim_16

查看文件:

[root@localhost ~]# find /root -type f
/root/.bash_logout
/root/.bash_profile
/root/.bashrc
/root/.cshrc
/root/.tcshrc
/root/.bash_history
/root/.localhost.txt.swp
/root/seq
/root/a.txt
/root/test.txt
/root/u.txt
/root/ab.txt
/root/b.txt
/root/.viminfo
/root/oldboy.txt
/root/oldgirl.txt
/root/oldboy
/root/seq.txt

学习笔记-第08天-命令合集7_vim_17

组合查找:find默认就是取交集(-a) and,并集(-o)or

查看文件类型为文件,并且名字为hosts

find  /  -name  “hosts”-a  -type  f

find  /  -name  “hosts”-type  f

[root@localhost date]# find  / -name "hosts" -a -type f
/etc/hosts
[root@localhost date]# find  / -name "hosts"  -type f
/etc/hosts

学习笔记-第08天-命令合集7_bash_18

并集:查找名为hosts,或者类型为d

find  /  -name  “hosts”-o  -type  d  -name  “oldboy”

[root@localhost date]# find  / -name "hosts" -o  -type d -name "oldboy"
/etc/hosts

学习笔记-第08天-命令合集7_bash_19

取反: !查找名字不是file1

[root@localhost ~]# mkdir /date -p
[root@localhost ~]# touch /date/file{1..3}
[root@localhost ~]# find /date -name "file1"
/date/file1
[root@localhost ~]# find /date -! -name "file1"
/date
/date/file2
/date/file3

学习笔记-第08天-命令合集7_vim_20

(3) 按大小查找:

-size +1M   #大于1M

-size -1M   #小于1M

-size 1M    #1M

其他单位: K ,G

[root@localhost date]# find ./ -size -10M
./
./file1
./file2
./file3
[root@localhost date]# find ./ -size +10M

学习笔记-第08天-命令合集7_bash_21

(4) -mtime按修改时间查找

-atime按访问时间查找

-ctime按改变时间查找

-mtime +7  #7天以前的

-mtime -7  #最近7天的

-mtime  7  #第7天

[root@localhost date]# find ./ -mtime -7
./
./file1
./file2
./file3
./file01
./file02
./file03
./file04
./file05
./file06
./file07
./file08
./file09
./file10
./file11
./file12
./file13
./file14
./file15
./file16
./file17
./file18
./file19
./file20
./file21
./file22
./file23
./file24
./file25
./file26
./file27
./file28
./file29
./file30
[root@localhost date]# find ./ -mtime +7

学习笔记-第08天-命令合集7_文件类型_22

测试:复制即可,模拟每天创建一个文件,连续30天。

for n in {01..30};do date -s “2030/05/0$n”;touch /date/file$n;done

[root@localhost date]# for n in {01..30};do date -s “2030/05/0$n”;touch /date/file$n;done
date: invalid date ‘“2030/05/001”’
date: invalid date ‘“2030/05/002”’
date: invalid date ‘“2030/05/003”’
date: invalid date ‘“2030/05/004”’
date: invalid date ‘“2030/05/005”’
date: invalid date ‘“2030/05/006”’
date: invalid date ‘“2030/05/007”’
date: invalid date ‘“2030/05/008”’
date: invalid date ‘“2030/05/009”’
date: invalid date ‘“2030/05/010”’
date: invalid date ‘“2030/05/011”’
date: invalid date ‘“2030/05/012”’
date: invalid date ‘“2030/05/013”’
date: invalid date ‘“2030/05/014”’
date: invalid date ‘“2030/05/015”’
date: invalid date ‘“2030/05/016”’
date: invalid date ‘“2030/05/017”’
date: invalid date ‘“2030/05/018”’
date: invalid date ‘“2030/05/019”’
date: invalid date ‘“2030/05/020”’
date: invalid date ‘“2030/05/021”’
date: invalid date ‘“2030/05/022”’
date: invalid date ‘“2030/05/023”’
date: invalid date ‘“2030/05/024”’
date: invalid date ‘“2030/05/025”’
date: invalid date ‘“2030/05/026”’
date: invalid date ‘“2030/05/027”’
date: invalid date ‘“2030/05/028”’
date: invalid date ‘“2030/05/029”’
date: invalid date ‘“2030/05/030”’

学习笔记-第08天-命令合集7_bash_23

.和./都表示当前目录

..和../都表示上级目录

【对找到的东西进行处理】

-exec  执行动作

方法一:

find /date -name “file*”-mtime +7 -exec rm -f {} \;

[root@localhost date]# find /date -name “file*” -mtime +7 -exec rm -f {} \;
[root@localhost date]# find /date -name “file*” -mtime +7 
[root@localhost date]# ls
file01  file03  file05  file07  file09  file10  file12  file14  file16  file18  file2   file21  file23  file25  file27  file29  file30
file02  file04  file06  file08  file1   file11  file13  file15  file17  file19  file20  file22  file24  file26  file28  file3
[root@localhost date]# find /date -name “file*” -mtime 7
[root@localhost date]# find /date -name “file*” -mtime 7 -exec rm -f {} \;
[root@localhost date]# find /date -name “file*” -mtime 7
[root@localhost date]# ls
file01  file03  file05  file07  file09  file10  file12  file14  file16  file18  file2   file21  file23  file25  file27  file29  file30
file02  file04  file06  file08  file1   file11  file13  file15  file17  file19  file20  file22  file24  file26  file28  file3

学习笔记-第08天-命令合集7_bash_24

方法二:

命令行:

$(命令)或`命令`,拼路径拼命令

rm -f $(find /date -name “file*”-type f -mtime +7)

rm -f `find /date -name “file*”-type f -mtime +7`

[root@localhost ~]# rm -f $(find /date -name “file*” -type f -mtime +7)
[root@localhost ~]# ls
ab.txt  a.txt  b.txt  dir  dir1  dir2  dir3  dir4  dir5  oldboy  oldboy.txt  oldgirl.txt  seq  seq.txt  test.txt  u.txt
[root@localhost ~]#  rm -f $`find /date -name “file*” -type f -mtime +7`
[root@localhost ~]# ls
ab.txt  a.txt  b.txt  dir  dir1  dir2  dir3  dir4  dir5  oldboy  oldboy.txt  oldgirl.txt  seq  seq.txt  test.txt  u.txt

学习笔记-第08天-命令合集7_bash_25

方法三:

Xargs

-n  分组

[root@localhost date]# seq 10 >oldboy.txt
[root@localhost date]# xargs -n 3 <oldboy.txt
1 2 3
4 5 6
7 8 9
10

学习笔记-第08天-命令合集7_vim_26

-i

/data/file 30

[root@localhost date]# find /date -name “file*” -mtime 7|xargs -i rm -f {}
[root@localhost date]# ls
file01  file03  file05  file07  file09  file10  file12  file14  file16  file18  file2   file21  file23  file25  file27  file29  file30
file02  file04  file06  file08  file1   file11  file13  file15  file17  file19  file20  file22  file24  file26  file28  file3   oldboy.txt
[root@localhost date]# find /date -name “file*” -mtime +7|xargs -i rm -f {}

学习笔记-第08天-命令合集7_文件类型_27

标签:23,May,合集,08,05,笔记,date,root,localhost
From: https://blog.51cto.com/u_16123007/6355423

相关文章

  • DAY14笔记及补充
     今日默写: 1.描述下Java运行原理全流程 2.描述下变量的定义及赋值方式 3.描述下常量的命名规范 4.java的技术类型种类 5.java基本数据类型中哪两种赋值时需要加入特殊标记后缀,分别是什么类型 6.java的引用类型如何定义并赋值 7.描述下自动转换类型中 int和double类型的......
  • 牛客练习赛108
    风间分析:暴力实现:inta[N],b[N];voidsolve(){res=0;scanf("%lld",&n);for(inti=1;i<=n;i++)scanf("%lld",&a[i]);for(inti=1;i<=n;i++)scanf("%lld",&b[i]);......
  • python 名称空间与作用域(笔记整理)
    一、名称空间什么是名称空间:名称空间就是存放变量名和变量值绑定关系的地方就是内存地址在程序执行期间最多会存在三种名称空间:内置名称空间:是Python解释器默认预定义大量内置函数和内置异常的名称空间,就是存放解释器自带函数方法的名称空间可以通过dir(builtins)来......
  • 帆软学习随笔记录
    --模板>模板Web属性>填报页面设置-为该模板单独设置,添加加载结束事件(JS实现根据当前sheet隐藏参数面板)$(".fr-sheetbutton-container").click(function() //给切换sheet的按钮绑定点击事件 { vara=_g().selectedIndex; //获取当前sheet的编号(从0开始) if(a==1){ //如......
  • EF6学习笔记
    概述EntityFramework(EF)Core是轻量化、可扩展、开源和跨平台版的常用EntityFramework数据访问技术。EFCore可用作对象关系映射程序(O/RM),这可以实现以下两点:使.NET开发人员能够使用.NET对象处理数据库。无需再像通常那样编写大部分数据访问代码(SQL)。EF通过使......
  • python 函数的参数(笔记整理)
    一、形参与实参介绍函数的参数分为形式参数和实际参数:简称形参和实参在定义函数阶段依次填写的参数名字,称为:形式参数(也称为形参)作为函数的输入,以便在函数内部进行处理。而在调用函数阶段,函数名括号中需要传入具体的值作为实际参数(也称为实参),这些实参会被赋值给函数中的形参,......
  • 合集 替换子关键词
    代码list_ZFI077=df_1.columns.tolist()df_ZFI077=df_1.columns.to_frame(name="列名")#先不重置索引drop依据索引df_ZFI077_1=df_ZFI077.copy().reset_index(drop=True)#index.to_frame()后需重置索引方便赋值fori,jinenumerate(list_ZFI077):ifdf_ZFI0......
  • 统信UOS系统开发笔记(一):国产统信UOS系统搭建开发环境之虚拟机安装
    前言  开发国产应用,需要使用到统信UOS系统,之前已经开发过国产银河麒麟V4、V7和V10版本了,本次新项目使用到统信UOS,记录UOS虚拟机安装流程,方便快捷进行相关开发工作。<br>提前准备VMware16虚拟机软件  下载VM16版本及以上的vmware虚拟机版本,否则没有CentO8选项,自行百度下......
  • Flask008_构造 URL
    通过url_for函数构造URL。url_for接收视图函数名作为第1个参数,以及其他URL定义时的参数,其他参数添加到URL的后面作为查询字符串参数。[email protected]('/blog/<int:blog_id>')2defblog_detail(blog_id):3returnf"您查找的博客id为{blog_id}"[email protected]......
  • 笔记本电脑调亮度没反应
    情况描述:按快捷键调亮度失效,在系统设置亮度左右滑动后亮度没反应。这种情况一般是显卡驱动问题。首先先解决快捷键调亮度失效问题;根据电脑的s/n码在对应的官网,公众号下载对应的驱动;第2步安装调亮度没反应的问题电脑类型:惠普站66三代笔记本出现显卡驱动问题前的操作,给电脑重装操作系......