Several Basic commands in SSH Software

Source: Internet
Author: User

Several Basic commands in SSH Software

Directory:
1. BasicInstructions/basic
2. wget/download Tool
3. Crontab/scheduled task
4. tar/tar.gz/compressed file
5. vi/Editor

Cd [directory name] conversion path
Cd .. back to the parent directory
Ls displays all files in the current directory
Rm [-r]-f [] [file name] delete a file, and add [-r] to delete all the sub-files in the file, for example, rm-rf [abc] deletes the abc folder and all files in the folder.
Tar-xzf [decompress the downloaded package]
Unzip [file name] decompress the file
Cp-rpf. Ahome/user/script. pl
The first number is the number of minutes per hour,
The second number is the hour of the day,
The third digit is the day of the month,
The fourth digit is the month of the year,
The fifth digit is the day of the week.
Example:
32 *: 32nd minutes per hour.
12, 42 *: indicates two times of 12th and 42nd minutes per hour.
*/15 */2 ***: 0: 00, 0: 15, 0: 30 ,...
43 18 ** 7: run the command line at every Sunday.

After using nano in DreamHost to edit the file, use ctrl + o to save the file and ctrl + x to exit the editing.

4.tar command
The tar command is used as follows:
Tar [parameter list] [file name]
Parameter List:
-C generate a new backup and overwrite the old backup file
-X extract from the backup file
-T list the file directories in the backup file
-V: display the list of all operated files
-F generate a backup at a specified location
-U will not exist in the backup file, or add the modified file to the backup.

Example:
Tar cvf filename.tar
Tar cvf tarfile.tar./filename
Tar tvf filename.tar
Tar xvf filename.tar
Tar zxpvf filename.tar.gz
Tar zxvf filename.tar.gz
Tar xvf tarfile.tar./filename
Tar-xzf filename.tar.gz unzip

5. vi Editor
An easy-to-use editor in Linux, you only need to know a few instructions to apply.

Open vi:
$ Vi [filename]: open or create a file and place the cursor at the beginning of the first line
$ Vi + n [filename]: open the file and place the cursor at the beginning of line n
$ Vi + [filename]: open the file and place the cursor at the beginning of the last line
$ Vi +/pattern [filename]: open the file and place the cursor at the first string matching pattern
$ Vi-r [filename]: a system crash occurred when editing with vi last time, restoring filename
$ Vi [filename]... [Filename]: open multiple files and edit them in sequence.

If filename does not exist, a new file named filename is automatically generated.
Vi has two statuses: command status and edit status.
Editing status:
Press the insert key in "insert" mode for the first time, and then press "replace" mode to return the command status using ESC;
In this status, the keyboard's PgUp/PgDn/Insert/Delete/Home/End/direction keys are in the normal functional state.

Command status:
The input string is processed as a command, and the "insert" key is used to switch to the editing status;
The following is a list of commands in the command status:

