Common commands for SSH in Linux VPS

Source: Internet
Author: User
Tags gz file vps

Directory operation:

  • Rm-rf mydir/* Delete the mydir directory */
  • Mkdir dirname/* create a directory named dirname */
  • Cd mydir/* enter the mydir directory */
  • Cd-/* Go back to the upper-level directory */
  • Cd ../* back to the parent directory with spaces in the middle */
  • Cd ~ /* Return to the root directory */
  • Mv tools tool/* rename the tools directory to tool */
  • Ln-s tool bac/* Create a symbolic link named bac for the tool directory. The most familiar thing is that www in FTP is linked to the public_html directory */
  • Cp-a tool/home/vpser/www/* Copy all files in the tool directory to the www directory */

Directory permission:

When installing the program, you are prompted that you do not have the corresponding file read and write permissions. You must execute the following command at the same time.

  • Chmod 777-R virtual host directory/* permission */
  • Chown www: www-r vm directory/* owner */

File Operations:

  • Rm go.tar/* Delete the go.tar file */
  • Find mt. cgi/* find the file named mt. cgi */
  • Df-h/* Check the remaining disk space. It seems unnecessary unless you are too busy */

Decompress:

  • Tar xvf wordpress.tar/* Extract files in tar format */
  • Tar-tvf myfile.tar/* view files contained in the tar file */
  • Tar cf toole.tar tool/* pack the toolcontents as a toole.tar file */
  • Tar cfz vpser.tar.gz tool/* The variable file is about 10 MB */
  • Tar jcvf/var/bak/www.tar.bz2/var/www // * Create .tar.bz2 file, high compression rate */
  • Tar xjf www.tar.bz2/* decompress the tar.bz2 format */
  • Gzip-d ge.tar.gz/* decompress .tar.gzfile as a .tar file */
  • Unzip phpbb.zip/* decompress the ZIP file. It is a bit troublesome to compress a .tar.gz file in Windows */
  • Zip-r myfile.zip/* compress all files and folders in the current directory into myfile.zip files.-r indicates recursively compressing all files in the subdirectories */
  • Unzip
    Unzip-o-d/home/sunny myfile.zip/* decompress the myfile.zip file to/home/sunny /*/
    -O:/* overwrite the file without prompting ;*/
    -D:-d/home/sunny/* indicates to extract the file to the/home/sunny directory ;*/
  • Others
    Zip-d myfile.zip smart.txt/* Delete the smart.txt file from the compressed file */
    Zip-m myfile.zip./rpm_info.txt/* file rpm_info.txt in myfile.zipto the compressed file */

Download:

  • Wget http://soft.vpser.net/web/nginx/nginx-0.8.0.tar.gz
  • /* Download files from the remote server to your server, saving the upload cost. If the server is not m, the bandwidth is M. It is not tens of seconds to download a 2-3 mb mt */
  • Http://soft.vpser.net/web/nginx/nginx-0.8.0.tar.gz wget-c
  • /* Continue to download the last undownloaded file */

Process Management:

  • Ps-aux/* ps Process status query command */

Description of the ps command output field:

[List] [*] USER: USER Name of the process owner. [*] PID, process ID, which uniquely identifies a process. [*] % CPU, percentage of CPU time and total time occupied by the process since the last refresh. [*] % MEM, percentage of memory used by the process. [*] VSZ, virtual memory used by the process, in K. [*] RSS, total number of physical memory occupied by processes, in K. [*] TTY, the terminal name related to the process. [*] STAT, Process status, with (R -- run or prepare to run; S -- sleep status; I -- idle; Z -- frozen; D -- uninterrupted sleep; w-the process does not reside on the page; T stops or tracks .) These letters. [*] START, the process START time. [*] TIME, total cpu time used by the process. [*] COMMAND, the COMMAND line to be executed. [/List]

  • Ps-aux | grep nginx/* search for nginx processes in all processes */
  • Kill 1234/* 1234 is the process ID, that is, the PID in ps-aux */
  • Killall nginx/* killall directly kills all processes by program name. nginx is the process name */

Vim operation:

Mobile class:

  • H/j/k/l: move one cell to the left/bottom/up/right
  • W: Move backward words (How many words are added before the number)
  • B: Move the forward word (How many words are added before the number)
  • E: Move backward to the end of the word
  • Ge: move forward to the end of the word
  • $ <End>: End of a row
  • 0 <Home>: Beginning of the line
  • Tx: Search for x in the row to the right and move it there (to the left in uppercase)
  • 33G: Move to the 33rd rows of the file
  • Gg: first line of the file
  • G: The end of the file.
  • 33%: 33% of the file
  • H/M/L: the beginning, middle, and end of the screen.
  • Zt/zz/zb: Move the current row to the beginning/center/Bottom of the screen

Jump:

  • ": Return to the jump point
  • CTRL-O: Jump to an older place
  • CTRL-I <Tab>: jump to a newer place

Search:

  • /: Search down (add a keyword)
  • ? : Search up (followed by a keyword)
  • N: The next matched record

Edit:

  • I: Switch to insert mode
  • X: Delete the current character
  • .: Repeat the last modification operation (same as ctrl + f in PS to execute the filter)
  • U: Undo operation
  • CTRL-R: redo
  • P: insert the deleted characters to the current position (put)

Exit and save:

  • : Q: Exit
  • : Q! : Do not save and exit
  • ZZ: Save and exit
  • : E! : Abandon modification and re-edit

You have mastered these basic commands and basic usage in Linux. As long as you practice more and encounter more problems and solve problems, your abilities will be continuously improved.



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.