Linux Common commands

Source: Internet
Author: User

1. System commands

[tab]: command completion, file completion

    1. Double-click 2 to list all possible commands or filenames

[Ctrl]+c Abort command

[Ctrl]+d keyboard input end or replace exit

Shutdown-h shut down after service is stopped

-R Restart after service is stopped

Reboot restart

Init 0 shutdown

3 Pure command line mode

5 includes graphical interface mode

6 restart

Stat Displays details of the specified file, more detailed than LS

Who shows online login

WHOAMI Show current Operation user

Hostname Display host name

Uname Display System Information

Top dynamic display currently consumes the most resources process information

PS Display transient process status Ps-aux

Du view directory size Du-h/home with units display directory information

DF View disk size df-h with unit display disk information

Ifconfig Viewing network conditions

Ping Test network connectivity

Netstat Displaying network status information

Clear Clear Screen

Alias renamed the Command as: Alias showmeit= "Ps-aux", in addition to de-use Unaliax Showmeit

Kill kills the process, you can first view the process ID with the PS or Top command, and then kill the process with the kill command.

2. Permissions and directories

Groupadd [groupname] adding user groups

Groupdel [groupname] Deleting a user group

Viewing user groups in/etc/group can be viewed using the Cat/etc/group command

useradd [param] [username] Add user

The parameters are as follows:

-C Comment Specifies an annotative description.
The-D directory specifies the home directory, and if this directory does not exist, it can be created by using the-M option.
The-G user group specifies the user group to which the user belongs.
-G user Group, user group specifies the additional group to which the user belongs.
-S Shell file specifies the user's login shell.
-u user number specifies the user 's user number, and if you have the-o option, you can reuse the other user's identification number.
-P This command is required to provide MD5 code encryption password, the ordinary number is not.

Userdel [param] [username] Delete User

usermod [param] [username] (only the ultimate administrator has permission to modify the account name, if you use the sudo command to authorize the normal account) to modify the user

The/etc/passwd file is one of the most important files involved in user management work. Each user in the Linux system has a corresponding record line in the/etc/passwd file, and he records some basic attributes of the user.

CHGRP [-R] [dirname/filename] Changing the file user group

-R for Recursion

Chown Changing the file owner

chmod changing file permissions

To change the permissions method:

① Number Types Change permissions

The syntax is: chmod ABC file
Each of the a,b,c is a number that represents the permissions of the user, Group, and other respectively.
R=4,w=2,x=1
To rwx the attribute then 4+2+1=7;
To rw-the attribute then 4+2=6;
To r-x the property, 4+1=7.

② Symbol Type Change permissions

Mode: Permission set string in the following format: [Ugoa ...] [[+-=][RWXX] ...] [,...], where
U represents the owner of the file, G means that the owner of the file belongs to the same group (group), and O indicates that the other person, a means that all three are.
+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions.
R is readable, w means writable, x is executable, x means only if the file is a subdirectory, or the file has been set as executable.
-C: If the file permissions have changed, the change action will be displayed
-F: Do not display an error message if the file permissions cannot be changed
-V: Show details of permission changes
-r: The same permissions change for all files in the current directory and subdirectories (that is, they are changed in a recursive manner)

3. File and Directory Management

LS Display file or directory

-l list File details L (list)

-a lists all files and directories under the current directory, including Hidden A (all)

mkdir Creating a Directory

-P Create directory, if no parent directory, create p (parent)

CD Switch Directory

Touch creates an empty file

PWD Displays the current directory

mkdir Creating a Directory

-M configuration file permissions

-P Recursive creation

RmDir Delete Empty Directory

-P is removed along with the upper empty directory

Example: Rmdir-p/test1/test2/test3/test4 These directories will be deleted if they are empty.

Echo creates a file with content.

Cat View File Contents

CP Copy

MV Move or rename

RM Delete File

-R Recursive Delete, can delete subdirectories and files

-F Force Delete

Find searches a file system for a file

WC statistics Text line number, word count, number of characters

Grep finds a string in a text file

RmDir Delete Empty Directory

Tree structure display directory, need to install tree package

PWD Displays the current directory

LN creates a linked file

More, less pagination displays text file contents

