1. Find the file location: find / -name filename -print
2. Remote login server: ssh username@ip eg: ssh [email protected]
Login server specified port: ssh username@ip -p port
When returning to the machine: exit;
3. Download files or folders remotely: scp username@servername:/path/filename /tmp/local_destination
eg:scp -r [email protected]:/yun/soft/tomcat7 /usr/local (download folder)
4. Upload files or folders remotely : scp /path/local_filename username@servername:/path
eg:scp -r /usr/local [email protected]:/yun/soft/tomcat7
5. Check the site space: df -h;
6. View all processes: top;
When killing a process: kill -9 process number
7. Database backup command: mysqldump -uroot -p database > savepath/*.sql
If mysqldump: command not find is reported, it can be solved in the following ways
The first step: find / -name mysqldump -print to find out the absolute path of mysqldump
The second part: ln -s path /usr/bin establishes a soft link, which is equivalent to a shortcut
The reason for this problem is that the Linux system will default to the /usr/bin directory to find commands
8. Database recovery command:
The first step: mysql -uroot -p to enter mysql
Step 2: use database to select the database to be restored
The third step: source path/*.sql executes the sql statement (path is the absolute path of the sql file)
9. Database startup and shutdown and restart commands: /etc/init.d/mysql start|stop|restart
10. vi command details: vi path/filename , then enter command mode by default, all input at this time are regarded as commands; at this time, press i or a again to enter edit mode, i means insert before the cursor, a means at the cursor After inserting, esc returns to command mode when finished; :wq saves and exits.
In addition, ctrl+shift+f next page, ctrl+shift+b previous page
11. Common methods to enhance the security of linux system:
The first type: strengthen the level of the root password, it is recommended to use an online password generator to generate the password, eg: %yTxBEj^PlL*IUgw
The second: Prohibit the use of root account for remote ssh login, first confirm that openssh server is installed, install and execute: apt-get install openssh-server; then modify the configuration file vi /etc/ssh/sshd_config, set PermitRootLogin to no; finally restart ssh service, service sshd restart.
第三种:修改ssh登陆的端口为非常用端口,如2211。首先,增加一个修改后的端口2211,vi /etc/ssh/sshd_config,增加Port=2211,重启ssh服务,service sshd restart,此时ssh将有两个工作端口号;编辑防火墙添加我们增加的新端口:/sbin/iptables -I INPUT -p tcp --dport 2222 -j ACCEPT,之后重启防火墙/etc/init.d/iptables restart,查看端口是否开放:/etc/init.d/iptables status;如果是ubuntu系统,直接使用ufw为防火墙增加开放端口sudo ufw allow 2211,使用ufw status查看端口开放情况;再使用ssh登陆当前端口号,如果登陆成功表示端口开放;最后再次编辑sshd_config,删除原来的登陆端口,重启ssh服务。
12.Ubuntu防火墙基本操作:
启动防火墙:sudo ufw enable; 关闭防火墙:sudo ufw disable
添加开放端口:fufw allow 2211; 删除添加的开放端口:ufw delete allow 2211;
查看开放端口情况:ufw status
13.查看各个文件夹的大小: du -sm /etc/*
14.centos7端口命令:
systemctl start firewalld
firewall-cmd --zone=public --add-port=2328/tcp --permanent
firewall-cmd --reload
firewall-cmd --state //running 表示运行
firewall-cmd --query-port=2328/tcp
systemctl restart sshd.service
systemctl status sshd.service
jps -lv |grep billing-service.jar 查看billing-service服务是否启动
less service.log 查看日志:pageUp/pageDown上下翻页
15. 查看系统版本命令: cat /etc/issue
16.linux本地文件夹同步:
rsync -zvrtopg -progress ./soft/ ./soft2/
第一个目录为待同步目录, 第二个目录为同步目标
远程文件夹同步:
rsync -zvrtopg -progress -e 'ssh -p 端口号' [email protected]:/文件目录/ 本机的目录地址
17. mysql
show profiles;
show profile cpu, block io for query ID;
18.中国移动网络访问服务器时断时续
具体操作步骤: vi /etc/sysctl.conf