Common Linux Command set

Source: Internet
Author: User
1. List of the most common commands

The following lists the ten commands that are frequently used in Linux. Here is a brief introduction. For detailed usage, refer to the following content.

Cat: displays the file content.

CD to change the directory path.

CP, copy the file.

Find to find the file.

Grep: Search and filter information.

Ls to list directory information.

More, display by page.

RM: delete a file or directory.

VI: Call the VI text editor.

WHO: displays logon user information.

2. chmod ---- change the access mode of one or more files)

Chmod [Options] mode files

Only file owners or privileged users can use this function to change the file access mode. Mode can be in the digital format or in the WHO opcode permission format. Which is optional. The default value is a (all users ). Only one opcode can be selected ). You can specify multiple modes separated by commas.

Options:

-C, -- Changes

Only output the information of the changed File

-F, -- silent, -- quiet

When the CHMOD mode cannot be changed, the file user is not notified.

-- Help

Output help information.

-R, -- Recursive

Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory

-- Reference = filename

Set the permission by referring to the filename permission.

-V, -- verbose

Whether the modification is successful or not, the information of each file is output.

-- Version

Output version information.

Who

U

User

G

Group

O

Others

A

All users (default)

Opcode

+

Add Permissions

-

Delete permission

=

Reassign Permissions

Permission

R

Read

W

Write

X

Run

S

Set the ID of a user (or group)

T

Sets Sticky Bit to prevent files or directories from being deleted by non-owners.

U

Current User Permissions

G

Current permissions of the Group

O

Current permissions of other users

In most cases, we use three Octal numbers to indicate permissions. The first one is the owner permission, the second is the group permission, and the third is the permission of other users, each permission is determined by the sum of four (read), two (write), and one (execution) values. For example, 6 (4 + 2) indicates that you have the read and write permissions, and 7 (4 + 2 + 1) indicates that you have the read, write, and execution permissions.

You can also set the fourth digit, which is located before the three-digit permission sequence. The fourth digit is 4, 2, and 1, which means the following:

4. Set the user ID during execution to authorize the process based on the file owner, instead of the user who creates the process.

2. Set the user group ID during execution to authorize the process based on the file group, instead of the user who creates the process.

1. Set the adhesion position.

Instance:

$ Chmod U + X file: grant the execution permission to the file owner $ chmod 751 grant the file owner the read, write, and execute (7) permission, assign the read and execute (5) permissions to the group where the file is located, and assign the execution (1) permissions to other users $ chmod u = rwx, G = RX, O = another form of example on X file $ chmod = r file assigns read permissions to all users $ chmod 444 file same as above $ chmod A-WX, A + R in the same example as above $ chmod-r u + r directory recursively assigns read permissions to the owner of all files and subdirectories in the directory $ chmod 4755 sets the ID, assign read, write, and execution permissions to the owner, and assign read and execution permissions to the group and other users.

3. chgrp ---- modify the group to which the file or directory belongs

Chgrp [Options] newgroup files/directorys

The group name can use the group ID or the group name in/etc/group. Only the file owner or privileged user (Root) can change its group.

Options:

-C, -- Changes

Only output the information of the changed File

-F, -- silent, -- quiet

If the file group attribute cannot be changed, users of the file are not notified.

-- Help

Output help information.

-R, -- Recursive

Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory

-- Reference = filename

Set the group of the current file according to the group information of filename

-V, -- verbose

Output details

-- Version

Output version information.

Instance:

$ Chgrp root test: Change the root group of test to the root group $ chgrp-r MySQL test recursively sets the group attributes of the test directory and all files and subdirectories in the directory to MySQL $ chgrp Root * set the group attribute of all files in the current directory to root.

4. chown ---- set the owner identity of one or more files or directories

Chown [Options] newowner files/directorys

The new owner can be the user's ID or the login name in/etc/passwd. Chown can also accept the form newowner: newgroup or newowner. newgroup. Change the attributes of the group. If there is no group name after the periods and colons, the group is changed to the new owner group. Only the current owner of a file or directory has the right to change its attributes.

Options:

-C, -- Changes

Only output the information of the changed File

-- Dereference

Trace Symbolic Link

-H, -- no-Dereference

Change the owner identity of each symbolic chain, rather than the owner identity of the referenced File

-F, -- silent, -- quiet

If the file owner attribute cannot be changed, users of the file are not notified.

-- Help

Output help information.

-R, -- Recursive

Recursively traverse sub-directories and apply modifications to all files and sub-directories in the directory

-- Reference = filename

Change the owner to the owner of the filename file.

-V, -- verbose

Output details

-- Version

Output version information.

Instance:

