Linux use command record

 

1. Modify permissions for all files in a folder:
	• chmod –R 777 aa (-R recursively change the specified directory and the owner of the files in it)
	• Directory /his and its file directory, chown - R www.www /his (the first www represents the owner of the file, and the second www represents the group name)
	• #drw-r-xr-- 3 root root 4096 Nov 5 2016 file means: the first 3 (rw-) belong to the owner, the middle belongs to the group, and the last 3 belong to other users (the first d means directory)
2. Move the file mv aa bb 
	• Copy the folder www to bak: cp -r www/ /ibos/bak/
	• Rename can also be this: mv ab
3. Find the file find / -name aaa: where / is the root directory, use "." for the current directory; -name is the name, case-insensitive, use -iname
4、
	• zip:
		○ Unzip: unzip test.zip -d /tmp
		○ Compression: zip -r mydata.zip mydata #compress the mydata directory
	• tar: (-z: with gzip attribute, -x: decompression, -c: create a compressed file, -v: display all processes, -f: use the file name, this parameter is the last parameter, only the file can be followed name)
		○ Unzip the tar zxvf filename.tar.gz
		○ compressed tar zcvf filename.tar.gz targetname
	
5. Shutdown and restart: shutdown -h now, shutdown -r now
6. Start the server httpd: httpd service start
7. Clear screen ctrl + l
8. Ubuntu View the version number: sudo lsb_release -a
9. apache2 start and stop: https://www.cyberciti.biz/faq/star-stop-restart-apache2-webserver/
	•  systemctl start apache2.service
10. cat: view the file cat filename; create a file cat >filename
11. View the process: ps -ef, filter by grep: ps -ef | grep nginx. The | is called a pipe, which means: treat the result of the previous command as the input of the next command; grep is full-text regular matching printing, and nginx is its parameter
12. Add as system service: http://blog.csdn.net/awj3584/article/details/38036539
13. File transfer method: https://www.cnblogs.com/wfwenchao/p/6008959.html
	• rsync : rsync -av [email protected]: /ibos/bak/data.tar.zg / ibos / bak /
14. Check the folder size: du xxx/ , du -sh xxx/ (do not display other sub-files)
15. Install jdk (java):
	• Install JDK with yum
	yum search java|grep jdk
	yum install java-1.7.0-openjdk (select the version and install it)
	.set environment variables
	
	[root@localhost ~]# vi /etc/profile
	
	Add the following to the profile file
	
	#set java environment
	JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
	JRE_HOME=$JAVA_HOME/jre
	CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
	PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
	export JAVA_HOME JRE_HOME CLASS_PATH PATH
16. Test address and port: telnet ip port: telnet 45.111.222.2 4444 You can also use online port scanning (Google online port scanning)
17. Check the port occupancy and kill: lsof -i:4444 netstat -anp|grep 4444 kill -9 15001
	• netstat -nupl (UDP type port)
	• netstat -ntpl (TCP type port)
	a means all, n means do not query dns, t means tcp protocol, u means udp protocol, p means query occupied programs, l means query listening programs
	• netstat -ntpl|grep 3306 //This means to find the process in the listening state with port number 3306
18. Create a connection command ln -s Soft link: ln -s source file (existing file) object file (non-existing link): ln -s www2 www
19. Compile the installer from source code: http://blog.csdn.net/u010657789/article/details/51789209
20. Modify dns: vi /etc/resolv.conf
21. Pagoda Linux Control Panel
22. Closing the window can still run in the background:
	• screen: http://man.linuxde.net/screen  http://bg.artuion.com/linux/325.html
		○ Installation: yum install screen -y
		○ Create a session: screen -S yourname
		○ Then you can enter the command and close the window
		○ List existing sessions: screen -ls
		○ Reconnect the session: screen -r 12865xxx
		○ screen -d yourname -> detach a session remotely
		○ Create a window: Under screen, Ctrl+c is to create a new window
		Can -> Next, switch to the next window
		Cap -> Previous, switch to the previous window
		Ca 0..9 -> switch to the 0..9th window
23. Set/cancel proxy
		○ export http_proxy=127.0.0.1:8080
		export https_proxy=127.0.0.1:8080
		(Specify the proxy server addresses used by the http and https protocols respectively. Generally, there is ss or other software on the server monitoring 127.0.0.1:8080, so that it can be accessed through the software)
		To cancel this setting:
		unset http_proxy
		unset https_proxy
		To set http/https proxy in Linux system, add the following environment variables in /etc/bashrc or /etc/profile
		
24. Prevent ssh violent login denyhosts
	• http://blog.csdn.net/hjd199464/article/details/78315909
	• http://blog.csdn.net/wanglei_storage/article/details/50849070
	• Question: http://blog.51cto.com/linuxroad/673425
25. Disk view: df -hl
26. When accessing php as a file: https://blog.csdn.net/u013381397/article/details/77891947
        location ~ .*\.(php|php5)?$
        {
                #fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
	• Means: Rule: Any access with php suffix, nginx will give these access to fastcgi_pass, and fastcgi_pass is at 127.0.0.1:9000.
27、OOPS: vsftpd: refusing to run with writable root inside chroot ()  http://blog.51cto.com/ggvylf/1658850
28. It is the command to check and repair the linux file system: fsck -y /xxxxx mount  
29. php-fpm restart: find the master process of php-fpm, and then kill, as follows
ps -ef | grep php-fpm
kill -USR2 xxxx(pid)
30. View phpinfo under Linux: php -r 'phpinfo();'

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325361323&siteId=291194637