Head, tail display file header, tail content

CTRL+ALT+F1 command line full-screen mode

File View Files Type

Packaging compression-related commands

Gzip:

BZIP2:

Tar: Packaging compression

-C Archive File

-X Compressed file

-Z gzip Compressed file

-j bzip2 Compressed Files

-V shows the compression or decompression process V (view)

-F Use file name

Cases:

TAR-CVF/HOME/ABC.TAR/HOME/ABC only packaged, not compressed

TAR-ZCVF/HOME/ABC.TAR.GZ/HOME/ABC packaged and compressed with gzip

TAR-JCVF/HOME/ABC.TAR.BZ2/HOME/ABC packaged and compressed with bzip2

Of course, if you want to decompress, just replace the above command TAR-CVF/TAR-ZCVF/TAR-JCVF "C" in the "X".

VI command

"H (or left ARROW key)" Cursor moves left one character
"J (or DOWN arrow)" Cursor moves down one character
"K (or Up ARROW key)" Moves the cursor up one character
"L (or right ARROW key)" Cursor moves right one character

"[Ctrl] + F" screen moves down one page (equivalent to page DOWN key)
"[Ctrl] + B" screen moves up one page (equivalent to page UP key)

"[0] or [Home]" cursor moves to the front of the current line
"[$] or [end]" cursor moves to the end of the current line

The "G" cursor moves to the last line of the file (at the first character)
"NG" N is a number (hereinafter), moving to the nth row in the current file
"GG" moves to the first line of the file, equivalent to "1G"
"N[enter]" cursor moves down n rows

"/word" finds a string in a file with Word (look down)
"? Word" finds a string in a file that contains word (look up)
"[n]" means a duplicate lookup action, which is to find the next
"[N]" reverse lookup next
": n1,n2s/word1/word2/g" N1, N2 as numbers, find N2 string between line N1 and Word1 line and replace it with WORD2
": 1,S/WORD1/WORD2/G】FromTheOneYes(TheNYesWithActing)ToMostAfterOneYesCheckFindWORD1NoteBook,AndWillIts change Wor d2 ":1 s/word1/word2/g "From the first row (nth line) to the last line to find word1 registration, and replace it with Word2": 1,s/word1/word2/gc "function as above, except that each time the user will be confirmed

"X,x" x deletes a character backwards, equivalent to [Delete],x deletes a character forward, equivalent to [Backspace]
"DD" deletes the entire line where the cursor is located
"NDD" Removes the downward n-line of the cursor

"YY" the line where the cursor is copied
"Nyy" Copy the down-n line where the cursor is located
"P,p" p to paste the copied data on the next line of the cursor; p to paste the data that has already been copied on one line of the cursor

"U" undoes the previous action
"[Ctrl] + R" undo multiple times
"." This is the decimal key, repeat the previous action

(v) operation of the general mode switch to edit mode
1. Enter insert mode (6 commands)
"I" is inserted from the current cursor location
"I" from the current cursor
"A" inserts from the next character where the current cursor is located
"A" starts inserting at the last character of the line where the cursor is located
"O" English lowercase o, insert a new line at the next line where the cursor is currently located and start inserting
"O" English capital letter O, insert a new line at the top of the line where the cursor is currently located and start inserting

2. Enter replacement mode (2 commands)
"R" replaces only the one character where the cursor is located once
"R" will always replace the character of the cursor until the [ESC] key is pressed
"[ESC]" exit edit mode back to normal mode

(vi) General mode switch to command line mode
": W" Save file
": w!" If the file is read-only, force the file to be saved
": Q" Leave VI
": q!" does not save forced departure VI
": Wq" left after saving
": wq!" forced to leave after saving
【:! Command "Temporarily leaves VI to the command line after executing a command to display the result
": Set nu" Displays line numbers
": Set Nonu" to suppress line numbers
": W newfile" Save As
": Set fileencoding" View the current file encoding format
": Set Fileencoding=utf-8" Sets the current file encoding format to Utf-8, or can be set to another encoding format
": Set FileFormat" To view the current file's break format (Dos\windows,unix or Macintosh)
": Set Fileformat=unix" Formats the current file in the form of a UNIX format

Linux Common commands

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.