A Brief Introduction to the Linux Command-find

Source: Internet
Author: User
Tags printable characters

The following describes the 60 required Linux commands that must be mastered by new users. If you have mastered these commands, your technology will be greatly improved, we hope that the technology will be greatly improved after reading this article.

Dd
1. Role
The dd command is used to copy files and convert and format data according to parameters.
2. Format
Dd [options]
3. [opitions] Main Parameters
Bs = byte: Forced ibs = and obs =.
Cbs = byte: specified for each conversion.
Conv = Keyword: convert a file by using a comma-separated keyword.
Count = number of blocks: only the specified input data is copied.
Ibs = byte: Read the specified value each time.
If = file: Read content, not the data of non-standard input.
Obs = byte: specify each write.
Of = file: write data, not displayed in standard output.
Seek = number of blocks: first, the specified output data in obs is skipped.
Skip = number of blocks: first, the specified input data in ibs is skipped.
4. Application Instance
Dd commands are often used to create Linux boot disks. First find a bootable kernel, point its root device to the correct root partition, and then use the dd command to write it to the floppy disk:
$ Rdev vmlinuz/dev/hda
$ Dd if = vmlinuz of =/dev/fd0
The code above indicates that the rdev command directs the root device in the kernel vmlinuz to/dev/hda. Replace "hda" with your own root partition, run the dd command to write the kernel to a floppy disk.
Find
1. Role
The find command is used to search for files in a directory. It has the permission to all users.
2. Format
Find [path] [options] [expression]
Path specifies the directory path. From here, the system looks down the file in the directory tree. It is a path list separated by spaces. If path is not written, the current directory is used by default.
3. Main Parameters
[Options] parameters:
-Depth: uses the depth-level search process to prioritize file content in a specified directory at a layer.
-Maxdepth levels: the level-level subdirectory of the Start directory. Level is a non-negative number. If level is 0, it indicates that it is only searched in the current directory.
-Mindepth levels: indicates that at least the level subdirectory of the Start directory is found.
-Mount: Does not search for directories and files in other file systems, such as Msdos and Vfat.
-Version: print the version.
[Expression] is a matching expression accepted by the find command. All operations of the find command are for the expression. It has many parameters. Here we only introduce some common parameters.
-Name: The wildcard * And? are supported ?.
-Atime n: searches for files read in the past n days.
-Ctime n: searches for files modified in the past n days.
-Group grpoupname: searches for all grpoupname files in the group.
-User name: searches for all files whose owner is the user name ID or name.
-Size n: the size of the search file is n blocks.
-Print: outputs and prints the search results.
4. Application Skills
Find command to find files:
1) Search by file name
For example, to find a file named lilo. conf, run the following command:
Find/-name lilo. conf
"/" After the find command indicates searching the entire hard disk.
2) Quick file search
Root
It may take a long time to find files by file name, especially when large Linux file systems and large-capacity hard drive files are placed in a deep subdirectory. If we know
This file is stored in a directory, which saves a lot of time as long as you search for it. For example, the smb. conf file can be determined by its file suffix ". conf ".
Set the file, it should be in the/etc directory. At this time, you can use the following command:
Find/etc-name smb. conf
In this way, the "quick file search" method can shorten the time.
3) searching based on some file names
Sometimes we know that only one file package contains the four characters of abvd. To find all the files containing the four characters in the system, run the following command:
Find/-name '* abvd *'
After entering this command, the Linux system will find all the files containing the four characters abvd in the/directory, where * is a wildcard ), for example, all files that meet the conditions, such as abvdrmyz, can be displayed.
(4) Searching for files using hybrid search
The find command can use a hybrid search method. For example, we want to search for a file larger than 500000 bytes in the/etc directory and modify it within 24 hours, you can use-and (and) to link two search parameters into a hybrid search method.
Find/etc-size + 500000c-and-mtime + 1
Mv
1. Role
The mv command is used to rename a file or directory, or move the file from one directory to another. Its permission is granted to all users. This command is like a combination of ren and move in the doscommand.
2. Format
Mv [options] source file or directory target file or directory
3. [options] Main Parameters
-I: interactive operation. If the mv operation will overwrite the existing target file, the system will ask whether to rewrite the file and ask the user to answer "y" or "n" to avoid overwrite the file by mistake.
-F: Disable interactive operations. When an mv operation overwrites an existing target file, no indication is given. If this parameter is specified, the I parameter will no longer work.
4. Application Instance
1) Move all files in/usr/cbu to the current directory and use "." To indicate:
$ Mv/usr/cbu /*.
2XX rename the file cjh.txt as wjz.txt:
$ Mv cjh.txt wjz.txt
Ls
1. Role
The ls command is used to display the directory content. Similar to the dir command in DOS, it has the permission to use all users.
2. Format
Ls [options] [filename]
3. Main options Parameters
-A, -- all: Do not hide any items starting with the "." character.
-A, -- almost-all: list any projects except "." and.
-- Author: prints the author of each file.
-B, -- escape: an octal overflow sequence to indicate non-printable characters.
-- Block-size = size: the block is in the specified bytes.
-B, -- ignore-backups: do not list any ~ The project whose character ends.
-F: No sorting is performed. The-aU parameter takes effect and the-lst parameter is invalid.
-F, -- classify: add the file type indicator (*/= @ | one of them ).
-G: like-l, but do not list owner.
-G, -- no-group: inhibit display of group information.
-I, -- inode: List inode numbers of each file.
-I, -- ignore = style: do not print any items that match the Shell universal character.
-K: -- block-size = 1 K.
-L: Used to list information in a long format.
-L, -- dereference: when the file information of the symbolic link is displayed, the object indicated by the symbolic link is displayed, not the information of the symbolic link itself.
-M: All items are separated by commas (,) and the whole row width is filled.
-N, -- numeric-uid-gid: similar to-l, but list UID and GID.
-N, -- literal: List unprocessed project names, for example, not specially processed control characters.
-P, -- file-type: add the file type indicator (/= @ | one of them ).
-Q, -- quote-name: Enclose the project name in double quotation marks.
-R, -- reverse: in reverse order.
-R, -- recursive: Lists All Sub-directory layers at the same time.
-S, -- size: Order the block size.
4. Application Example
Ls
Commands are the most frequently used commands in Linux, and their parameters are also the most frequently used commands in Linux. When you use the ls command, there will be several different colors, where blue indicates the directory, Green indicates the executable
Line files, red indicates compressed files, light blue indicates linked files, bold black indicates symbolic links, and gray indicates other format files. The most common use of ls is ls-l, as shown in figure 1.
Figure 1 use the ls-l command
Text
The start of the component type is a string consisting of 10 characters. The first character indicates the file type. It can be one of the following types:-common files), d directory), l Symbolic Link), and B.
Device File ). The following nine characters indicate the object access permissions. They are divided into three groups, each with three characters. The first group indicates the permissions of the file owner, the second group indicates the permissions of users in the same group, and the third group indicates the permissions of users in the same group.
User permissions. The three characters in each group indicate the read r, write w, and execute permission x ). For a directory, it indicates the access permission. S indicates that when the file is executed, the UID of the file is
Or GID is assigned to the UID user ID of the execution process) or GID Group
ID ). T indicates that the flag is left in the memory and is not swapped out ). If the file is a directory, the files in the directory can only be deleted by the Super User, directory owner, or file owner. If it is executable
After the file is executed, the pointer pointing to its body segment remains in the memory. In this way, the system will be able to mount the file more quickly when you execute it again. The file size, generation time, file or command name is displayed.
Name.
Click mandatory Linux Command File Processing Command 3 below to continue viewing.

Related Article

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.