Linux file types and operations

Source: Internet
Author: User

First, File Type

1. The Linux file type is as follows:

2, there are many types of Linux files, different file types represent special meaning, use the following command to view the file type:

[[email protected] ~]# ls-l # The first character represents the file type

Total 108

- RW-------. 1 root root 1555 Jul 17:38 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4096 Jul 10:24 Desktop

[[email protected] ~]# file anaconda-ks.cfg

Anaconda-ks.cfg:ascii 中文版 Text

[[email protected] ~]# file desktop/

desktop/: Directory

Second, the file operation

1. View

Cat: Connect text to display on standard output

-e--show-ends Show Terminator $

[Email protected] test]# cat-e 1.txt

one$

two$

three$

-E: Equals-ve

-V: Show nonprinting characters

-N: Show each line sequentially numbered

[Email protected] test]# cat-n 1.txt

1 One

2

3 Three

-S: Merge multiple contiguous blank rows to display a blank line

Moe only supports backward flipping

Less supports front and rear rollover

The first 10 rows are displayed by the head

Tail Display the following 10 rows by default

TAC Reverse Display file

2. Copy

Cp

-R: Recursive

[[email protected] test]# cp-r/tmp/test//tmp/yx/Copy the test file directory to the YX directory

[[email protected] test]# cp-r/tmp/test/*/tmp/yx/Copy all files from the test file directory to the YX directory

-I: Hints, interaction

-F: Forced override

-A:-DR retains all file information after copying, including the owner and owner group

-D: When the source is a connection file, copy the linked file itself, not the source file pointing to

-P: Maintain the original property, similar to the –a function

3. move, cut

Mv

[Email protected] test]# mv/home/test01/test.txt. Move the Test.txt file to the current directory

4. Delete

Rm

Interactive hints are available by default

[Email protected] test]# RM 1.txt

Rm:remove regular file ' 1.txt '? Y #你输入y确认删除, enter n negative delete

-RF: Forcibly deleting a non-empty file directory or file

[Email protected] test]# RM-RF 1.txt

5. Create

Touch creates an empty file, modifies the timestamp

[email protected] test]# Touch testfile.txt

-T: Specify timestamp

-A: Modify access time only

M: Modify only modified time

[Email protected] test]# Touch-at 201905050505.05 1.txt

[Email protected] test]# TOUCH-MT 201905050505.05 1.txt

6. Meta Data Properties

Stat

[Email protected] test]# stat 1.txt

File: ' 1.txt '

size:0 blocks:0 IO block:4096 Regular empty file

device:802h/2050d inode:1572945 links:1

Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)

access:2011-05-05 05:05:05.000000000 +0800

modify:2019-05-05 05:05:05.000000000 +0800

Change:2017-07-26 17:17:48.302402935 +0800

7. View File Types

File

[[Email protected] test]# file 1.txt

    1. Txt:ascii text

8. Text Editor

Nano functions like the Windows Text Editor, easy to operate

VI Powerful text editor for complex operation

Vim VI upgrade version

Third, file directory operation

1 , view

-A: Show all files, including hidden files

[Email protected] test]# ls-a

.  .. 1 1.txt 2 2.txt A3 A3.txt

-L: Long format display

File type permissions hard-link number belongs to the primary group last modified time file name, original file

[Email protected] test]# ls-l

Total 12

Drwxr-xr-x 2 root root 4096 Jul 26 16:04 1

-rw-r--r--1 root root 0 Jul 16:04 1.txt

Drwxr-xr-x 2 root root 4096 Jul 26 16:04 2

-rw-r--r--1 root root 0 Jul 16:04 2.txt

Drwxr-xr-x 2 root root 4096 Jul 16:04 A3

-rw-r--r--1 root root 0 Jul 16:04 a3.txt

-D: Displays the properties of the directory itself, usually in conjunction with-l

[Email protected] test]# ls-ld/tmp/test

Drwxr-xr-x 5 root root 4096 Jul 16:13/tmp/test

-r: Enables reverse display

[Email protected] test]# Ls-r

A3.txt A3 2.txt 2 1.txt 1

-R: Recursive display

[Email protected] test]# ls-r/tmp/test/

/tmp/test/:

1 1.txt 2 2.txt A3 A3.txt

/TMP/TEST/1:

/TMP/TEST/2:

/TMP/TEST/A3:

-i:inode, index node

[Email protected] test]# ls-i 1.txt

1572866 1.txt

-H: The file size is displayed in human readable format and is usually used in conjunction with-l

[Email protected] test]# LS-HL

Total 12K

Drwxr-xr-x 2 root root 4.0K Jul 26 16:04 1

-rw-r--r--1 root root 0 Jul 16:04 1.txt

Drwxr-xr-x 2 root root 4.0K Jul 26 16:04 2

-rw-r--r--1 root root 0 Jul 16:04 2.txt

Drwxr-xr-x 2 root root 4.0K Jul 16:04 A3

-rw-r--r--1 root root 0 Jul 16:04 a3.txt

2. Create

Mkdri

3. Delete

Mmdir can only delete empty files directory, if the directory has files can not be deleted

Linux file types and operations

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.