Large summary of Linux commands

Source: Internet
Author: User
Tags clear screen function definition system log

From http://elain.blog.51cto.com/3339379/623310

Large summary of Linux commands
------------------------------------------------------------------------------------
Boot command-line mode and graphics mode:
Vi/etc/inittab change to 3 for command line mode 5 for graphic mode

Switch Machine command:
Shutdown init 0 shtudown-h now restart reboot init 6

To toggle the graphics mode from the command line mode:
STARTX Init 5

Multi-user login, can use ALT+F1 alt+f2 alt+f3 to switch
-------------------------------------------------------------------------------------
Grub-related Problem resolution commands:
* Unable to boot *:
1) Insert the disc, enter and press F5, then enter: Linux Rescue enter
cd/mnt/sysimage/
Cd/sbin
./grub-install/dev/hda
2) Insert the disc, enter and press F5, then enter: Linux Rescue enter
cd/mnt/sysimage/
Cd/sbin
./grub
Grub>root (hd0,0)
Grub>setup (hd0)
Grub>k
Grub>kernel/vmliuz-2.4.20-8
Grub>initrd/initrd-2.4.30-8.img
Restart ...

* User name password forgot question *:
Select the System menu by pressing "E". Under kernel input/1 Press B to boot the kernel
Enter single-user mode after input: VI/ETC/PASSWD
Remove the "X" between the two colons in root and restart the line.
or after entering single-user mode. Input: passwd root change a root password
-------------------------------------------------------------------------------------
File System command:
CTRL + Z quick exit to character input mode
DF to see the space remaining on the hard drive
Du view file Footprint-s-k-hs
Touch Create File
RM Delete file-f-rf (common)
Mount Mount-T
Usage: #mkdir USB/* To set up a mount point */
#cd/mnt/* Enter the mount point */
#ls
#mount-T Auto/dev/sdb1/mnt/usb
Umount Uninstall
#umount-A
#umount/mnt/usb
Cal Almanac such as: Cal 10 2008/* Show October 08 */
Data Change Date DMESG display System Information
UNAME-A display the current system version
Man display reference manual such as: Man-l
--help Viewing command Help
---------------------------------------------------------------------------------------
Directory File Operations Command:
LS Display directory file-a-r ll-ar|more (multi-line display press ENTER to page) find file
Where is looking for files such as: where is KQZJ
Clear Clear Screen
Cd.. Return to the top level directory
PWD Displays the absolute path to the current directory
The CD enters the corresponding relative path
mkdir Create a folder-p (Create a multilayer directory) such as: Mkdir-p AAA/BBB/CCC
RmDir Deleting a folder
CP Copy a file
More read file press ENTER to read (each down a few lines) press Q to exit and clear the screen
Cat read file (see end from head) press PgUp to turn up
VI First press ESC, plus colon q! (! = Forced exit)
chmod permissions to modify files
such as: chmod 777 kqzj.img represents KQZJ Full Control

