Linux Command set I have used

Source: Internet
Author: User

The following is a collection of Linux commands that I have used. It can also be said that Linux cainiao must know. Basically, it occupies more than 95% of all the commands you will use. It is worth noting that.

I. Common MySQL database operations in Linux

1. log on and log out
Mysql-uroot-p123456;
Mysql <./hostcache. SQL-uroot-p123456;
Mysql <E:/SQL/hostcache. SQL-uroot-p123456;
Show databases;
Use hostcache;
Show tables;
Desc hostcache;
Exit;

2. Data Operations
Alter table voucherwinner modify cpuid varchar (36 );
Alter table installerreport add skypeid varchar (32 );
Update operator set agentid = '000000' where username = '000000 ';
Select * From hostcache order by timestamp;
Select * From voucherwinner where skypeid not like '# % ';
Select externalip, internalip from hostcache order by timestamp;
Delete from hostcache where isptype = 4;
Delete from hostcache;

3. Import and export data
Import data from the table voucherwinner in the database skypeuser to the voucherwinner file.
This command saves the table creation operations and data insertion records as scripts to files.
Mysqldump-h172.24.172.47-uskypeuser-ptomskype47 skypeuser voucherwinner> voucherwinner

Export data tables with where conditions
Mysqldump-h61.135.158.241-uroot-p -- W "time> = '2017-05-03 00:00:00 'and time <= '2017-05-03 23:59:59'" skypeuser

Installerreport> installerreport20070503

Import records to the new database
Mysql-uroot-P skypeuser <voucherwinner;
Mysql-h61.135.158.241-uroot-P skypeuser <installerreport20070503

4. Permission assignment
Run the following command on the database server:
Mysql> grant all on *. * To username @ IP identified by 'Password ';
For example:
Mysql> grant all on *. * To root@192.168.15.96 identified by '20140901 ';

Then you can access:
Mysql-h192.168.15.96-uroot-p123456;

Modify the maximum number of connections
The default maximum number of connections for MySQL is 100. This value is stored in the INI file of MySQL, for example, my. ini. You can find the corresponding value and modify it.

Ii. Common Linux operations

1. Common File Operations
CD ../home/tcast/natserver; enter a directory
CD $ {ace_root}
Tail-F 2005-10-28.log: view files being modified by other processes
PS-A displays the current process list
PS-Ef | grep natserver query whether the process whose name includes natserver exists
Killall-9 p2pserver kill Process
Kill-9 6499 end the process with ID 6499
DF view disk usage ratio

2. Set scheduled tasks
A cron job is a command that is run by the cron daemon at the scheduled interval of the rule.
Crontab-E: edit a copy of your crontab file. Alternatively, if a valid username crontab file does not exist, create an empty file for editing. When editing

After the configuration is complete, the file is directed to the crontab directory as the user's crontab file.

For example, if you add a task that is executed once every day at, add the following text:
16 9 * *** echo "hello">/root/hello.txt

Crontab-l lists the user's crontab files.

3. display or modify the system time
Date
Date-s 'sat Apr 21 09:55:11 CST 2007'

4. Remote Logon
SSH 61.135.234.140 logs on from one Linux system to another
Exit exit from that Linux System

Iii. Environment Variables

Locale Check the localization settings (locale is in/usr/lib/locale)
Export lang = zh_cn: set local variables
Export lang = set this variable to null
Uname-A: View information about the operating system and CPU
Top view CPU and memory usage of processes
Env view environment variables
/Etc/profile environment variable file, which can be set
Add environment variable path in export path
Export cppflags = "-I/data/tomskypeivr/asterisk/include"
Export LD_LIBRARY_PATH =/data/tomskypeivr/cpprad/lib
Echo $ cppflags
$ {Ace_root}
Su-Root

IV. C/C ++ compilation and debugging

1. Common Operations
VI makefile edit makefile
Make compiles the source code in the current directory
./Kill. Sh script for running the end program
CTRL + C end the running program in the console
Chmod A + x tcastchanroot Modify file attributes to run
./Runnewtcast. Sh & background running script
Nohup./tcastchanroot> runlog does not suspend the execution program, and the output is directed to the file runlog

2. GDB debugging
GDB./reportserver start to debug the reportserver Program
B Main sets a breakpoint at main ().
B creportserver: SVC set a breakpoint at creportserver: SVC ()
B 100 place a breakpoint on the second line of the current file
D. Delete all breakpoints.
Start
T displays the current thread status
P argc variable display
S: Enter function execution
N jump to the next line for execution
C jump to the next breakpoint for execution
Quit exit debugging

Ulimit-C Unlimited
Check the debugging information of GDB tcastchanroot core.6200.
Where module structure

V. Text operation commands

1. Common Operations
Tail-F 2005-10-31.log: View logs
Open a text file in CAT/proc/cpuinfo read-only mode

Grep mykeyword statistics.2006102700.log
Grep mykeyword statistics.2006102800.log | WC
Grep mykeyword statistics.2006102800.log | awk '{print $1}' | sort-u | WC
In the statistics.2006102800.log, The mykeyword row appears, and the number of rows in the 1st columns of the mykeyword row are printed.

