Linux Common Command Reference

Source: Internet
Author: User
Tags uicontrol

Ls
    • Description

    • Example

Description

Lists the contents of the catalog.

Example
    1. Lists all files under the current directory whose names begin with S, sorted by date.

      # ls-ltr s*

    2. The details of all the files in the "/bin" directory are listed in detail.

      # Ls-lr/bin

Cd
    • Description

    • Example

Description

Directory switching commands, using the following:

    • After the CD directory name is omitted, switch to "home directory", which is the directory where the current user is logged in.

    • Adding "~" to the CD also means switching to "home directory".

    • After CD add "." Represents the switch to the current directory.

    • After CD add "..." Represents the switch to the previous level directory of the current directory.

Example
    1. Switch to the "/usr/bin/" directory.

      # Cd/usr/bin

    2. Switch to your own "home directory".

      # CD ~

Vi
    • Description

    • Example

Description

The VI Editor is a powerful, user-friendly editor in Linux systems. The VI command has two modes of operation:

    • Edit mode

      The mode used to input and output files, the user's typing information is displayed, and the text content can be written to the file.

    • Instruction mode

      The mode used to edit, save, and exit a file, the typed command is not displayed on the screen, and any characters you enter are treated as instructions.

After running VI , first enter the instruction mode. If you switch from instruction mode to edit mode, you can press the "Insert" key, or you can press the "ESC" key if you switch from edit mode to instruction mode. For specific editing commands, see VI Editor.

Example

Edit The file "123.txt".

# VI 123.txt

Rm
    • Description

    • Example

Description

Delete files and directories.

Example
    1. Delete all files with the suffix named ". C" and confirm each one before deleting.

      # rm-i *.C

    2. Completely delete the "finished" directory and all content in that directory.

      # Rm-r finished


Mv
    • Description

    • Example

Description

Move or rename a file or directory.

Example
    1. Rename the file "123.txt" to "456.txt".

      # MV 123.txt 456.txt

    2. Move all files with the suffix ". C" to the "finished" directory.

      # mv-i *.c finished

Mkdir
    • Description

    • Example

Description

Create a directory.

Example

Create a subdirectory "File2" under the "File1" directory.

# mkdir-p File1/file2

650) this.width=650; "src=" "/> Description:

When the command is executed, " file1" and its subdirectories "File2"are created at the same time if the "file1" directory does not exist.

Cp
    • Description

    • Example

Description

Copy the file or directory.

Example
    1. Copy the "123.txt" file and name it "456.txt".

      # CP 123.txt 456.txt

    2. Copy all files with the suffix ". C" to the "finished" subdirectory.

      # CP *.c finished

Cp
    • Description

    • Example

Description

Copy the file or directory.

Example
    1. Copy the "123.txt" file and name it "456.txt".

      # CP 123.txt 456.txt

    2. Copy all files with the suffix ". C" to the "finished" subdirectory.

      # CP *.c finished

Cat
    • Description

    • Example

Description

Create, read, merge, overwrite, and add file content.

Example
    1. View the contents of the "file1" file.

      # cat File1

    2. Enter the "file2" file after the contents of the "file1" file are added to the line number.

      # cat-n File1 > File2

    3. Append the contents of the "File1" and "File2" files to the "File3"after adding the line numbers.

      # cat-b file1 file2 >> file3

Find
    • Description

    • Example

Description

Find the command to find his absolute path based on information such as the file name or the time it was created.

Example
    1. Lists all files and their absolute paths with the suffix named ". C" under the current directory and its subdirectories.

      # Find-name *.C

    2. Lists all files whose owner is "root" and their absolute paths under the current directory and its subdirectories.

      # Find-user Root

    3. Lists all files and their absolute paths that have been updated in the current directory and its subdirectories for the last 20 minutes.

      # find-ctime-20

Less
    • Description

    • Example

Description

The file Content Browse command. Allow users to page back and forth, press "Q" key to exit browsing.

Example

Browse the contents of the "/opt/123.txt" file.

# Less/opt/123.txt

Chown
    • Description

    • Example

Description

Change the owner and owning group of the file.

Example

Change the "123.txt" file owner to "user1"and change the group to " root".

# chown User1:root 123.txt

chmod
    • Description

    • Example

Description

Change permissions for a file or directory.

chmod has the following three uses:

    • # chmod [Options] ... [mode, Mode] ... File or directory ...

    • # chmod [Options] ... [octal mode] file or directory ...

    • # chmod [Options]--reference= reference file or directory file or directory ...

The options include the following:

    • -C, if the permissions of the file or directory have actually changed, the change action is displayed.

    • -F, do not display an error message if the permissions of the file or directory cannot be changed.

    • -V, which shows the details of the change in permissions.

    • -R, the same permission changes for all files in the current directory as subdirectories (i.e., recursively changing one by one).

    • --help, displays the auxiliary instructions.

    • --version, displays the version.

The pattern consists of three parts: [Ugoa][+-=][rwxxstugo]. The meanings of each parameter are as follows:

    • A u-user that represents the owner of a file or directory.

    • A g-group that represents the group to which the file or directory belongs.

    • O-other, which means that other users are in this range, except for the file or directory owner or group in which they belong.

    • A-all, which represents the entire user, including the owner, the owning group, and other users.

    • +, which indicates increased permissions.

    • -, which means cancel the permission.

    • =, which indicates a unique set of permissions.

    • R, Read permissions.

    • W, writable permission.

    • X, execute permissions.

    • X, only if the file or directory is a subdirectory or sub-file, or the file or directory has been set to be executable.

    • S, special.

Example
    1. Set the "file1.txt" file to be readable by everyone.

      # chmod Ugo+r file1.txt

    2. "File1.txt" and "File2.txt" are set to the owner of the file, and the same group that they belong to can write to, but others are not writable.

      # chmod ug+w,o-w file1.txt file2.txt


Linux Common Command Reference

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.