Read and write execution
R W X
4 2 1
Chown modifying the owner of a file
File Display Type
---------------------------------------------------------------------------------------
File Compression command:
gzip Compression-V (Show progress)
Gunzip decompression-FV (f means no prompt overwrite of the original file) equivalent to gzip-d
Zip compression format: Zip (file name after compression) (original file name)
Unzip decompression
BZIP2 compression
BUNZIP2 Decompression
TAR-CVF Package Format: TAR-CVF (file name after compression) (original file name)
-XVF Unpacking
-CZVF packaged and compressed format: TAR-CZVF kqzj.php.tar.gz kqzj.php
-ZXVF Unpacking and unpacking
Tar and GZ can also be combined into tgz such as: TAR-CZVF kqzj.php.tgz kqzj.php
---------------------------------------------------------------------------------------
Package Installation Commands:
* Install binary Packages *
TAR-ZXVF first Unzip
chmod 755 re-change permissions
./execute files in current directory/usr/local/default installation path
./(program name) & Execute program and run in background
* Install RPM Package *
RPM Common commands:-IVH
-uvh
-I install a new installation package
-U upgrade a software package that exists on a system if it doesn't exist, install it.
-F Update a package if it does not exist, do not install it
-V displays various information (paths, etc.) displayed when the system installs software
-H Displays the progress shown when the system installs software
-E Delete a package (software name)
-Q (a) lists the software that the user has installed
./setup.sh perform a direct installation after entering the installation file directory
* Source Code installation Command *
TAR-XVF Unpacking
./configure Configuration Installation
VI README View Description
Make read and compile the source code
./configure make Make
---------------------------------------------------------------------------------------
User Management commands:
VI/ETC/PASSWD User Name (passwd): Set NU is displayed in sequence form
Vi/etc/shadow Password (shadow)
Vi/etc/login.defs system default information #表示该信息被注释 when establishing a user, does not work
Useradd Add user-u-g-g-d-s-p
such as: Useradd-u 502-g root-g ftp-d/home/kqzj/-s/bash-p 123456 kqzj
Userdel Delete User-R
passwd Changing user passwords
---------------------------------------------------------------------------------------Process Management Commands:
Who (W) view currently logged in user actually w more practical
Last shows the recent user logon situation
Top System Monitoring Commands
PS Display System Current process-a-aux (based on synthesis of top and PS commands)
Kill end a process-9 (unconditional)
Kick out a user, kill-9 pid (-bash)
---------------------------------------------------------------------------------------
Log Management commands:
vi/etc/syslog.conf System Log configuration file
Cd/var/log into the log file directory
---------------------------------------------------------------------------------------
Shell Programming Commands:
Bash execution Shell Script Bash < a.sh
=============================================
The contents of the a.sh script are as follows:
#! /bin/bash
ABC ()
{
A=kqzjhack
Echo $a
}
echo hostname: $HOSTNAME
echo Username: $USERNAME
Echo UID: $UID
echo pwd: ' pwd '
Abc
Ls-l
==============================================
--------------------------------------------------------------------------------------
Network Management commands:
Configuration of the Gdmconfig login interface
Ifconfig viewing the current network configuration
Setup Configure network
Service Network Restart Restart Network Service stop start
Service network State to view the status of current networks
Vi/etc/sysconfig/network-scripts/ifcfg-eth0 modifying IP address with VI editor
Ping Test network connectivity
At Scheduled task command [-v][-q queue][-f filename][-MLDBV] Time
-C Job

Vim

First of all, vi editor ──unix General Editor,
Read as Vee-eye (visual Editor shorthand).
(here vim, is improved VI, VI improved shorthand, VIM is written by Bram Moolenaar)
Vi working mode
Divided into command mode and insert mode as well as: Ex mode;
Press ESC to allow VI to enter the command mode;
Insert mode is the mode in which you enter text. Some simple actions for

VI:
Normal operation:
Insert text
command I, a, I, A, O, o
I enter command mode input I, this time is and ordinary text editor general;
A or input A, the difference is that a is inserted after the character appended text, and I inserted in front of the character;
I Insert at the beginning of line;
A Line Footer is inserted.
O new blank line under Cursor
O new blank line on cursor
Modify Delete text
command C, X, D, D
CW to delete the current position to the end of the word at that position, plus insert text; CW Delete English words, Chinese is not.
C $ or C deletes the current position to the end of the line, plus the inserted text.
x deletes only the current character if you want to delete a Chinese text, use 2x (or 4x 8x, of course) because a Chinese character accounts for two characters.
CC Deletes a row, plus you can insert text.
R deletes the current character, plus you can insert text. The
DW only deletes the current position to the end of the word.
[N]dd Deletes the [n] row. Of course, you can use 2DD 3dd to delete two lines, three lines.
D is deleted to the end of the line.

Paste, copy, merge
command p, y, J, "(quotation marks)
p When you perform the above deletion, the deleted text will remain in the cache, and when you enter P, the deleted text will be pasted after the current cursor.
Y combination (yw,4yy,y$, etc.)//Copy the word, copy four lines, copy to the end of the line after the copy can be pasted with P
J to merge the next line into the current line, note J Capital
"[X]yy name your buffer before copying the command with a colon and a name (A to Z) for example" Ryy "D2DD" ZD ") to copy a row to the R buffer, delete the 2 rows to the D buffer, delete the cursor to the end of the sentence to the z buffer.
"[X]p pastes the X buffer after the current position.]
The default 1~9 buffer is the first 9 delete operations.
Visual action
Command V, V, CTRL + V.