Cat testsetuplog2006-10-28 | awk '{print $3}' | sort-u | WC
Cat testsetuplog2006-10-30 | awk '{print $6}' | grep 0 | WC
Cat testsetuplog2006-11-15 | awk '($5 $6 = 62) {print $4}' | sort-u | WC
In each row of the log testsetuplog2006-11-15, 5th columns equals 6, 5th columns equals 2 rows print their 4th columns of content that are not repeated

Cat exportmac2005.txt> mac.txt stores the exportmac2005.txt file in another file, mac.txt
Cat ExportMac2006-01-01.txt> mac.txt Add the content of exportmac2006-01-01.txt to the file mac.txt
WC mac.txt counts the number of entries in mac.txt.
Cat mac.txt | sort-u | WC counts the number of non-duplicated entries in mac.txt.
Cat mac.txt | sort-u> macunique.txt stores the unique content in mac.txt to macunique.txt

Grep 'radius '* searches all files in the current folder for the location where the radius is displayed.
Find-name main. cpp search path of the file whose file name is main. cpp

2. VI command
I from command mode to insert mode
ESC from insert mode to command mode
Command mode scrolling: Ctrl + F
YY copy the current row
P Paste
Dd deletes the current row
/XX search for the XX string in the document, and N for the next
: WQ

Replace installerreport in the text with installerreport20070503
: G/installerreport/S/installerreport/installerreport20070503/g

Vi. File System Operations

Touch XXX creates a new file
Mkdir XXX creates a new directory
MV jspwiki-2.2.33-bin.zip.../usr/tomcat55/webapps/
MV (MOVE) can move the file to another place, or change the file name (there is no Ren or RENAME Command in lniux to change the file name ).

CP jspwiki. War ../jspwiki. War
Rm-RF WEB-INF force remove folders with content
Rm XA * Delete all files starting with XA
Split-l 10000 exportmac.txt splits exportmac.txt into multiple files, each of which contains 10000 lines
CP-A./star_zh_cn.../tomwiki/templates/start_zh_cn copy the entire directory
CP-A./star_zh_cn ../.../../tomwiki/templates/start_zh_cn copy, use absolute path

Ln
This is a very important command in Linux. Please be familiar with it. Its function is to create a non-same link for a file in another location. The most common parameter of this command is

-S: the target file of the Ln-S source file.
When we need to use the same file in different directories, we do not need to put a file that must be the same under each required directory. We just need to put it in a fixed directory.

And then use the ln command link in other directories. Example: ln-S/bin/less/usr/local/bin/less
-S indicates the symbol (symbolic.
There are two points to note: first, the ln command will keep the synchronization of each link file, that is, no matter which one you have changed, other files will change the same; second

, Ln links are soft links and hard links. The soft link is ln-s *****. It will only generate a file image at your selected location, does not occupy disk space, hard link ln **

** Without the-S parameter, it will generate a file of the same size as the source file at the position you selected. both soft and hard links keep the file Changing synchronously.
If you use ls to view a directory, you will find that some files are followed by a @ symbol, that is, a file generated using LN command, and you can use LS-l command to view it, the displayed

Link path.

Obtain and download an object from the network to the current directory
Wget http://www.blogdove.com/nnt.tar.gz

File Transfer command to upload the. So file in the current directory to/data/tomskypeivr/asterisk/lib/asterisk/modules/Under the machine 211.99.190.120
SCP *. So web@211.99.190.120:/data/tomskypeivr/asterisk/lib/asterisk/modules/

7. compression and decompression commands

Unzip jspwiki.zip
Unzip-D ../jspwiki jspwiki.zip unzip the zip package
Unrar x udt2.rar unzip the RAR package

Gunzip backup.tar.gz &
Tar xvf backup.tar

Tar zxvf kingsoftunion.tar.gz files suffixed with tar.gz.
Tar jxvf upx-3.00-i386_linux.tar.bz2 uncompressed files suffixed with tar.bz2.

Package A folder into a compressed file
Tar zcvf kingsoftunion.tar.gz kingsoftunion/

8. PHP commands

PHP exportmac. php executes a PHP script

9. run commands in the background

When starting a program, let it immediately enter the background Running Mode
After reading the previous bash introduction, we should understand the usage of Ctrl + z/BG/FG. Some programs work very time-consuming. Add an & symbol next to it, for example, "updatedb &

"," Netscape & ", etc. In this way, the shell will be released for other jobs. Note that the parent process of the program is still the shell. If you exit the shell

The program will also be killed. We recommend that you run the jobs command to view background jobs before exiting shell.

Use the nohup (do not suspend) command
If you want to execute a process after you exit the system, you can use the nohup command, for example:
% Nohup tar-CF/dev/tape/home &
If you log on again after logging out, run the "Ps" command to check that the process is still running. Note: To put the command in the background for running, nohup must be the same as & Operation

. Some software can handle sighup signals by itself, such as wget, without using nohup.
You can also use nohup to implement PPP callback: dial up first, and then execute a self-made script with nohup, such as "sleep 60; PPP-start-script. Last

Log out and stop waiting.

10. General installation methods of software packages

1. Baidu or Google get the download path of the installation package, for example, search for lrzsz in Google to get
Http://www.ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz
In Linux
Wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz

2. decompress the Software Package
Tar zxvf lrzsz-0.12.20.tar.gz

3. Install Trilogy
./Configure -- prefix =/data/tomskypeivr/bin
Make
Make install
 

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.