几个搜索命令(find),文件名后缀,linux和Windows之间传文件

来源:互联网 发布:淘宝食品没有证能吗 编辑:程序博客网 时间:2024/05/18 09:40

几个快捷键

Ctrl + l : 清屏
Ctrl + d : (行里没字符)退出一个终端,和exit ,logout 。(行内有字符)向后一个一个的删
Ctrl + c : 放弃这一行,进入下一行
Ctrl + u : 删除光标之前的字符
ctrl + e : 将光标移到行尾
Ctrl + a : 将光标移到行首

几个搜索命令

  1. which
    搜索可执行文件的绝对路径
    [root@shuai-01 ~]# which ls
    这里写图片描述
  2. whereis
    一种模糊查找,用的不多
    [root@shuai-01 ~]# whereis ls
    这里写图片描述
  3. locate
    和whereis类似,模糊查找
    要使用要先安装一个包mlocate
    [root@shuai-01 ~]# yum -y install mlocate

  4. find
    find 命令语法:
    find [路径] [参数]
    [root@shuai-01 ~]# find /etc/ -name “ssh”
    这里写图片描述

参数:
-name filename 查找该文件名的文件

[root@shuai-01 ~]# find /root -name "*.txt"/root/shuai/3.txt/root/deng/1.txt/root/1.txt/root/2.txt

-type filetype 通过文件类型查找文件(f,b,c,d,l,s)

[root@shuai-01 ~]# find /root/ -type l/root/deng/shuai

-atime 访问或执行时间

[root@shuai-01 ~]# find /tmp/ -atime -1/tmp//tmp/.Test-unix/tmp/.font-unix/tmp/.XIM-unix/tmp/.ICE-unix/tmp/.X11-unix/tmp/shuai/tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp

-ctime 文件大小,权限,iNode,写入时间

[root@shuai-01 ~]# find /tmp/ -ctime -1/tmp//tmp/.font-unix/tmp/.ICE-unix/tmp/.X11-unix/tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp

-mtime 写入时间

[root@shuai-01 ~]# find /tmp/ -mtime -1/tmp//tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp/systemd-private-4d5410310bc44e4a8156c6025c03e487-vmtoolsd.service-mkXyBT/tmp

如果几个参数以空格隔开,表示并列搜索

[root@shuai-01 ~]# find /etc/ -type f -atime -1 -mtime -1/etc/resolv.conf/etc/group/etc/gshadow/etc/tuned/active_profile

通过iNode号找硬链接

[root@shuai-01 ~]# ls -l总用量 12-rw-rw-r--. 2 root root     4 10月 25 23:58 1.txt-rw-rw-r--. 2 root root     4 10月 25 23:58 2.txt-rw-------. 1 root root  1422 10月 17 00:46 anaconda-ks.cfgdrwxrwxr-x. 2 root shuai   32 10月 26 22:19 dengdrwxrwxrwx. 4 root root    43 10月 24 21:19 shuai[root@shuai-01 ~]# ls -i 1.txt33574997 1.txt[root@shuai-01 ~]# find -inum 33574997./1.txt./2.txt

这里写图片描述

-mmin 查找多少分钟内改过的

[root@shuai-01 ~]# find /root/ -type f -mmin -60/root/1.txt/root/2.txt

-exec 找到的文件通过这个参数还能做一些其他的动作

找到60分钟内改过的文件的详细信息显示出来

[root@shuai-01 ~]# find /root/ -type f -mmin -60 -exec ls -l {} \;-rw-rw-r--. 2 root root 8 10月 27 23:53 /root/1.txt-rw-rw-r--. 2 root root 8 10月 27 23:53 /root/2.txt

找到60分钟内改过的文件并重命名

[root@shuai-01 ~]# find /root/ -type f -mmin -60 -exec mv {} {}.bak \;[root@shuai-01 ~]# ls1.txt.bak  2.txt.bak  anaconda-ks.cfg  deng  shuai[root@shuai-01 ~]# find /root/ -name "*.bak"/root/1.txt.bak/root/2.txt.bak

stat命令
查看文件或目录详细信息,比ls -l 还要详细

[root@shuai-01 ~]# stat 2.txt  文件:"2.txt"  大小:4          块:8          IO 块:4096   普通文件设备:803h/2051d   Inode:33574997    硬链接:2权限:(0664/-rw-rw-r--)  Uid:(    0/    root)   Gid:(    0/    root)环境:unconfined_u:object_r:admin_home_t:s0最近访问:2017-10-25 23:58:41.764965898 +0800最近更改:2017-10-25 23:58:37.392846746 +0800最近改动:2017-10-26 23:00:30.319973967 +0800创建时间:-

文件名后缀

linux下,文件后缀是没有什么特别要求的,但是为了便于区分,会习惯于把文本文件加.txt后缀,把shell文件加.sh后缀,而.gz,.zip , .gz2这些后缀通常表示压缩文件

linux 和Windows 传文件

在xshell下,可以做到。
先安装一个包(lrzsz),在linux

[root@shuai-01 ~]# yum install -y lrzsz

在linux下往Windows下传文件

[root@shuai-01 ~]# sz 1.txt

在Windows往linux下传东西

[root@shuai-01 ~]# rz        
阅读全文
0 0