When using the Gvim you can use the mouse to select the text you need to copy, delete, then press D (delete), p (paste), y (copy) to manipulate your text,
Of course, you can share data with other programs through the pasteboard.
V for VIM in xterm enter command v to enter the visual state, when you can right-click to copy and paste operation

Repeat action and undo
Command. (dot), U, u
. Repeat the last action, when it is not the kind of redo, he just repeats the last command you entered.
Ctrl+r Redo
U Undo Last Action
U undo any changes made to the current line.
Find text
Command/,? , N, N
/Backward Find text into command mode input/[you want to find the text]; For example, find edit input/edit;
? And the forward lookup text is input? [The text you are looking for];
n when there are many search results, enter n in command mode to find the next search result, and enter n
N is the inverse of a search result.

Open, Save and exit
Enter ex mode first, type in command mode: then enter the command.
Command ZZ, Q, W, E, R
: ZZ enters the command mode input ZZ (uppercase) is saved + exited;
: W saves text into command mode input w is saved;
: q! Forced exit is input q!;
: e! To undo all current edits and return to the original state, please enter e!;
: w [filename] saved as w [filename].
: e [filename] open another file (before opening a new file, save the file first.)
: R [FileName] reads the filename into the current file's current position
Move cursor
Command HJKL, (,), {,}, E, W, b, GG, G

HJKL can be used to move the cursor directly with the arrow keys on the keyboard. and page Up/down key is the front and back page;
Or, in command mode, press the
H (left) J (bottom) K (UP) L (right)
Or, with a number on the base, a few lines of movement, such as 4j, means moving down four rows.
NG For example 200G is moving 200 lines. And Ctrl+g is the display of the current line information (how many lines, in the position of the text);
G to end of file
GG to file header