$ Chown root test improves the root Root test_directory of the test file by recursively changing all file owners in the test_directory directory to root $ chown -- dereference root test_link the original file owner is changed to root, the owner of the linked file remains unchanged $ chown -- no-dereference root test_link: Change the owner of The Link file of test_link to root, and the owner of the original file remains unchanged.

5. Date ---- display and modify the system time

Date [Options] [+ format] [date]

$ Date-s 06/09/2004 modification date (in the format of monthly, daily, and annual) $ date-s 13:56:00 modification time (in the format of hour, minute, and second) $ date-r test shows the last modification time of the test file $ date + '% Y-% m-% d' to display the date in yyyy-mm-dd format, for other formats, see help $ clock-R to query the BIOS time $ clock-W to write the modified time back to the BIOS.

6. df ----- displays the disk capacity status of the installed File System

DF [Options] [name]

$ DF-H outputs the disk capacity status of all installed file systems in a friendly format $ DF-M/home outputs the disk capacity status of the home directory in MB. $ DF-K uses k outputs the disk capacity status of all installed file systems $ DF-I reports idle, used, or partially used (hundreds of ratios) index node $ DF-T ext3 only displays the disk status of the file system whose file type is ext3 $ DF-x ext3 only displays the disk status of the file system whose file type is not ext3 $ DF- t in addition to the size of the file system disk, the file system type $ DF-L is also displayed. Only the local file system is displayed.

7. fdisk ---- Partition Table query tool

Fdisk [Options] [Driver]

$ Fdisk-l list information about all partitions

8. hdparm ---- hard disk management

Hdparm [Options] [Driver]

$ Hdparm-D/dev/hda: Hard Disk DMA mode is not enabled, 1 represents the Write Performance of the hard disk on $ hdparm-Tt/dev/hda test $ hdparm-D1/dev/hda enable the DMA function $ hdparm-D1-x68-C3-M16/dev/ hda options: -C3: Convert the I/O mode of the hard disk from 16 bits to 32 bits. -M16: changed the multi-sector reading function of the hard disk.-M16 enables the hard disk to read data from 16 sectors during an I/O interruption. -D1: Enable the DMA mode. -X68: Data Transmission Mode of ata66 is supported. The following figure compares the settings of other modes with those of ata33 ....... the parameter is-x66 ata66 ....... the parameter is-x68 ata100 ...... the parameter is-x69 $ hdparm-K1/dev/hda.

9. ln ----- create an alias for the file

Ln [Options] sourcename [destname]

Ln [Options] sourcenames destdirectory

$ Ln-s file1 file2 creates a symbolic link to file1 file2. Deleting file2 will not affect file1 $ ln-S-F file1 file2 creating a symbolic link to file1 file2, does not prompt whether to rewrite

10. Shutdown ----- terminate all incoming programs and close the computer.

Shutdown [Options] When [Message]

The when can be the specified shutdown time (in HH: Mm format), the waiting time before shutdown (in + M format), or now. Message indicates that a broadcast message notifies all users to exit the system. Showdown sends a sigterm signal to all processes and calls init 1 to execute the actual shutdown action.

$ Shutdown-C cancel the ongoing shutdown operation $ shutdown-F restart quickly, disable regular calls to fsck upon restart $ shutdown-h stop the system when the shutdown is completed $ shutdown-K output warning information, but disable the actual shutdown. $ shutdown-N execute the shutdown command without calling init. $ shutdown-r restart the system when the shutdown is completed. $ shutdown-T 5 ensure that the system is between killing the process and changing the running level. latency: 5 seconds

11. Sleep ----- waiting time before executing another command

Sleep amount [units]

The default value of units is second (s), M indicates minute, h indicates hour, and D indicates day.

12. Swapon/swapoff ----- start and close swap partitions

Swapon/swapoff [Options] Device

$ Swapon-s displays swap partition information $ Swapon-A activates all Sw-marked partitions in/etc/fstab $ Swapon-P 1 sets the switch partition priority to 1

13. tune2fs ----- adjust the parameters of the second Linux Extension File System

Tune2fs [Options] Device

$ Tune2fs-L/dev/hda1 display the super block content of the hda1 partition $ tune2fs-C 100/dev/hda1 set the hda1 partition to check the disk every mount100 times

14. uniq ---- filter, count, and delete duplicate rows

Uniq [Options] [file1 [files]

$ Uniq-C file: Repeat row output once in file, and the number of repeat times is displayed before each row. $ uniq-D file: Repeat row output once, but no unique row is output. $ uniq-u file only outputs the unique row in the file. $ uniq file1 file2 deletes the duplicate adjacent row in file1 and sends a copy of each row to file2.

15. WC ----- output the number of characters, words, and lines in each file.

WC [Options] [files]

$ Number of lines in the output file of WC-l file $ number of words in the output file of WC-W File $ number of characters in the output file of WC-C file

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.