1. Linux under the use of VIM to open the configuration file garbled, in the terminal input: "lang=" can be.
2. See if the port is occupied:
3. Netstat-anp | grep Port
Netstat-ltn
4. Lsof-i:port
5. 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
6. 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.
7.: N, $s/vivian/sky/the first Vivian of each row in the beginning of line N to the last row is sky
: N, $s/vivian/sky/g replace the nth line to the last row all Vivian are sky
8. chown User name file path
9. chmod 777 Test
Ten. AddUser Password
11. On the PC machine can not do on-demand operation (only for the PC machine without adding domain name resolution), but on other computers, then you need to put someone else's C:\Windows\System32\drivers\etc\hosts Overwrite the Hosts file in this directory of your own.
In 12.c++, there is often a "\" in the back of the code to indicate a line break, and the following sentence is the same line as above.
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, in fact, this operation is 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 can make the system 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);
27. Synchronous, asynchronous, blocking, non-blocking IO model
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 pipe 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.
Work flow 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
31. Match all Blank lines: ^[\t]*$[\n\r]
32. Decompression Command TAR-ZVXF * * *
33. 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
How to start the stun server:./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 is installed.
Rm-f/etc/my.cnf Remove configuration and data files from other MySQL paths
Rm-rf/var/lib/mysql Delete configuration and data files under other MySQL paths
Mysql> set GLOBAL max_connections=300; Set 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 Check 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 shutting down the firewall in time Iptables–f can also take effect
RPM-IVH vsftpd-2.0.5-16.el5_4.1.x86_64.rpm Mandatory Installation Vsftp
/sbin/chkconfig--list vsftpd Check the startup status of FTP
Wuyi/sbin/chkconfig--level 2345 vsftpd on or off a state of FTP
Adduser-g ftp-s/sbin/nologin-d/mpeg cdnftper Add an FTP user
Chkconfig--list mysql Check if MySQL starts randomly
Chkconfig--add MySQL let 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 View CPU
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 View 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.
65. Clear 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
66. Find the disk space occupied by all the 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.
68. Add Network Neighborhood: netsh-c "I i" Add Neighbors "172.30.25.246" "B8-ca-3a-f2-f4-c8"
69. View the current network send receive: Dstat
Du-h--max-depth=1 work/testing/* can view the disk usage of all files in the directory
The commands that Linux often use