Linux commands that novice must master

Source: Internet
Author: User

Basic file directory Operations
Ls

$ ls #查看当前目录下文件conf lnmp_install.sh README vhost_ngx_pagespeed.shinit.sh ngx_pagespeed.sh Source vhost.sh
$ ls conf #查看conf目录下文件index. html nginx.conf pureftpd-mysql.conf Tz.phpinit.d.nginx pure-ftpd.conf script.mysql
$ ls -a  #显示所有文件 (contains hidden files beginning with dots (.)) .   conf      lnmp_install.sh   readme  vhost_ngx_pagespeed.sh.   init.sh  ngx_pagespeed.sh  source  vhost.sh 
$ ls -l  #以长格式显示文件的详细信息, can view file permissions, user, date, etc. total  60drwxr-xr-x  2 root root  4096 jul 25 18:14 conf-rwxr-xr-x   1 root root  5720 Jul 25 18:14 init.sh-rwxr-xr-x   1 root root 21011 jul 25 18:14 lnmp_install.sh-rwxr-xr-x  1  root root  1983 jul 25 18:14 ngx_pagespeed.sh-rw-r--r--  1  root root   392 jul 25 18:14 readmedrwxr-xr-x 15 root  root  4096 jul 27 13:58 source-rwxr-xr-x  1 root root   4865 jul 26 21:58 vhost_ngx_pagespeed.sh-rwxr-xr-x  1 root  root  3774 jul 25 18:14 vhost.sh 

PWD #打印当前目录

# PWD/ROOT/LNMP

Cd

# CD: /#进入上层目录 # CD. /.. /#进入上上层目录 # cd ~ #进入当前用户的家目录 # cd/root/lnmp/conf #进入/root/lnmp/conf Directory

Mkdir

$ mkdir linuxeye #创建一个linuxeye目录 $ mkdir-p backup/sql #递归创建目录 (created if directory does not exist)

Rm

$ rm init.sh #删除init. sh file (without the-r parameter cannot delete the directory) $ rm-r conf #递归删除文件或目录 (You can delete the folder, you will be asked if you want to delete it, enter Y for confirmation, and then return) $ RM-RF backup #不会询问 (-F The parameter is used with caution) to delete files or directories directly recursively

Mv

$ mv Linux Linuxeye #将linux文件或者目录重命名为linuxeye $ mv vhost.sh conf/#将vhost. SH Move to Conf directory

Cp

$ CP Linux Linuxeye #将linux文件复制一份命名为linuxeye (if the Linuxeye directory is present, copy the Linux file to the Linuxeye directory and the file name does not become Linux) $ cp-r linuxeye/conf /#将linuxeye目录 (including inside files) copied to the Conf directory

Wget

$ wget http://blog.linuxeye.com/wp-content/uploads/lnmp.tar.gz #下载文件, add parameter-C breakpoint to continue,-T set timeout period followed by seconds

Cat && grep

$ Cat Vhost.sh | grep linuxeye #显示vhost. SH filter lines that contain linuxeye characters


Awk
Take a public network IP address

Ifconfig | grep ' inet addr: ' | Cut-d:-f2 | Grep-v ^10\. | Grep-v ^192\.168 | Grep-v ^172\. | Grep-v ^127\. | awk ' {print '} ' | awk ' {print;exit} '

System Resource Management
Df-h

Filesystem Size used Avail use% mounted On/dev/xvda 24G 13G 9.9G 55%/TMPFS 5 01M 108K 501M 1%/DEV/SHM

Top #动态查看进程消耗资源 (CPU, memory)
Top-h #查看各个线程资源消耗情况

Free-m # View memory, swap usage, top can also see

Compression and decompression
Tar

$ tar czf linuxeye.tar.gz./linuxeye #tar打包压缩 $ tar xzf linuxeye.tar.gz #解压

Zip & Unzip #加-Q parameter does not show the compression process

$ zip-r linuxeye.zip./linuxeye #zip压缩 $ unzip-q linuxeye.zip #安静的zip解压

MySQL Database operations

# mysqldump-uroot-pmysqlpwd--opt--database linuxeye > Linuxeye.sqlroot for user name, mysqlpwd for password, linuxeye database name, Linuxeye.sql sql# mysql-uroot-p after backup #命令行进入MySQL管理Enter password: Mysql>source linuxeye.sql #导入sql, usually used for database recovery



Linux commands that novice must master

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.