Linux Study Notes _ 3_common Linux commands _ 1 _ file management commands

Source: Internet
Author: User

Not recommended: Follow books like command book!

There are about 200 Common commands.

File naming rules:

A) All characters except '/' are valid!

B) It is best not to use these characters.

1. space character, Tab character, return character

2. Connector

3. Special symbols: @ # $ & ()-and so on

C) Avoid using. As the start and use. As the start to indicate file hiding.

D) Note: It is case-sensitive, similar to C. Windows is not strictly differentiated.

E)linuxcan have no suffix, such as. EXE.

Command Format:

Command-option Parameter

Ls-la/etc

Note: 1. Multiple options can be written together. // or: ls-a-l/etc.

2. indicates the current directory.

.. Represents the parent directory // returns the parent directory: cd .. // contains spaces

3. The parameter indicates the operation object.

Learning outline:

1. File Processing commands

2. permission management commands

3. file search commands

4. Help commands

5. compression and decompression commands

6. Network Communication commands

7. system switch commands

8. Shell application skills

Note: different command storage directories determine different execution permissions:

Commands that can only be executed by the root user

/Sbin or/usr/sbin

Commands that can be executed by all users

/Bin or/usr/bin

[Most of them ...]

Appendix: Linux binary files refer to a wide range

Most of Linux's directory structures and commands come from abbreviations of English words...

Different file types have different colors, such as binary files: Black, true color; Directory: Blue

File Processing command:

1. ls [list]/bin/ls

Option:-a all

-Llong details

-D directory: view directory Properties

Part 1:

Drwxr-xr-x

D:Mark the file type [d: directory;

-: Binary File;

L: Soft link file link]

Rwxr-xr-x=> Rwx r-x: each three characters in length

R: read Permission

W: write Permission

X: execute execution permission

-: Indicates replacement. This permission is not granted.

There are also three types of users:

1. owner U: user

2. group G: group

3. others O: others

Part 2:

2-number of hard links

Part 3 and 4:

Rootroot 4096

Directory size of the owner's group: The Directory size is not accurate:

In Linux, many data blocks are represented by data blocks. The block size is 512 bytes, but can be adjusted according to the actual application.

Data blocks can be understood as the smallest unit of data storage.

Part 5 and Part 6:

12-0120:52

Time of File Creation or last modification

Part 7

Bin: File Name

2. cd [changedirectory]

Cd [Directory]

E. g. ch // switch to the root directory

Cd .. // switch to the parent directory

3. pwd [printworking directory]/bin/pwd

4. touch: create a file/bin/touch

Touch [file name]

5. mkdir [makedirectories]: create a directory.

Mkdir [directory name] // mkdir/test

// Mkdir test: create a directory in the current directory

6. cp [copy]: copy a file or directory/bin/cp

Syntax: cp-R [source file or directory] [destination Directory]

Cp-R [Copy Directory]

// If the file is copied,-R is not required and the number of files is not limited.

Appendix: Most of the files saved in the etc directory are configuration files.

Ctrl + c: Terminate the program running

7. mv [move]: move the file, rename it/bin/mv // similar to cut or rename

Mv [source file or directory] [target directory]

E.g. mvservers ser // rename

Mv/test/ser/tmp // move

Mv/test/testfile/tmp/file. test // move and rename

8. rm [remove]: delete a file/bin/rm

Rm-r [file or directory]

// Rm can only be used to delete files. to delete a directory, you must add-r, which is sometimes annoying...

// But if you are sure that the file directory should be deleted, add-rf.

// If you do not want to bring up the confirmation information, add the-f option [force], which is not recommended.

* 8.1rmdir is used to delete empty directories, which are not commonly used.

9. cat [concatenateand diplay files]/bin/cat

It is applicable to files whose content is not long.

Cat [file name]

10. more/bin/more

Display file content by PAGE

Command: f or Space Paging

Q or q quit

Enter next line

E.g. more/etc/servies

11. head/bin/head

View the first few lines of a file

Head-num [file name] // 10 rows by default if no number is added

E.g. head-20/etc/servirs

12. tail/bin/tail

View the last few lines of a file

Tail-num [file name]

-F // dynamically display the File Content

13. ln [link]:/bin/ln

Generate a link file.

Syntax: generate a hard link directly without any options

Ln [source file] [target file]

-S [soft] is required to generate soft links.

Ls-s [source file] [target file]

E.g. ln-s/etc/issue. soft // soft link generated to the root directory

Note: the permissions of soft links are special. lrwxrwxrwx // All are rwx.

He is very small, just a symbolic link, with an arrow pointing.

The time value is different from the source file.

It is similar to the shortcut in Windows.

Ln/etc/issue. hard // generate a hard link to the root directory

Note: Apart from different storage locations, all others are the same, such as the same size and time, but they are similar to copy but different. They are synchronously updated!

Therefore, cp has a-p option to save the time value.

Otherwise, cp is similar to the newly generated file.

Different: a) deleting the soft link of the source file cannot be accessed.

The hard link can be accessed again and is the same as the original source file.

B) hard links cannot be cross-file systems or partitions, but soft links do not matter!

Appendix: Why can he synchronize updates?

The ls-I // I [inode] I node is actually a digital identifier, because Linux does not recognize characters! A digital identifier is required for processing anything in Linux.

Therefore, all files must have an I node!

However, hard links have the same I nodes as source files, whileThe kernel only recognizes I nodes!

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.