Linux Learning (10) Find command, linux file suffix name, Linux and Windows file transfer

Source: Internet
Author: User
Tags log log


A few search commands related to find. 1.1 which
[[email protected] ~]# which ls
alias ls=‘ls --color=auto‘ /usr/bin/ls


This command only finds files below the environment variable, as in the above code.


1.2 Locate


This command depends on the search library, the file is not input, but can be updated manually, using the command:


[Email protected] ~]# UpdateDB


If the command does not, you need to install:


[[email protected] ~]# yum install -y mlocate
Loaded plugins: langpacks
base                                                                                 | 3.6 kB  00:00:00     
epel                                                                                 | 4.3 kB  00:00:00     
extras      
1.3 Whereis


This command, it is good to know, seldom used.


[Email protected] ~/usr/bin/ls/usr/share/man/man1/ls. 1. gz/usr/share/man/man1p/ls.1p.gz
Second, the Find command 2.1 The basic syntax of find


Find directory-Find options options parameters finding content



Take a look at the basic example:


[[email protected] ~]# find /root/ -type f -name "*.log"
/root/npm-debug.log
/root/.npm/npm-debug.log
/root/oneinstack/src/libevent-2.0.22-stable/config.log
/root/oneinstack/src/tmux-2.1/config.log
/root/oneinstack/src/pcre-8.38/config.log
/root/oneinstack/src/htop-2.0.0/config.log
/root/oneinstack/src/pure-ftpd-1.0.42/config.log
/root/Application/Runtime/Logs/Home/17_09_11.log


The above code means: Look for files with the file type F (normal file) in the/root directory, and the file name ends with. Log.


2.2 The search options can be divided into the following categories: 2.2.1 Type: File type


F: File


[[email protected] ~]# find /root/ -type f -name ‘*.log‘
/root/npm-debug.log
/root/.npm/npm-debug.log
/root/oneinstack/src/libevent-2.0.22-stable/config.log
/root/oneinstack/src/tmux-2.1/config.log
/root/oneinstack/src/pcre-8.38/config.log
/root/oneinstack/src/htop-2.0.0/config.log
/root/oneinstack/src/pure-ftpd-1.0.42/config.log
/root/Application/Runtime/Logs/Home/17_09_11.log


D: Catalogue


 
[[email protected] ~]# find / -type d -name ‘conf‘
/proc/sys/net/ipv4/conf
/proc/sys/net/ipv6/conf
/usr/local/aegis/PythonLoader/conf
/usr/local/aegis/aegis_client/aegis_10_27/conf
/usr/local/aegis/aegis_client/aegis_10_25/conf
/usr/local/aegis/aegis_client/aegis_10_33/conf
/usr/local/aegis/aegis_client/aegis_10_31/conf
/usr/local/nginx/conf


L: Soft Connection


[[email protected] 1]# find . -type f|xargs ls -l
-rw-r--r-- 1 root      ruanwenwu 0 Oct 26 22:30 ./1.txt
-rw-r--r-- 1 ruanwenwu ruanwenwu 0 Mar 26  2017 ./4/33.txt
-rw-rw-r-- 1 root      root      0 Oct 26 00:01 ./4/4.txt
-rw-rw-r-- 1 root      root      0 Oct 26 00:15 ./4/6/b.txt
-rw-r--r-- 1 root      root      6 Oct 26 00:33 ./4/b.txt
-rw-rw-r-- 1 root      root      2 Oct 26 00:24 ./5.txt


C: Input Device



B: Block device


[[Email protected]1]# find/dev/-Type B/dev/Xvdb/dev/xvda1/dev/xvda2.2.2 mtime/mmin: Modified number of days/modified minutes


To find a modified time of more than 1 days:


1] # find/root/1 -mtime +1/root/1/4/. txt


Find the modification time within 10 minutes:


[[email protected] 1]# find /root/1 -mmin -10
[[email protected] 1]# touch /root/1/c.txt
[[email protected] 1]# find /root/1 -mmin -10
/root/1
/root/1/c.txt
2.2.3 Size: File size


The lookup file size is less than 10kb:


1] # find/root/-size +1000k/root/.cache/composer/repo/https---packagist.org/p-provider--  the. JSON


Find files larger than 10M in size:


 
[[email protected] 1]# find /root/ -size +10M
/root/oneinstack/src/ImageMagick-6.8.9-10.tar.gz
/root/oneinstack/src/php-5.6.18.tar.gz
/root/oneinstack/src/mysql-5.5.48.tar.gz
/root/oneinstack/src/php-7.0.3.tar.gz
/root/oneinstack/src/percona-server-5.6.28-76.1.tar
2.3 Find Hard Links


We use the Inode number to find the hard link because the inode number of the hard link is the same as the source file:


[[email protected] 1]# ls
1.txt  4  5  5.txt  c.txt
[[email protected] 1]# ln 1.txt /tmp/1.txt
[[email protected] 1]# ls -l 1.txt
-rw-r--r-- 2 root ruanwenwu 0 Oct 26 22:30 1.txt
[[email protected] 1]# ls -i 1.txt
158242 1.txt
[[email protected] 1]# find / -inum 158242
/tmp/1.txt
2.4-xargs parameters


The Xargs parameter is used to process the found file, with an example:


[[email protected] 1]# find /root/1 -type f -exec mv {} {}.bak \;
[[email protected] 1]# tree /root/1 /root/1 ├── 1.txt.bak.bak
├── 4 │   ├── 33.txt.bak
│   ├── 4.txt.bak
│   ├── 6 │   │   └── b.txt.bak.bak
│   └── b.txt.bak
├── 5 ├── 5.txt.bak
└── c.txt.bak.bak


After discovering that this command was used, all the files were changed to the original file name +.bak file. Parentheses are a result of finding.


Third, the common shortcut key CTRL + D exit Terminal logout exit Terminal exit Exit Ctrl+u the end of the ctrl+d to delete the next ctrl+e move to the end of CTRL + a move to the front ctrl+k delete the four after the cursor, statstat to view the file details
[[email protected] 1]# stat /root/1/1.txt.bak.bak 
  File: ‘/root/1/1.txt.bak.bak’
  Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: ca01h/51713d    Inode: 158242 Links: 2 Access: (0644/-rw-r--r--)  Uid: ( 0/    root)   Gid: ( 1003/ruanwenwu)
Access: 2017-10-27 22:47:06.221000000 +0800 Modify: 2017-10-26 22:30:26.890000000 +0800 Change: 2017-10-27 23:07:24.217000000 +0800


Our most commonly used is three time:



Access: The time of the visit. It changes when we cat a file.



Modify: When we change the content of a file, changes are changed, because the change is affected by the Inode information, the file size changes, the inode information changes, and the change changes.



Change: Changes when the file permissions, the owning group, size, and so on are changed.



When you touch a file, you change it three of times.


Five, Linux file suffix


The file suffix of Linux is not as meaningful as it is under Windows. Under Linux, the suffix is just to make it easier for us to distinguish between file types. Common file types are:



. conf configuration file



. zip Zip archive Package



. tar.gz tar.gz Compression Pack



. Tar Tar compression package



. log log file


Six, Windows and Linux file transfer.


SECURECRT and Xshell support. You need to install the LRZRZ command:


Yum-y Install Lrzsz


Uploading Files to Linux:


Rz


It would be nice to lose the return to the RZ.



To download a file to Windows:


SZ filename


SZ plus the file name, it will pop up the interactive interface.



Linux Learning (10) Find command, linux file suffix name, Linux and Windows file transfer


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.