apache=====================
1.启动apache
/opt/sudytech/apache2/bin/apachectl start apache
2.重启apache
/opt/sudytech/apache2/bin/apachectl restart
3.停止apache
/opt/sudytech/apache2/bin/apachectl stop
0如果Apache已经安装成Linux服务0
1.启动apache
service httpd start
2.重启apache
service httpd restart
3.停止apache
service httpd stop
tar========================
1.将文件解压到指定目录(指定的解压目录结尾可以没有"/")
tar -zxvf WebplusPro.tar.gz -C /opt/sudytech/apache-tomcat/webapps/
2.将文件压缩到指定目录(压缩的目标文件如果用绝对路径/opt/sudytech/WebplusPro的形式,压缩文件会带有opt,sudytech的目录)
tar -zcvf /opt/sudytech/WebplusPro.tar.gz WebplusPro
3.打包文件,排除指定文件夹(排除_upload,在upload后面不能加"/")
tar -zcvf ROOT20170510.tar.gz --exclude=ROOT/_upload ROOT
zip========================
1.压缩并指定目录(压缩的目标文件如果用绝对路径/opt/test/_web的形式,压缩文件会带有opt,test的目录)
zip -r /opt/test/a.zip /opt/test/_web
2.解压并指定目录
unzip /opt/test/a.zip -d /opt/test/
unzip /opt/test/a.zip //如果解压在当前目录,直接使用unzip
MySQL======================
1.查看MySQL是否启动
ps aux|grep mysqld
2.执行MySQL的sql脚本(导入)
/opt/sudytech/mysql/bin/mysql -uroot -p12344 webplus3_v1_4_7_5 < /opt/webplus3_v1_4_7_5.sql;
use database; source /opt/sudytech/aaa.sql;
3.导出数据库到脚本(导出)
/opt/sudytech/mysql/binmysqldump -uroot -p12344 dabaseName > fileName.sql
/opt/sudytech/mysql/binmysqldump -uroot -p12344 dabaseName tableName > fileName.sql (1导出某个表的数据1)
4.查看表结构
desc T_MO_APPSTRATEGY;
5.清空表数据
truncate table t_mo_microapp;//删除表数据,释放空间,不删除定义
delete from t_mo_microapp;//删除表数据,不释放空间,不删除定义
drop table t_mo_microapp;//删除表数据,释放空间,删除定义
6.授权语句
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.10.122' IDENTIFIED BY '12344' WITH GRANT OPTION;
iptables====================
1.查看防火墙状态
service iptables status
2.关闭防火墙
service iptables stop
3.启动防火墙
service iptables start
4.从防火墙开放80端口
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables restart
5.centos7 操作服务器防火墙
启动:systemctl start firewalld
查看状态:systemctl status firewalld
停止:systemctl disable firewalld
禁用:systemctl stop firewalld
查看所有打开的端口:firewall-cmd --zone=public --list-ports
开启端口:firewall-cmd --zone=public --add-port=80/tcp --permanent
(--permanent永久生效,没有此参数重启后失效)
重新载入:firewall-cmd --reload
查看:firewall-cmd --zone= public --query-port=80/tcp
删除:firewall-cmd --zone= public --remove-port=80/tcp --permanent
显示状态: firewall-cmd --state
wget=======================
1.(内网)服务器下载文件(以a.zip命名,下载到当前目录)
wget -o a.zip http://170.18.10.46:4690/opt/sudytech/redis-2.8.17.tar.gz
scp========================
1.(内网)从服务器 59.76.83.72 拷贝文件到当前服务器的目录(root是另一台服务器用户,会提示输入另一台服务器的密码)
scp root@59.76.83.72:/opt/sudytech/apache-tomcat-6.0.35/webapps/ROOT20170621.tar.gz /opt/sudytech/apache-tomcat-6.0.35/webapps/
2.从本地服务器拷贝到远程服务器
scp /opt/sudytech/apache-tomcat-6.0.35/webapps/ root@59.76.83.72:/opt/sudytech/apache-tomcat-6.0.35/webapps/ROOT20170621.tar.gz
mount======================
1.服务器挂载,2台服务器链接同一个数据库,当前服务器执行语句,图片资源从另一台服务器获得
mount -o rw 59.76.83.72:/opt/sudytech/apache-tomcat-6.0.35/webapps/ROOT/_upload /opt/sudytech/apache-tomcat-6.0.35/webapps/ROOT/_upload
netstat====================
1.查看端口占用情况
netstat -apn|grep 8080
telnet=====================
1.查看端口是否可以访问
telnet www.baidu.com 80 | telnet 127.0.0.1 8080
date=======================
1.date -s "2017-05-26 13:27:50"
修改完后要 "clock -w" 命令,否则重启后会还原
vi=========================
1.vi /usr/local/file.js
2.使用a,A,o,O,i,I进入编辑模式
3.编辑完成,按esc返回命令模式
4.命令模式下,(以下常用)
:w 保存不退出vi
:q 退出vi
:w! 强制保存
:q! 强制退出vi,当文本改变,却不想保存
:wq 保存并退出
touch=======================
1.创建一个file.js文件
touch /usr/local/file.js
df==========================
1.查看磁盘内存
df -hl
chmod=======================
1.给/opt/sudytech/WebplusPro的文件夹赋权限,-R递归子文件夹
chmod -R 777 /opt/sudytech/WebplusPro
2.给当前目录下的.sh文件的所有者增加可执行权限(在tomcat启动时,执行startup.sh遇到没有权限的情况,进入bin目录,执行语句)
chmod u+x *.sh (u代表所有者,x代表执行权限。 + 表示增加权限)
tail========================
语法:tail [ -f ] [ -c Number | -n Number | -m Number | -b Number | -k Number ] [ File ]
1.查看文件webplus.log的最后100行
tail -n 100 webplus.log
mv和cp======================
可以使用mv和cp来修改文件名称
1.mv aaa.txt bbb.txt (直接修改,源文件不在)
2.cp aaa.txt bbb.txt (赋值一份修改,源文件还在)
vim========================
命令模式下,大写的G,跳转到最后一行
命令模式下,/user 查询“user”
命令模式,按a,进入编辑模式
编辑模式,按Esc进入命令模式
命令模式,按:wq,:q 等,退出
1、按v进入可视模式,移动光标选中需要复制的行;
2、使用y复制选中块到缓冲区(剪切选中块使用d);
3、将光标移动到粘贴的位置,按p即可。
复制多行并粘贴到指定位置后,可能需要进行多行缩进。多行缩进步骤如下:
1、按shift+v进入可视模式,移动光标选中需要缩进的行;
2、使用>向右缩进,使用<向左缩进(注意使用符号<和>要按住shift,不然就变成了,和.)。
nginx========================
1.启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2.关闭
1>快速停止nginx
./nginx -s stop
2>完整有序的停止
./nginx -s quit
3>从容停止
ps -ef|grep nginx
kill -QUIT 2072
4>快速停止
ps -ef|grep nginx
kill -TERM 2072
或者
kill -INT 2132
5>强制停止
pkill -9 nginx
3.重启前验证配置文件
1>进入nginx安装目录sbin下,输入命令./nginx -t
2>./nginx -t -c /path/to/nginx.conf
出现如下提示,表示可用
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4.重启服务
1>./nginx -s reload 修改配置后重新加载生效
2>kill -HUP 9999 平滑重启(9999是master的进程号)
rabbitmq========================
1.开启服务在控制台执行(关闭终端一段时间后服务会停止)
rabbitmq-server start
2.开启服务和节点,且服务已后台程序执行
rabbitmq-server -detached
3.关闭服务并关闭节点
rabbitmqctl stop
4.关闭服务但是不关闭节点
rabbitmqctl stop_app
5.节点开启的情况下,开启服务
rabbitmqctl start_app
6.查看节点状态
rabbitmqctl status
7.开启web
rabbitmq-plugins enable rabbitmq_management
8.查看所有用户
rabbitmqctl list_users
9.新增一个用户
rabbitmqctl add_user ang ang123
10.给用户赋权(administrator是超级管理员)
rabbitmqctl set_user_tags ang administrator
zookeeper========================
1.启动服务,Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
./zkServer.sh start
2.客户端连接
./zkCli.sh -server localhost:2181
如果连接本机,直接zkCli.sh
3.查看状态
./zkServer.sh status
4.关闭服务
./zkServer.sh stop
Linux操作手册--Linux常用命令记录
最新推荐文章于 2025-08-08 09:40:01 发布