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

External commands for manipulating files and directories in Linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1 、 file

File attributes:

-: ordinary files

D: catalog file

B: block equipment

C: character device file

L: symbolic link file

P: command pipeline

S: socket file

2 、 ls

Show catalog contents

-l: display file properties, ls-l=ll

-h: do the corresponding unit conversion display

-a: show all files

-A: show. And... All the files I thought

-d: displays the properties of the directory itself

-I: displays the miniature contact number of the file (index node, inode)

-r: displays the list of files in reverse order

-R: recursively display files

3 、 cd

Switch directories

Cd returns to the user's home directory

Cd ~ username: enter the specified user's home directory

Cd -: switch back and forth between the current directory and the previous directory

Cd..: switch to its parent directory

Cd / home enter the'/ home' directory'

4 、 pwd

Show current path

5 、 touch

Create and update empty files

-c: the file is not created when it exists

-a: only change the access time of the file

-m: only change the modification time of the file

-t: set the time stamp of the document (year, month, day and hour). Seconds), used in conjunction with an and m

6 、 mkdir/rmdir

Mkdir: create a directory

Rmdir: deleting a directory

-p: recursive creation

-V: display creation information

7 、 rm

Delete a file

-I: interactive deletion

-f: violent deletion

-r: recursive deletion

Commands can be combined and used

8 、 cp

Copy a file

-r: recursively copy directories

-I: interactive display replication

-f: force copy, overwrite

-p: retain the attributes of the source file, timestamp

-a: retain all attributes of the source file

-P: save as a link when copying a linked file (the default is to copy the file that the link points to)

-d: keep the link when copying

-a: archive replication, common use and backup

# cp / etc/passwd / tmp/ copy to the directory and save the original file name

# cp / etc/passwd / tmp/test to see whether test is a file or a directory, directory: copy to a directory

The file is replaced!

9 、 mv

Move or rename a file

Mv SRC (source) DEST (destination)

Mv can be used to rename the target source in a unified directory: mv abc bcd or mv-t

10 、 ln

Create a linked file

Ln SRC DEST: creating hard links

-s: create a soft connection

-I: displays the inode number of the file

-v: displays the execution result

Hardware connection:

1. Files can only be created, but cannot be applied to directories. The number of hard links to files is 2.

2. Do not praise the file system

3. Creating a hard link will increase the number of times the file is connected

Soft connection:

1. Can be applied to the directory

2. Cross file system

3. It will not increase the number of connections to the connected files

4. Its size is the number of characters contained in the specified path

11 、 du

Displays the size of all files in the directory

-s: displays the directory size

-sh: display after unit conversion

12 、 wc

Text statistics

-l: show only the number of rows

-w: displays only the number of words

-c: show only the number of bytes

-L: displays how many characters the longest line contains

13 、 sort

Sort the display file

-n: arrange from small to large according to numerical value

-r: sort in descending order

-t: specify the field delimiter

-k: which character to start with is to specify the keyword arrangement.

-u: the same line is displayed only once

-f: ignore character case

14 、 tree

Displays the tree structure of files and directories starting from the root directory

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