Linux under the use of VIM to open the configuration file garbled, in the terminal input: "lang=" can be.
To see if the port is occupied:
NETSTAT-ANP | grep Port
Netstat-ltn
Lsof-i:port
Shell script Command list:
$# is the number of arguments passed to the script
The name of the script itself
$ $ is the first parameter passed to the shell script
$ $ is the second parameter passed to the shell script
[Email protected] is a list of all parameters passed to the script
$* is to display all parameters passed to the script in a single string, unlike positional variables, which can have more than one parameter
$$ is the current process ID number for the script to run
$? is to display the exit status of the last command, 0 means no error, others indicate an error
Find. -type f-name "*.sh"-type find a file of a certain type, such as: B-block device file. D-Directory. C-character device file. P-Pipeline file. L-Symbolic link file. F-Normal file.
- : N, $s/vivian/sky/replaces the first Vivian of each row in the nth row to the last row is sky
: N, $s/vivian/sky/g replace the nth line to the last row all Vivian are sky
Chown User name file path
chmod 777 Test
AddUser Password
On the PC machine can not do on-demand operation (only for not add the domain name resolution of the PC machine), but on the other computer, then you need to put someone else's C:\Windows\System32\drivers\etc\hosts to cover their own directory of hosts file.
12.c++ often have code followed by "\" to indicate a newline, indicating that the following sentence and above are the same line.
Du–sh view the file size.
Shell 2>&1: & 1 more accurately, it should be the file descriptor 1, and 1 generally represents the Stdout_fileno, which is actually a dup2 (2) call. He standard output to All_result, Then copy the standard output to the file Descriptor 2 (Stderr_fileno), the consequence is that the file descriptor 1 and 2 point to the same file table entry, or the wrong output is merged. where 0 means that keyboard input 1 means that the screen output 2 indicates an error output. REDIRECT standard error to standard output and throw /dev/null go under. In layman's words, all standard output and standard errors are thrown into the trash.
- Try_file
Try_files $uri $uri//index.php?q= $uri & $args;
Checks whether the file exists in order and returns the first found file. The trailing slash is represented as a folder-$uri/. If all the files are not found, an internal redirect is made to the last parameter.
The date +%s can display a large integer time of UTC equivalent to Os:millionseconds ().
Date-d @1411266453 can convert the time to the current month date format.
Date-d "1970-01-01 UTC 1411261790 Seconds" converts a random UTC time to the current time.
Ulimit-c Unlimited enables the system to produce core files
"Grep-v #" gets all lines that do not contain the # number, where "\" is the translation character,
Cut-d:-f1 Gets the text with ":" As a delimiter, and gets the value of the first zone.
- grep return Value:
succeeded, returned 0;
Failed, file exists, template string does not exist, return 1;
Failed, file does not exist, return 2;
- Try_file
Try_files $uri $uri//index.php?q= $uri & $args;
Checks whether the file exists in order and returns the first found file. The trailing slash is represented as a folder-$uri/. If all the files are not found, an internal redirect is made to the last parameter.
umout. tmp resolves an issue in which the original folder cannot be deleted because the files are deleted before the project is quite worth.
- Stat ()
Related functions: Fstat, Lstat, chmod, Chown, Readlink, Utime
Header files: #include <sys/stat.h> #include <unistd.h>
Define functions: Int stat (const char file_name, struct stat buf);
Used to copy the file state referred to by the parameter file_name to the structure referred to in parameter buf, the return value of the function can be used to determine whether the file exists.
- INotify, which can be used to listen for file paths or files.
int fd = Inotify_init ();
int wd = Inotify_add_watch (fd, path, mask);
int ret = Inotify_rm_watch (FD, WD);
- synchronous, asynchronous, blocking, non-blocking IO models
Finally, a few more examples are not very appropriate to illustrate these four IO Model:
There is a (synchronous blocking), B (synchronous non-blocking), C (asynchronous blocking), D (asynchronous non-blocking) four persons in fishing:
A used is the most old-fashioned fishing rod, so, have to keep guarding, wait until the fish hooked up again lever;
B's Fishing rod has a function, can show whether there are fish hooked, so, B and next to the MM chat, and then see if there are fish bait, some words on the rapid lever;
C with the fishing rod and B almost, but he thought of a good way, is to put several fishing rods at the same time, and then keep in the side, once the show said the fish hooked, it will be the corresponding rod pull up;
D is a rich man, simply hired a person to help him to fish, once the person caught the fish up, send a message to D.
- The Popen () function starts a process by creating a pipeline and invokes the shell. Because the pipeline is defined as one-way, the type parameter can only be defined as read-only or write-only, not both, and the resulting stream is read-only or write-only.
The command parameter is a string pointer to a string that ends with a null terminator, which contains a shell command. This is sent to/bin/sh with the-c parameter, Executed by the shell. The type parameter is also a pointer to a string ending with a null terminator, which must be ' r ' or ' W ' to indicate whether it is read or write.
The return value of the Popen () function is a normal standard I/O stream, which can only be closed with the Pclose () function, not fclose (). function. Writes to this stream are converted to standard input to the command commands; The standard output of command commands is the same as calling Popen (), which is the same as the process of the function, unless the command commands itself to change. Instead, reading a "Popen" stream is equivalent to reading the standard output of command commands, The standard input for command is the same as calling Popen, which is the same process as the function.
Note that the output stream of the Popen function is fully buffered by default.
The Pclose function waits for the associated process to end and returns the exit state of a command command, just like the WAIT4 function.
Can be used to return the command result in the program: Popen ("Ls-l", "R"), the list of files can be returned;
Popen ("Du-sk", "R") can be used to return the remaining space.
- Workflow of Libaio
Libaio Workflow:
Io_prep_pread ()/io_prep_pwrite () set read and write operation parameters
Io_submit () Submit
Io_getevents () Check Results
Uname–a View all information about the system,-r view all, if it is a red hat, you can use Cat/etc/issue
Match all Blank lines: ^[\t]*$[\n\r]
Decompression command TAR-ZVXF * * *
With Ulimit-n, we can get the maximum number of FD that a process can open.
PWDX pid is used to view the directory where the running thread is located
Stun Server Startup method:./server-v-b-h 121.14.85.205-a 121.14.85.206
Pstack can be used to view stacks in the course of running Linux programs.
Rpm-qa|grep-i MySQL is used to check if MySQL has been installed
Rm-f/etc/my.cnf Remove configuration and data files from other MySQL paths
Rm-rf/var/lib/mysql removing configuration and data files from other MySQL paths
Mysql> set GLOBAL max_connections=300; Sets the maximum number of connections for MySQL
Mysqladmin-uroot-pcoship variables Check the maximum number of connections for MySQL.
TAR-XZVF redis_2.4.7.tar.gz Unzip the package.
Getenforce checking the status of SELinux
Vi/etc/selinux/config Disable SELinux in configuration
Setenforce 0 enables the above configuration to take effect.
Service iptables status Check firewall state
Chkconfig iptables off firewall, after reboot takes effect
Service iptables stop shut down firewall in time iptables–f can also take effect
RPM-IVH vsftpd-2.0.5-16.el5_4.1.x86_64.rpm Force Installation Vsftp
/sbin/chkconfig--list vsftpd Check the startup status of FTP
/sbin/chkconfig--level 2345 vsftpd on or off a state of FTP
Adduser-g ftp-s/sbin/nologin-d/mpeg cdnftper Add FTP user
Chkconfig--list mysql Check if MySQL starts randomly
Chkconfig--add MySQL lets MySQL start randomly.
Tcpdump-i eth0-t tcp-s 60000-w diaoxian.cap Clutch
- Tcpdump–i eth0 TCP port 554–w test.cap
View PC Configuration
- Cat/proc/cpuinfo viewing CPUs
Free-m Viewing memory
Fdisk-l viewing hard disk partitions
Df-h Viewing mounted directories
Ifconfig Viewing network card information
Ethtool eth0 View details of the network card operating mode
Lspic lists all the chip information, such as sound card, video card, network card and so on.
Cat/etc/issue viewing the release version of the current system
Uname–a View kernel information for the current system
RPM-E--nodeps mysql-libs-5.1.73-3.el6_5.x86_64 forced uninstall MySQL
Select Table_name,table_rows from tables where Table_schema = ' Olaj ' ORDER by table_rows Desc;
NETSTAT–TNL | grep 3306
%s/((HTTP|FTP|HTTPS)://) ([A-za-z0-9. -]+. [A-za-z] {2,6}) | ([0-9]{1,3}. [0-9] {1,3}. [0-9] {1,3}. [0-9] {1,3})) (: [0-9]{1,4}) * (/[a-za-z0-9\&%./-~-]*)?/\/Match link.
Grep-r-n '. _log. [Loadxml|parse] './grep usage,-n denotes line number,-I means ignore case.
- Empty the system log and make room
Rm-rf/var/log/*.gz
Rm-rf/var/log/*.1
echo "" >/VAR/LOG/DMESG
echo "" >/var/log/kern.log
echo "" >/var/log/messages
echo "" >/var/log/syslog
- Find disk space for all files in the current directory
DU-LH--max-depth=1
g++ Hello.cpp-save-temps can save temporary files that are generated at compile time.
Add Network Neighborhood: netsh-c "I i" Add Neighbors "172.30.25.246" "B8-ca-3a-f2-f4-c8"
View send receive for current network: Dstat
- Du-h--max-depth=1 work/testing/* can see the disk usage of all files in the directory
71-73 slightly
- OpenSSL engine–t See if there is an SSL hardware acceleration device
- Pgrep Redis-server | Wc–l View the number of startup threads.
- RSYNC-AVLP--exclude= "Log" to back up other things that remove log
- Echo–e allows for translation of subsequent content
- Echo-e "\e[32;40;1;4m is success\e[0m" The output font is color
- #cat/proc/cpuinfo |grep "Cores" |uniq view the number of CPU cores
- getconf PAGESIZE Query Nginx in the fastcgi_buffer_size should be configured how much.
- How to traverse some fields
Startorder= "Redisserver,cpm,cls,cl,cg,rtcl,cdnadapter,ci"
For module in $ (echo $startorder | tr ', ' \ n ')
Do
Done
- transcoding commands
./ffmpeg-i./bjqn/dragontv.beijing.youth.ep02.hdtv.720p.x264-chdtv.mkv-fpre vod-acodec copy-y./bjqn02.mp4
- Find: /download/-maxdepth 1-type f-mmin +120 | Grep-v Heartbeat.xml | Xargs-n 1 rm-f
- SORT-K3NR file
K3 refers to sorting by a third field
n Specifies that the classification is a numeric classification on a field.
R is the descending meaning.
- 1>/dev/null indicates that the standard output of the command is redirected to/dev/null
2>/dev/null indicates that the error output of the command is redirected to/dev/null
- Find. -name "*.C" | Xargs grep Main
- Du–sk View the current directory used space.
- TAR–JXVF TAR-BZ2 's Decompression command
- Stat-c%Y filename to check the last modified time of a file.
- Mysql-uroot-pcoship dbname < dbname.sql MySQL Direct import data
- SELECT Table_name,column_name,column_type from INFORMATION_SCHEMA. COLUMNS where table_schema= "Ott_r002_portalms" and data_type in (' int ', ' bigint ', ' decimal ') prevent IDs from overstepping.
- SELECT Table_schema,table_name,round ((data_length+index_length)/1024/1024,2) as MB from INFORMATION_SCHEMA. TABLES have mb>500 database space is not enough, see details.
- Awk-f ' [&,=,.,/] ' Nr==6{print $ ' tmpfile awk locks the first few lines
- Ps-a|awk '/process name/{print $ ' identifies a process number.
- Nohup Ping www.ibm.com & running programs in the background
- Setsid Ping www.ibm.com running programs in the background
- (Ping www.ibm.com &) Run the program in the background
- Screen, disown can also implement the function of response.
- !! Executes the last command executed.
- !s commands that begin with s in the execution history
- watch-d ls–l Let a command continue execution by default two seconds
- Pgrep ssh to find out the PID of the process associated with SSH
- CTRL+D Fast Launch Login terminal, ctrl+u delete a whole line (VIM insert mode is active)
- cd– return to the directory where you Last
- Touch-c-T 0801010800 filename.c time to modify files
- $_ last parameter of previous command
- Ss–t–a displaying TCP connections
- Cat/proc/46720/environ Gets the environment variables that the current process relies on.
- /proc/net/dev stores the network card information;
- grep eth/proc/net/dev|awk-f: ' {print $} ' |awk ' {print $, $9} ' view network card bandwidth
/etc/passwd/etc/shadow user and password to store Linux system
- grep "http://202.105.136.35:18080/"-rl./Displays the file name with this entry
- awk ' End{print NR} ' tmp; counts the number of lines of a text.
- PS Auxw|head-1;ps auxw|sort-rn-k3|head-10 See the most CPU-consuming 10-a program;
- Treatment Dynamic Library not found: Ln-s/usr/lib64/libcrypto.so libcrypto.so.6
- Ps-a-O Stat,ppid,pid,cmd | Grep-e ' ^[zz] ' find zombie process
- Ps-a-O Stat,ppid,pid,cmd | Grep-e ' ^[zz] ' | awk ' {print $} ' | Xargs kill-9 Find and kill zombie process
- Database query Implementation Cartesian product: Select X+y+1, x+y+1 from (select 0 as X from dual union select 1 from dual Union select 2 from Dual) A, (select 0 as Y from dual Union Select 1 from dual Union select 2 from dual) b;
Batch binding: FORALL I in 1.. 10000000
INSERT a ...
- ./ffmpeg-i/mpeg/ad1.ts 2>&1 | grep ' Duration ' | Cut-d '-F 4,8 | Sed s/,//get the bitrate of the file
- After thread apply all BT gdb–c core.1111, you can use this command to view all threads.
Netstat-n | awk '/^tcp/{++y[$NF]} END {for (w in y) Print W, Y[w]} counts the number of States of all TCP links
- df–h [directory name] to query which partition the current directory belongs to
- Iptables-i input-p tcp-m State--state new-m TCP--dport 22122-j accept open a port on the firewall/etc/init.d/iptables save to save the firewall settings. NETSTAT-UNLTP | grep Fdfs
- Vim/etc/rc.d/rc.local Set Boot start
Centeros setting up a firewall firewall-cmd--zone=public--add-port=5000/tcp--permanent
Firewall-cmd–reload
- Wget-s Http://httpd.apache.org/images/httpd_logo_wide_new.png 2>&1 | grep ' Accept-ranges '
Accept-ranges:bytes testing whether the server supports the breakpoint continuation function
- Curl–range 0-99 http://images/billboard_iphone_hero.jpg Test Server supports breakpoint continuation
- Does the background server support long connections: netstat–n | grep time_wait, if the long connection is not supported then there will be many time_wait states.
Common commands for Linux