Learning and using Linux commands 2

Source: Internet
Author: User
Tags array definition array length clear screen fpm install openssl openssl install perl line editor

1.ctrl+a: Skip to command line ctrl+e: Skip to command End ctrl+l: Clear Screen
2. Switch User Su-user name
3. Replace the Yum image source
1. Go to/ETC/YUM.REPOS.D backup Centos-base.repo
2.http://mirrors.163.com/Select CentOS Download Centos6-base-163.repo
3.centos6-base-163.repo modified into Centos-base.repo
4. Run the following command to generate the cache yum clean all yum Makecache
5.yum grouplist viewing installed software
4. Installing Tree,telnet,dos2unix,sysstat,lrzsz
5. Turn off SELinux 1. Change/etc/selinux/config to selinux=disabled 2.setenforce 0 temporarily modified to permissive, after boot will take effect
6. Modify Boot Mode
1. Change the/etc/inittab file to 3 command line mode
2. Toggle init (option)
7.chkconfig View settings boot software Auto-start
8. Modify the SSH default port:
1. Backup/etc/ssh/sshd_config.bak
2.Port SSH default port, modify
3.PermitRootLogin Yes changes to No, no root remote login
4.PermitEmptyPasswords no disable null password login
5.UseDNS Yes to No does not use DNS
6./etc/init.d/sshd Restart
9. Line +gg navigate to row
10.visudo 98 line configuration sudo normal user permissions configuration Nopasswd:all sudo su-no password required
11.netstat-lntup Viewing network status
12. Time Synchronization
13.W Querying the currently logged-on user
14./ETC/ETC/INIT.D has many command services
15. mount point---> File system (Device) entrance (new device, disk, USB stick can not be used to first mount in a directory to use)
16. Your own software commands can be built under/usr/local/bin and can be executed globally
17.file File View File types
18. Create Connection file ln-s source files new file name Windows shortcut similar
19.stat h1.c View file status
20.dumpe2fs/dev/sda1 |grep-i "inode size" to view inode information
21.df-i View inode totals and Usage df-h view disk usage
22. Hard link with soft link: ln-s source file New filename creates a soft link without the-s default create hard link
1. Hard links are linked through an index node (Inode) multiple file names point to an Inode this is a hard link---> directory does not support hard links
2. A soft link is a file name that points to another, which is equivalent to a shortcut to the windowns system
23.awk,sed,grep
1. Regular expression: ^ matches with what begins, $ matches the end,. matches any one character (one)
2.* Repeat 0 or more of the preceding characters. * Match all characters [] match the characters inside + match one or more? 0 or one
24.crond timed Task format * (minutes) * (Time) * (day) * (month) * (week) cmd
1. Note: Week and day do not use simultaneously
2.crontab-e Adding an edit timed task
25.hostname viewing host names
26 modifying host names
1.hostname name
2.vim/etc/sysconfig/network
3.vim/etc/hosts
27./etc/sysconfig/network-scripts/ifcfg-*
28. Restart the NIC/etc/init.d/network restart
29. View Gateway Route-n
30.route Add (DEL) default GW IP Delete/subtract gateway
31.nslookup View DNS resolution dig domain name can also traceroute domain name route tracking
32.free-m Viewing Memory
fdisk-l View disk condition disk size = number of tracks * Number of Heads * 512 bytes * Number of sectors
34. Partitioning:
1.fdisk/dev/sdb
2. Partprobe notifies the system that the disk has changed after the addition is complete
3. Disk Format MKFS.EXT4/DEV/SDB1
4.mount/dev/sdb1/mnt/Mount using umount/mnt/delete Mount
35.du-sh/etc/(*) to view the size of a file or directory
36.DUMPE2FS/DEV/SDB1 Viewing file system Information
37.nfs Construction:
1. The installation is complete by default
2. Server: Start rpc/etc/init.d/rpcbind start view ps-ef |grep RPC service rpcinfo-p localhost
3. Server: Start Nfs/etc/init.d/nfs start Chkconfig--list NFS
3. Server: Edit configuration file Vim/etc/exports/data 192.168.138.0/24 (rw,sync) Restart Nfs/etc/init.d/nfs reload View showmount-e localhost< /c0>
4. Client: Check showmount-e 192.168.138.137
5. Mount Mount-t NFS 192.168.138.137:/data/mnt/
38. Uninstall RPM--nodes (regardless of dependencies, if there is dependency on unload)-E source
39.apache Installation:
1. Download httpd
2. Install the query
0.--prefix=prefix install architecture-independent files in prefix
1.--enable-deflate Deflate transfer encoding support compression
2.--enable-expires Expires Header control
3.--enable-headers HTTP Header Control
4.--enable-modules
5.--enable-so DSO capability
6.--with-mpm=mpm Mpm={beos|event|worker|prefork|mpmt_os2|winnt}
7.--enable-rewrite rule based URL manipulation
8../configure--prefix=/usr/local/apache2.2.31--enable-deflate--enable-expires--enable-headers-- Enable-modules--enable-so--with-mpm=worker--enable-rewrite
3. Prompt installation failure so that the installation of the-devel
4.echo $? Check for Success
5.make then make install
40,apache Optimization
1. Remove no home page display directory structure options-indexes followsymlinks
41. Configure Multiple Sites
1.vim httpd-vhosts.conf
2. Open the include conf/extra/httpd-vhosts.conf include conf/extra/httpd-mpm.conf
3. Add <directory "/var/www/html/" >
options-indexes followsymlinks
allowoverride None
Order Allow,deny
allow from all
</Directory>
4. Restart Apache
42.mysql----> Recommended installation of binary files The following steps are identical to the source installation
1. Install create MySQL group
2. Create a MySQL user useradd mysql-g mysql-m-s/sbin/nologin
3. See Linux MYSQLL Single Instance source compilation install. txt file
43.php
1. Installing the PHP dependency package
Yum install zlib libxml libjpeg freetype libpng gd Curl libiconv zlib-devel\ libxml2-devel libjpeg-devel freetype-deve L Libpng-devel gd-devel curl-devel-y
install Libiconv./configure--prefix=/usr/local/libiconv make do install
2. Install PHP
./configure--prefix=/usr/local/php-5.5.38 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv-dir=/usr/local/libiconv \
--enable-sockets \
--enable-mbstring \
--enable-soap \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir
compilation failed install yum install openssl-devel yum install Libxslt-devel
3.make && make install successful CP Php.ini-development/usr/local/php/lib/php.ini
4.apache httpd.conf Add 2 lines to line No. 311
addtype application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. Phps
5. The home address is index.php
44.nginx
1. Install the pcre yum install pcre pcre-devle support rewrite pseudo-static
2.yum install OpenSSL openssl-devel
3.0. First create user, group Useradd nginx-s/sbin/nologin-m
3../configure--user=nginx--group=nginx--prefix=/usr/local/nginx-1.10.2--with-\http_stub_status_module-- With-http_ssl_module
4.make && make install
45.mysql Non-source installation:
46.nginx PHP Installation
1. Dependency package with Apache installation PHP with yum install libxslt*-y
2. Failure
error while loading shared Libraries:libmysqlclient.so.18:cannot open Shared object file:no such file or directory< /c0>
1. First confirm whether there is libmysqlclient.so.18 this file under/usr/local/mysql/lib/.
Ll/usr/local/mysql/lib/|grep libmysqlclient.so.18
2. Modify the ld.so.conf file
echo "/usr/local/mysql/lib" >>/etc/ld.so.conf
3. Then execute the ldconfig to make it effective.
3. Change config file: CP etc/php-fpm.conf.default etc/php-fpm.conf
47.cms discuzz WordPress
48.php Optimization
1. Installing yum install perl-devel-y
2. Installation Expansion method usr/local/fastphp/bin/phpize./configure--enable-eaccelerator=shared \
--with-php-config=/usr/local/fastphp/bin/php-config
3. Installing MYSQLI expansion
./configure--with-php-config=/usr/local/php/bin/php-config--with-mysqli=/usr/local/mysql/bin/mysql_config
/home/centos3/public/apps/php-5.5.38/ext/mysqli/mysqli_api.c:36:47:error:ext/mysqlnd/mysql_float_to_ Double.h:no such file or directory
Make : * * * [Mysqli_api.lo] Error 1
Note: There may be a problem with the relative path, mysqli_api.c in the mysql_float_to_double.h path in Mysqlnd
3. Modify Extension_dir = "/usr/local/fastphp/lib/php/extensions/no-debug-non-zts-20121212/" in PHP.ini
extension=mysqli.so
4.php.ini in the lib of PHP can be found
5. General PHP forgot to install the source code in the installation of Ext can be re-added, first to usr/local/fastphp/bin/phpize and then configure make ...
49.php Cache Accelerator XCache
1. Choose one with Eaccelerator two
2. Install: Perform/usr/local/fastphp/bin/phpize,./configure--enable-xcache--with-php-config=/usr/local/fastphp/bin/first Php-config
3.php.ini Adding extension=xcache.so
50. Installing Pdo_mysql
1. Execute/usr/local/fastphp/bin/phpize First
2../configure--with-php-config=/usr/local/fastphp/bin/php-config--with-pdo-mysql=/usr/local/mysql
3. Error:/home/centos3/public/apps/pdo_mysql-1.0.2/php_pdo_mysql_int.h:53:error:expected Specifier-qualifier-list before ' Mysql_res '
Make : * * * [Pdo_mysql.lo] Error 1
FIX: This problem occurs because a file is required for MySQL header at compile time, and it does not find the location of the head file by default search. So to link the MySQL header file in the/usr/local/mysql/include/directory to/usr/local/ Under the include/directory:
ln-s/usr/local/mysql/include/*/usr/local/include/
then the make and make Install,pdo_mysql modules are added.
51. Optimization:
1. Hide version number: Server_tokens off;
2. Compression:
gzip on;
gzip_min_length;
Gzip_buffers 4k;
Gzip_http_version 1.1;
Gzip_comp_level 6;
gzip_types text/html text/css text/xml application/javascript text/plain Application/json;
gzip_vary on;
52.apache forgot to install module solution-----> Load with DSO dynamic module
1. Switch to Apache source path:/home/centos3/public/apps/httpd-2.2.31/modules/filters
2. (This is the path of installation)/usr/local/apache/bin/apxs-c-i-a mod_deflate.c
3. Check whether the Apache installation directory generates. So Files ll/usr/local/apache/modules/
53.expires Local Cache

54.JS,SCC Log Configuration not logged
Location ~. *\. (Js|jpg| Jpg|jpeg| Jpeg|css|bmp|gif| GIF) ${
Access_log off;
}css failure what reason?
55. Security
1. Users and groups for all site directories should be root
2. All directory permissions are 755
3. All file permissions are 644
4. Users of Web services cannot use root
5. Change to expose_php = off does not show PHP version
56.iptables
1.iptables-l-N
2.iptables-f Purge rule iptables-x Delete custom rule iptables-z Register of the chain 0
3.iptables-t filter-a input-p tcp--dport 80-j DROP
4.-a and-I differences:-a adds a rule at the end,-I adds it at the beginning
5.iptables-t filter-a input-i eth0!-S 192.168.0.2-j DROP seal an IP
6.iptables-t filter-a input-p The port between TCP--dport 80:100-j drop80-100 is sealed
57.SVN
1.yum Install subversion-y
2. Start svnserve-d-R svndata/svnadmin Create path/project
3. Under construction svnserve.conf Open 12 line changed to Anon-access = None auth-access = Write Password-db =/home/centos3/public/svnpasswd Authz-db =/home/centos3/public/svnpasswd/authz
4.CP Authz passwd/home/centos3/public/svnpasswd/
5. Restart Svnserve
58.shell
1. Note: [] write a space on either side or it will go wrong
2..bash_profile. BASHRC Global variables that user home directory setting that effective/etc/profile all users
3./etc/profile.d/placing a file into bash execution
4.unset name environment variable cancellation
5.$0 Gets the file name of the current shell script, including the script path
6.dirname $ basename path name
7.${n} Gets the parameters of the script
8.$ #获取当前脚本参数的个数
9.$? Gets whether the last script execution was successful
10. Script Exit General with exit 1
11.$* gets all parameters passed in by the script, and all parameters passed in as a string, similar to "$1$2."
"[email protected]" Gets the parameters passed into the script, but is listed separately, similar to "$" "$" ... "$*" All parameters a string output, [email protected],$* the same list, similar to "$" "$" ...
13.shift parameter forward shift
14. Numerical Calculation:
1. ((a=1+2**3-2)) Double parenthesis Inside Operation Echo $ (($a + 1))
2.let i=i+2 No (()) High efficiency
3.expr
4. Echo 2+2|BC
5.read-p "Please enter:" A echo $a
15. Condition Testing
1.man Test View usage
2. Note the string comparison: ["AB" = "ab"]&&echo 1| | echo 0 1. String "" caused, 2. To have a space
3.[] [[]] difference [] inside with-a-o-gt-ge ... and [[]] can apply to && | | > >=
16.shell function
1.echo-e "\033[{3-4}{0-7}m 111 \033[0m" display fonts in different colors
17. Array Definition a= (1 2 3 4) echo ${#a [*]} echo ${arr[@ or *]} Get all elements get array length print echo ${a[0]}
2. Define the associative array declare-a arr2 arr2= ([' A ']=11 [' B ']=22 [' C ']=33) echo ${arr2[' A ']}
echo ${!arr2[*]} List all indexes echo ${arr2[*]} List all values
18.tty Displays the name of the current user terminal. Note that each individual xterm window is counted as a different terminal.
19.lsof lists open files. This command will list all currently open files with a detailed table, including the file owner information, dimensions, information related to them, etc.
: > Data.xxx function identical to: Cat/dev/null >data.xxx
21.command &>filename will redirect command standard output (STDOUT) and standard error (stderr) to file filename
22. A command followed by A & will run in the background.
59.sftp [email protected]
60.sed Line Editor
61.grep
62.awk Report Generator

Learning and using Linux commands 2

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.