e also enter E to move the cursor over a word,
(at the beginning of the current sentence
The next sentence starts for example 2) move forward two sentences
{Paragraph start
The next section of the head
B, w before moving in the word unit.

Mark the command M, ' (single quote), ' (back quotes that is ~ there that key)
M[X] Mark X (a~z) position for example MB mark current cursor position is flag b
' x moves the cursor to the beginning of the X marker line
' x move cursor to x marker's original cursor position
' Move to the beginning of the previous marker
' Move to the previous marker's original cursor position;
ZL zh Zs ze window left roll right roll left start right end//configurable: Set sidescroll=32 set scroll length (I don't seem to be able to use this command)
Other
CTRL+L Brush Screen
Return to the beginning of the next line
-, + move the cursor up and down the line, the beginning of the line (as if the + number to use the keypad +);
CTRL+G Display current line information
H Screen Start
M Screen Middle
L screen Tail

Combination using the example command mode
Example: Existing text

aaabbb
CCCDDDEEEFFF (cursor in first line)

Enter/aab carriage return D/CCC return that will remove the current position AaB (including AAB), all data before the CCC and copy the data to the buffer (and cut almost). Of course D can also be changed to Y for copying purposes, and then paste with P.

Vim's ex state when in: Ex mode you can use tab to perform auto-completion commands (with: Set Nu to display the number of rows) and can use | Multiple commands can be combined at the same prompt

Text Search, replace, move, delete, copy
Command: g/,: s/,: M,:d,: Co (or: T)
: g:g/[Text] Global search text, the cursor moves to the last search text, and displays all data plus rows.
: g!/[text] line without [text]
: s: [nth line],[to line M]s/[to replace]/[replace] [] n-m line substitution, if not n,m then replace the current line
:%/s/[to replace the//replace]/g with a global replacement. % represents each row, in addition there is. Represents the current row, $ represents the last row, and the +-sign represents the top and bottom n rows of the row, for example. -2 indicates the second row above the current row
: M: [Where to move the data]m[Move] Example: 20,30m100 20-30 lines move to 100 lines (the last row is 100 lines)
Example:: g/^$/d Delete all empty lines D plus Delete action

Search mode
. (dot) Any single character, Chinese characters with two points.
* matches the preceding character 0 or more arbitrary (does not represent any character) for example/abcdl* will find ABCDL or start with ABCD, and find all/.*
^ indicates starting from the beginning of the line
$ $ at the end of the expression is expressed as a regular expression to be at the end of the row.
Escaped. means to find. * indicates looking for * \ means looking for
[] [0~9] means that any number between matching 0~9 has the same [a~z] and [a~z], while [ab3a] indicates a A, B, 3,a any one of the characters.
<, > Start or End with a space or punctuation at the beginning or end of a word. For example, inux> matches Linux.
R Enter
T tab
Execute SH command
:! [Shell command] For example:!ls

Add data to the end of a file >>
Example: 1,10w>>newfile

It is important to note that VIM can be used to combine some commands.
: 1,3d | s/they/she/one to three rows to delete and replace the current line they with she
:.,/while/d Delete the current row to match all data in the while row (both the current row and the row containing the while)
:/aaa/,/bbbb/d aaa to BBBB row Delete (both lines included)
:/aaa/,/bbb/m. AAA to BBB line move to current line

Split screen
: [N]sp[lit] [filename] opens another window, the height is N rows, and the filename file is opened.
ctrl+w [x] is ready for a window operation where x is the function key to select after pressing CTRL+W (see next line) For example Ctrl+w and pressing T will go to the top window
Ctrl+w [s/w/t/b/c/q/r/i/=] s re-split screen, w next window, T top window, b bottom window, c close window Q exit window R Loop window I open and enter new window = All windows same height
: Hide hides the current window when the file buffer is not closed (that is, once again: E [filename] is open and remains the previous file)
: Q Closes the window and releases the buffer.
: qa[!] Close all windows and forcibly exit vim;
: On[ly] Show only the current window
: new [filename] New file and opens a fresh window.
: Res[ize][n]: res[ize][+-n] Change the window size, or increase the number of rows reduced

Programming with VIM
: Make [arguments] run make and move to the first error,
: Cf[ile] [!] [ErrorFile] Read the error file and move to the first error! Forcing vim to move to another buffer,
: Cl[ist] [!] List errors with file names, all errors are listed,
: cc[!] [n] Displays error n if n is present, or the current error is displayed again.
: Cn[ext] moved to the next error.
: CP moved to previous error.

Another useful programming feature is to use the Ctags (Unix command) to mark a function in C. This command is used in conjunction with the VI's tags)
First Use ctags command:!ctags file.c Create the C program tags file, and then use in VI: Tag [function name], then VI directly call up the C original file and jump to the function definition.
Example::!ctags *.c
: Tag AAA Where there is an AAA function in BBB.C, then jump to the definition of AAA
: TN jumps to the next matching flag
: A flag on TP

Set VIM
: Set all displays all options.
: Set Nu[mber] Displays the number of rows.
: Set binary binary readable binary file
: Syntax on syntax highlighting
: Set taglength=4 setting tag length
I can't remember. You can use the tab completion command (you can also display the commands you can select)

Vim's configuration file. vimrc
There is a Vimrc_example.vim file in the VIM installation directory, you can copy it to your working directory as your original vim profile (file renamed. VIMRC)

VI citation
Finally, here is the VI certification: VI is perfect
Argument: VI in the Roman numeral is six, less than six of the natural number can be divisible by 6 is the 6=1x2x3; and 6 can be expressed as 6=1+2+3, Visible VI is a perfect number, so VI is also perfect.

For VIM
In Roman numerals, vim may be expressed as (1000-(5+1)) = 994, which is exactly equal to 2x496+2, and 496 is exactly divisible by 1,2,4,8,16,31,62,124,248, and 1+2+4+8+16+31+62+124+248=496
So 496 is a more perfect number, so vim is more perfect than VI.

Large summary of Linux 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.