Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use dd, find and mv commands in Linux system

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "Linux system dd, find, mv commands how to use", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "Linux system dd, find, mv commands how to use" this article.

Dd

1. Action

The dd command is used to copy files and convert and format data based on parameters.

two。 Format

Dd [options]

3. [opitions] main parameters

Bs= bytes: force ibs= and obs=.

Cbs= bytes: specified for each conversion.

Conv= keyword: converts files based on how they are represented by comma-delimited keywords.

Number of count= blocks: only the specified input data is copied.

Ibs= bytes: read the specified bytes each time.

If= files: read content, not standard input data.

Obs= bytes: write the specified byte each time.

Of= file: writes data instead of displaying it in standard output.

Number of seek= blocks: skip the specified output data in obs first.

Number of skip= blocks: skip the specified input data in ibs first.

4. Application example

The dd command is often used to make a Linux boot disk. Find a bootable kernel so that its root device points 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 above code shows that using the rdev command to point the root device in the bootable kernel vmlinuz to / dev/hda, please replace "hda" with your own root partition, and then use the dd command to write the kernel to the floppy disk.

Find

1. Action

The function of the find command is to search for files in the directory, and its permission is for all users.

two。 Format

Find [path] [options] [expression]

Path specifies the directory path, from which the system starts looking down the directory tree for files. It is a list of paths separated from each other by spaces. If you do not write path, it defaults to the current directory.

3. Main parameters

[options] parameters:

-depth: use the depth-level search process to find the contents of files first in a specified directory at a certain layer.

-maxdepth levels: indicates that at most the level subdirectory of the start directory can be found. Level is a non-negative number, and if level is 0, it means to look only in the current directory.

-mindepth levels: indicates that at least the level subdirectory of the start directory is found.

-mount: do not look in directories and files of other file systems (such as Msdos, Vfat, etc.).

-version: printed version.

[expression] is a matching expression, an expression accepted by the find command, and all operations of the find command are directed against the expression. It has a lot of parameters, and only some commonly used parameters are introduced here.

-name: wildcard characters * and? are supported.

-atime n: search for files that have been read in the past n days.

-ctime n: search for files that have been modified in the past n days.

-group grpoupname: search for all files whose group is grpoupname.

-user user name: search for all files that belong to a user name (ID or name).

-size n: search for files whose file size is n block.

-print: output the search results and print them.

4. Application skills

There are several ways for the find command to find files:

(1) search based on file name

For example, if we want to find a file with the file name lilo.conf, we can use the following command:

Find /-name lilo.conf

The "/" after the find command means to search the entire hard disk.

(2) quickly find files

Root

A practical problem with finding files by file name is that it takes quite a long time, especially when large Linux file systems and large hard disk files are placed in deep subdirectories. If we find out,

This file is stored in a directory, so just looking down in that directory can save a lot of time. For example, the smb.conf file, judging from its file suffix ".conf", is a match.

Set the file, then it should be in the / etc directory, at this point you can use the following command:

Find / etc-name smb.conf

In this way, you can shorten the time by using the Quick find File method.

(3) search method according to some file names

Sometimes we know that only one file contains the word abvd, so to find all the files in the system that contain these four characters, enter the following command:

Find /-name'* abvd*'

After entering this command, the Linux system will look in the / directory for all files containing the four characters of abvd (where * is a wildcard), such as abvdrmyz and other eligible files can be displayed.

(4) use hybrid search method to find files.

The find command can use a hybrid lookup method. For example, if we want to find a file in the / etc directory that is larger than 500000 bytes and is modified within 24 hours, we can use-and (and) to link the two lookup parameters together to form a hybrid lookup.

Find / etc-size + 500000c-and-mtime + 1

Mv

1. Action

The mv command is used to rename a file or directory, or to move a file from one directory to another, with permissions for all users. This command is like a combination of ren and move in the DOS command.

two。 Format

Mv [options] Source file or directory destination file or directory

3. [options] main parameters

-I: operate interactively. If the mv operation will result in an overwrite of an existing target file, the system asks whether to rewrite and asks the user to answer "y" or "n" to avoid mistakenly overwriting the file.

-f: interoperability is prohibited. The mv operation does not give any indication when it wants to overwrite an existing target file, and the I parameter will no longer work when this parameter is specified.

4. Application example

(1) move all files in / usr/cbu to the current directory (with "." Represents):

$mv / usr/cbu/ *.

(2) rename the file cjh.txt to wjz.txt:

$mv cjh.txt wjz.txt

Ls

1. Action

The ls command is used to display the contents of the directory, similar to the dir command under DOS, with permissions for all users.

two。 Format

Ls [options] [filename]

Main parameters of 3.options

-a,-- all: do not hide anything with "." The item at the beginning of the character.

-A,-- almost-all: list any items except "." and "..".

-- author: print out the author of each document.

-b,-- escape: represents unprintable characters in octal overflow sequences.

-- block-size= size: the block is in specified bytes.

-B,-- ignore-backups: does not list any items that end with the ~ character.

-f: no sorting,-aU parameter takes effect,-lst parameter is invalid.

-F,-- classify: add an indication of the file type (* / = @ | one of them).

-g:like-l, but do not list owner.

-G-- no-group:inhibit display of group information.

-I,-- inode: lists the inode number of each file.

-I,-- ignore= style: no items that match the Shell universal characters are printed.

-k: namely-- block-size=1K.

-l: lists information in a longer format.

-L,-- dereference: when the file information of a 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 fill the entire line width.

-n,-- numeric-uid-gid: similar to-l, but list UID and GID numbers.

-N,-- literal: lists unprocessed project names, such as no special handling of control characters.

-p,-- file-type: add an indication of the file type (/ = @ | one of them).

-Q,-- quote-name: enclose the project name in double quotes.

-r,-- reverse: in reverse order.

-R,-- recursive: lists all subdirectory layers at the same time.

-s,-- size: in order of block size.

4. Application example

Ls

Command is the most frequently used command in Linux system, and its parameters are also the most frequently used in Linux commands. There are several different colors when using the ls command, where blue indicates a directory and green indicates an executable

Line files, red indicates compressed files, light blue indicates linked files, bold black indicates symbolic links, and gray indicates files of other formats. The most common use of ls is ls- l, as shown in figure 1.

Figure 1 using the ls-l command

Article

The item type begins with a string of 10 characters. Where * * characters represent the file type, which can be one of the following types:-(normal file), d (directory), l (symbolic link), b (block device text)

C (character device file). The next nine characters represent the access to the file, divided into three groups, each with 3 bits. The * group represents the permissions of the master of the file, the second group represents the permissions of the users in the same group, and the third group represents the permissions of the users in the same group.

The permissions of his users. The three characters in each group represent read (r), write (w), and execute permissions (x) to the file, respectively. For directories, entry permissions. S means that when the file is executed, the UID of the file

Or the UID (user ID) or GID (group) assigned by GID to the execution process

ID). T means to set the flag bit (stay in memory and not be swapped out). If the file is a directory, the files in that directory can only be deleted by the superuser, the directory owner, or the file owner. If it is an executable text

The pointer to its body segment remains in memory after the file is executed. This way, when it is executed again, the system can load the file more quickly. This is followed by the file size, generation time, file or command name

Say.

The above is all the contents of this article entitled "how to use dd, find and mv commands in Linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report