Move cursor command
H: move the cursor one character to the left
L: move the cursor one character to the right
Space: move the cursor one character to the right
Backspace: move the cursor one character to the left
K or Ctrl + p: move the cursor up a row
J or Ctrl + n: move the cursor down a row
Enter: move the cursor down a row
W or W: move one word to the beginning of the word to the right of the cursor.
B or B: move one word left to the beginning of the word
E or E: move the cursor right to the end of a word j.
): Move the cursor to the end of the sentence.
(: Move the cursor to the beginning of the sentence.
}: Move the cursor to the beginning of the paragraph
{: Move the cursor to the end of the paragraph
NG: move the cursor to the beginning of line n
N +: move the cursor down n rows
N-: Move n rows above the cursor
N $: move the cursor to the end of line n
H: move the cursor to the top line of the screen
M: move the cursor to the middle line of the screen
L: move the cursor to the last line of the screen
0: (Note the number is zero) move the cursor to the beginning of the current row
$: Move the cursor to the end of the current row

Screen tumble command
Ctrl + u: half screen at the beginning of the file
Ctrl + d: Flip the half screen to the end of the file
Ctrl + f: Flip the screen to the end of the file
Ctrl + B; open a screen at the beginning of the file
Nz: Rolls row n to the top of the screen. If n is not specified, the current row is rolled to the top of the screen.

Insert text commands
I: Before the cursor
I: at the beginning of the current row
A: After the cursor
A: At the end of the current row
O: open a new row under the current row
O: open a new row above the current row.
R: Replace the current character
R: Replace the current and subsequent characters until you Press ESC.
S: Starting from the current cursor position, replace the specified number of characters with the input text
S: delete a specified number of rows and replace them with the input text
Ncw or nCW: modify a specified number of characters
NCC: modifies a specified number of rows.

DELETE command
Ndw or ndW: n-1 characters starting at and following the cursor
Do: Delete to the beginning of a row
D $: Delete to the end of the row
Ndd: Delete the current row and the next n-1 row
X or X: delete a character. x deletes the character after the cursor, and X deletes the character before the cursor.
Ctrl + u: delete text entered in input mode

Search and replace commands:
/Pattern: Search for pattern from the beginning of the cursor to the end of the file
? Pattern: Search for pattern from the beginning of the cursor
N: Repeat the previous search command in the same direction.
N: Repeat the previous search command in the reverse direction.
: S/p1/p2/g: replace all p1 in the current row with p2.
: N1, n2s/p1/p2/g: replace all p1 from line n1 to line n2 with p2.
: G/p1/s // p2/g: replace all p1 files with p2.

Option settings
All: lists all options.
Term: Set the terminal type
Ignorance: Case Insensitive in search
List: displays the stop table (Ctrl + I) and end mark ($)
Number: displays the row number.
Report: displays the number of changes made by line-oriented commands.
Terse: displays brief warning information
Warn: NO write information is displayed if the current file is not saved when it is transferred to another file.
Nomagic: allows you to use special characters without "\" in search mode.
Nowrapscan: Prohibit vi from searching at both ends of the file and starting from the other end.
Mesg: Allows vi to display the information that other users write to their terminal using write.

Last-line command
: N1, n2 co n3: copy the content from line n1 to line n2 to line n3.
: N1, n2 m n3: Move the content from line n1 to line n2 to line n3
: N1, n2 d: Delete content from line n1 to line n2
: W: Save the current file
: E filename: open the file filename and edit it.
: X: Save the current file and exit.
: Q: Exit vi.
: Q! : Do not save the file and exit vi
:! Command: execute shell command
: N1, n2 w! Command: The content from line n1 to line n2 in the file is used as the command input and executed. If n1 and n2 are not specified, the entire file content is used as the command input.
: R! Command: place the output result of the command to the current line.

So far, you have successfully logged on to SSH! You can enter help to view the help, input ls to view your directory, etc.
Log out of SSH and enter:
Exit
The following message is displayed:
Logout
Connection to 208.113.155.20.closed.
----------------------------
MySQL Problems
----------------------------
Update: MySQL can be operated only after logging on to SSH!
Log on to MySQL and enter:
Mysql-u username-p-h 208.113.129.128
Replace username with your account. After the following prompt is displayed, enter the password:
Enter password:
Next, log on to the mysql database successfully. The following prompt is displayed:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 3602 to server version: 5.0.18-standard-log
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

View your database:
Show databases;

Import the database content. First, select the database for which you want to import the content:
Use database;
Change the database name to the name of the database you imported into the database. Before importing the database, make sure that you have uploaded the exported database file to the FTP directory. For example

Decompress the exported backup file with the suffix ". SQL" and upload the file to your FTP directory. You can directly upload the file without putting it under the directory. Continue the original statement

Enter the following command to import the database:
Source wp. SQL
Wp. SQL is the name of your database backup file.
Exit mysql:
\ Q
View mysql help (not useful ):
\ H

Related Article

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.