Linux Common Command collation

Source: Internet
Author: User

File, Directory Class

File view, processing

Cat file # Displays the contents of the file

Cat-n File # Displays the number of line numbers

Cat file1 file2 > File3 # Merge the contents of the file File1 and file2 into the new file File3

Head File # Displays the first 10 lines of the file

Tail file # Displays the last 10 lines of the files

Tail-f File # Displays the latest additions to files and monitors file changes, often used to track log files

More file # based on the VI Editor text filter, which displays the contents of a text file on a full-screen basis

Less file # Functions much like more, PageUp page UP, PageDown page down, press Q to exit

Cat file1 > File2 # Overwrite Import

Cat file1 >> File # Append Import

wc-l [-m][-c][-w] File # count rows, characters, bytes, number of words

File query, search

grep KeyWord # using cat file with cat or other commands | grep KeyWord

Find Dir-name "*.log" # Search for files with the suffix. Log in the specified directory

Find Dir-name "*.log"-o-name "*.pid" # Search for ". Log" Files and ". pid" files in the specified directory

Find Dir-user User1 # Search for files belonging to User1 users in the specified directory

Text edit Vi/vim Bottom row mode

: Set Nu # Displays line numbers

: Set Nonu # does not display line numbers

: N # jumps to the specified nth row

: W File # Save As

: N1,n2 s/str1/str2/g # from N1 line to N2 line, replace str1 with STR2 (from beginning to end 1,$ s/str1/str2/g)

: Wq # Save and exit

: q! # Force quit does not save

Text Edit Vi/vim Command mode

G # to the last line (Shift + g)

GG # to First line

DD # Delete rows or cut rows

U # Undo

Y # When you select a piece with V mode, copy the selected block to the buffer with

YW # Copy a word (NYW or ynw, copy n word,n to numbers)

YY # Copy a row

Nyy # copy n rows down

P # Paste

Rights Management

chmod 755 Dir/file # Modify permissions for specified files and folders

Chmod-r 755 dir # recursively modifies permissions for directories and their sub-files, directories

Chown user File # To change the owner of files

Chown-r User dir # to change the owner of the directory

Chgrp group1 File # change the owner

Chgrp-r group1 dir # change the owning group of the directory

Chown user1:group1 File # Changes both the owner and the owning group

Chown-r user1:group1 dir # simultaneously changes the owner and owning group of the directory

WHOAMI # View Current action user

Who # View users who are currently logged on to the system

ID User1 # View user User1 's attribution ID information

Compression, decompression

TAR-CVF Test.tar Test.log # package only, do not compress

TAR-XVF Test.tar # Direct unpacking

TAR-ZCVF test.tar.gz Test.log # After packing, compress with gzip

TAR-ZCVF test.tar.gz * # Compresses all the files in the current directory

TAR-ZXVF test.tar.gz # Direct Decompression

TAR-ZXVF test.tar.gz-c dir # unzip to the new directory, only Dir and already exists

Zip Test.zip * # compresses all files in the current directory into zip packages

Unzip Test.zip # Unzip Zip package

User Management

Groupadd group1 # Create a user group

Groupdel group1 # Delete a user group

Groupmod-n group2 group1 # group1 Rename group2

Useradd User1 # Create user

Useradd-g group1 User1 # Create User1 and assign it to group1 group

Userdel-r User1 # Delete user1, "-r" parameter means also delete related directory in home directory

Usermod-g group2 User1 # change User1 group to Group2

Usermod-g group2 User1 # adds User1 to the Group2 group while preserving the original primary group

passwd # Modify the current user password

passwd User1 # Modify the password of the User1 user only for root user execution

Su User1 # switch to user user1

Groups User1 # View the group that the user User1 belongs to

View command Help

Help CD # for internal commands such as exit, History, CD, ECHO, etc. resident memory

LS--help # is primarily used for external commands, and you can view the storage path for external commands, such as LS,VI, via the Echo $PATH command

Man ls # command manual, available for all commands, enter "Q" to exit

Type cd # view command type, internal or external, and command location

System-related commands

Shutdown-h now # shut down immediately

Shutdown-r Now # Restart immediately

Uname-r # View Kernel version

Cal # Calendar

Date # time, date

Date-s "2015-12-22 08:00" # Modify Time

Ntpdate time.nist.gov # Synchronizing the current time

History # View Historical command record, runtime "!" + command number, such as!123 run the command number 123

PS-EF # Viewing processes

Kill PID # Terminate process

Kill-9 PID # forced termination process

Top # View current system Resource Usage

DF-H # Viewing disk information

FREE-M # Viewing memory information

Du-h File/dir # View a single file/directory Size-H representation to K,m,g

Du-sh File/dir # View File/directory Total size

Mount-o Loop Linux.iso/mnt/dir # Loading the file system to the specified mount point

Umount/mnt/dir # Uninstalling a file system that has already been loaded

RPM-IVH xxx.rpm # Install RPM Package

Rpm-e xxx.rpm # unload RPM Package

Yum Install XXX # installation package xxx

Yum Remove XXX # remove installed XXX

wget http://xxxx # Download the remote ZIP package

echo ' > XXX # empty XXX file contents

Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source. Internet + times, always want to keep learning, together with the thousand front php,dream It Possible.

Linux common commands collation

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.