Simple and practical use of Linux commands

Source: Internet
Author: User
Tags create directory grep regular expression parent directory

1.linux directory Structure

/etc: (ETCETERA): The directory where the system configuration file resides. It is not recommended to store executables under this directory. Important configuration files are, for example.

/usr: (Unix shared resourced) applications store directories,/usr/bin store applications,/usr/share store shared data,/usr/lib store cannot run directly, but are some library files necessary for many programs to run. /usr/local: Store the software upgrade package. /usr/share/doc: System description file storage directory. /usr/share/man: Program description file directory, when using man LS will query/usr/share/man/man1/ls1.gz.

/root: Home directory for system administrator root.

2. Disk Management common commands:

LS (list): List Directory contents

-A: Queries all files and folders, including hidden.

-L: Detailed list.

The parameters in the Liux command are generally unordered except for special cases.

-H: Friendly display.

Ls-l abbreviated to LL.

Specific details can be viewed using the man LS. You can use the Man command to view the commands in detail.

CD (change directory) feature: Switch directory

Syntax: cd "directory"

CD ~: Current User home Directory

CD/: Root directory

CD/directory Name: Any directory switch to the specified directory,/directory name the absolute path of Linux

CD-: The directory that was last accessed. You can only switch between two directories, which is equivalent to the back of the Windows system.

mkdir (Make Directoriy) feature: Create directory

Mkdir-p folder name

-P Parent Directory does not exist, Sir into the parent directory (parents)

Need to create a T2 directory under the/ROOT/T1 directory

Location:/root

Command: relative: mkdir t1/t2

Absolute: Mkdir/root/t1/t2

You need to create a T directory under the current file condition: both T3 and T4 do not exist.

Command:

Mkdir-p T3/T4

RmDir (remove directory) command:

3. File Browse command

The cat file name quickly views the current file contents. (Cat is a good place to view a small amount of information.)

More File Name page shows the contents of the files

Operation

Enter down n rows, which need to be defined, default to 1 rows.

Space bar scroll down one screen or ctrl+f

B return to previous screen or ctrl+b

Q Exit More

LESS-MN File Name page displays the contents of the files, labeling the line numbers of each line

Operation

Enter down n rows, which need to be defined, default to 1 rows.

Space bar scroll down one screen or ctrl+f

B return to previous screen or ctrl+b

Q Exit Less

Tail-A digital file name allows you to quickly see the contents of the X line after the file

For example: tail-10 the file name to view the contents of the X line.

4. File Operation commands

CP (copy)

Location where the CP needs to copy the copied files

Requirements: Copy the/root/demo1.java to the/ROOT/T1 directory

Location:/root

Command: CP demo1.java/root/t1

Cp/root/demo1.java/root/t1

Requirements: Copy the/root/demo1.java to the/ROOT/T1 directory and change the name to Ddd.java

Location:/root

Command: CP Demo1.java T1/ddd.java

Copy Directory

-R: Recursively handles all files in this directory and directory.

Cp-r the location of copied files

MV Command

MV (move) function: Moving or renaming an existing file or directory

Syntax: mu [source file or directory] [destination file or directory]

-F If the destination file or directory is duplicated with an existing file or directory, overwrite the existing file or directory directly

The location of the MV moved file movement

Rename Operation:

Requirement: Renaming 1.java to 2.java

MV 1.java 2.java

The name of the MV is dependent on a move, moved to the original directory, and renamed.

RM command

RM (remove) Feature: Delete files or directories

-F: Forcibly delete files or directories,-r: Recursive processing the files and subdirectories under the specified directory.

Delete file RM file name

Remove Directory RM-RF directory name

Note: RM-RF * Delete all content in the current directory

RM-RF/* Delete all contents of Linux system root directory

Find command: function to locate files or directories

Syntax: Find directory name-name ' string to find

* Denotes 0 ~ to more than one character

Requirements: Find all files or directories in the/root directory that begin with INS

Command: Find/root ' ins* '

Vim command

grep and piping

grep regular expression, string search work

Format: Grep-i search for a string of files that need to be searched

-I ignores case lookup data

Pipeline: | You can connect a lot of commands to it.

such as: LL | grep T finds but the current directory, all row data with the keyword T

Compress, unzip command "important"

Linux Compressed package: *.tar Packaging, size is not compressed.

*.tar.gz package, and compress the file size.

Simple and practical use of Linux commands

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.