Linux
1)防火墙设置:
作用:保护服务器安全
设置防火墙规则
开放端口
关闭防火墙
安装: yum install firewalld
启动:service firewalld start
检查状态:service firewalld status
关闭或禁用防火墙:service firewalld stop/disable
防火墙操作基本命令:firewall-cmd --help 列表相关可以查看
2)提权和文件上传下载操作命令:
root账号下输入visudo 按下G,跳到最后一行,往上翻找到
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
然后添加指定sudo权限的用户名即可
%user ALL=(ALL) ALL
按下:x或wq退出保存
从本地上传到远程主机
scp 文件名 用户@ip:/制定目录/
从远程下载到本地目录
scp 用户@ip:/制定目录/文件 本地制定目录
3)Apache的安装(WebServer)
安装:yum install httpd
启动:service httpd start
停止:service httpd stop
ps -ef | grep httpd 查看特定协议启动情况
sudo netstat -anpl | grep 'http' 网络统计
配置虚拟主机:
sudo vim httpd.conf
<VirtualHost *:80>
ServiceName www.imoc.test
DoucmentRoot /data/www
sudo service httpd restart
4)Nginx基本操作
首先下载依赖包:sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装:yum install nginx
启动:service nginx start
停止:service nginx stop
重载:service nginx reload
5)Linux 查找命令:
a. find <指定目录> <指定条件> <指定动作>
b. whereis 命令搜索linux系统中的所有可执行文件 whereis grep
c. which 命令查看系统命令是否存在,并且返回系统命令所在位置 which grep
d. type 查看某个命令是否为系统自带的命令 type grep
6) msyql服务安装:
yum search mysql
yum remove mariadb.x86_64
下载源:
wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
yum search mysql 搜索mysql服务
安装mysql源到系统
yum localinstall mysql-community-server.x86_64
yum install mysql-community-server.x86_64
启动msyql
service mysqld start
重启mysql
service mysqld restart
关闭mysql
service mysqld stop
找到初始密码
cat /var/log/mysqld.log | grep password
登录mysql
mysql -uroot -p
pwd:
第一步修改mysql密码
set global validate_password_policy=0;
set global validate_password_length=1;
SET PASSWORD = PASSWORD('123456');
刷新权限
flush privileges;
或者 exit;
重启mysql服务
service mysqld restart;
开启mysql远程连接
use mysql;
select Host,User from user \G;
update user set Host = '%' where Host='localhost' and User = 'root';
flush privileges;
或者 exit;
service mysqld restart;
若防火墙开启许关闭防火墙(或者开放数据库端口一般是3306)
ps -ef | grep firewall
service firewalld stop
开启genelog
可以记录所有数据库操作
设置日志存储位置
set global general_log_file="/tmp/general.log";
开启
set global general_log=on;
关闭
set global general_log=off;
新建mysql用户
create user 'test'@'%' identified by '123456';
赋权
grant all privileges on *.* to 'test'@'%' identified by '123456' with grant option;
grant select, insert,update,delete ^Cn *.* to 'test'@'%' identified by '123456' with grant option;
收回权限
revoke all privileges on *.* from test;
找回密码
编辑my.cnf文件
vim /etc/my.cnf
skip-grant-tables
跳过密码验证
重启mysql服务
service mysqld restart
mysql -uroot -p
use mysql;
update user set authentication_string=password("123456") where user='root';
flush privileges;
7)Memcached的基本操作(11211)
安装:yum install memcached
启动:memcached -d(启动一个守护进程-后台运行) -l(监听地址) -m(大小) -p(端口)
停止:kill pid
telnet + ip:port 可以测试连接 ,也可发送报文
set test 0 60(过期时间) 5(位数)
hello
get test
delete test
get test
8)Redis 的基本操作(6379)
安装 源码编译安装(生产环境推荐源码安装)
启动:redis-server start/restart
停止:redis-server stop
客户端:redis-client
Redis不仅支持k/v类型的数据,同时还提供list、set、hash等数据结构的存储
Redis支持数据的备份,即master-slave模式的数据备份
Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用
telnet + ip:port 可以测试连接 ,也可发送报文
set test 0 60 5
源码安装redis:
wget + redis源码地址
tar -zxvf + 文件包
进入解压后的文件
编译安装:
make
make malloc = libc
make install
命令介绍:
redis-server Redis服务器端启动程序
redis-cli Redis客户端操作工具。也可以用telnet根据其纯文本协议来操作
redis-benchmark Redis 性能测试工具
redis-check-aof 数据修复工具
redis-check-dump 检查导出工具
启动:./redis-server
set key value
get key
lpush key value
lrange key start_index end_index
(推荐菜鸟教程~~)
9)git版本控制工具
安装
yum install git
生成 ssh key
git 命令自动补全设置:
git clone git@github.com:git/git.git
复制git-completion.bash文件
cp contrib/completion/git-completion.bash /etc/bash_completion.d/
加载bash脚本
source /etc/bash_completion.d/git-completion.bash
从远程仓库拉取
git 命令 --help
git config
git clone
git fetch
git rebase
推送远程仓库
git init
git remote
添加远程仓库
git remote add origin git_ip
拉取远程代码
git fetch
合并
git rebase origin/master
推送至远程仓库
git push origin:origin
git commit
git push
git status
配置用户
git config --global user.email ""
git config --global user.name ""