aliyun - centos部署
云服务器已经安装了 java1.8.0_111版本
- 开机自动启动的服务
- apache
- mysql
- ftp服务器
- 防火墙 开机关闭
文件操作
-
pwd 当前的工作目录
-
exit 退出
-
ls -l 查看文件详情
-
ls -lh 友好格式
-
ls -lha 显示隐藏文件
-
cat >> hello.txt 创建文件 ,输入内容,ctrl+D,保存退出
- cat > hello.txt 覆盖文件
- cat hello.txt 查看文件内容
-
cat mysql_pass.sh | less 看见文件内容,向前翻页 b,向后翻页 空格,退出q
-
vi hello.txt 编辑文件,ctrl+f:向后翻页,ctrl+b:向前翻页,i:进入编辑,esc:退出编辑,wq:保存,q!:不保存
-
mkdir hello 创建hello文件夹
-
mkdir -p hello/ninghao 创建多级目录,没有创建,有覆盖
-
cp hello.txt hello-copy.txt 复制文件到当前目录
-
cp -t hello hello.txt hello-copy.txt 把hello.txt hello-copy.txt复制到hello的文件夹下
-
cp -r hello hello2 复制hello文件夹以及所在的所有文件到hello2中,hello2没有自动创建
-
rm hello-copy.txt 删除文件
-
rm -rf hello2 强制删除文件夹以及其中的文件
-
rm -rf hello/* 强制删除 hello文件夹下的所有文件,不包括隐藏文件
-
mv hello.txt hello 移动hello.txt 到 hello文件夹
-
mv world.txt world.bak 把world.txt重命名world.bak
-
mv hello/* . 移动hello文件夹下所有文件到当前目录
权限(ACL)
-
r(read)/4 查看权限
-
w(write)/2 写入
-
x(execute)/1 执行
-
d rwx r-x r-x 2 root root 4096 6月 10 16:37 hello
-
分别是当前文件,当前用户拥有者权限,用户组权限,其他用户权限,目录文件数量(包含隐藏文件数),文件目录的拥有者,用户组
-
useradd xiaoxue 添加用户
-
userdel xiaoxue 删除用户
-
groups xiaoxue 查看用户组
-
usermod -g root xiaoxue 修改用户组,xiaoxue修改为 root
-
groupadd ninghao 创建用户组ninghao
-
usermod -G ninghao xiaoxue 把xiaoxue添加ninghao用户组
-
usermod -aG xiaoxue xiaoxue xiaoxue添加更多的用户组,“a”追加的意思
-
usermod -G root xiaoxue 去掉xiaoxue的其他用户组,留下root
-
su xiaoxue 切换用户
-
chown xiaoxue hello.txt 更换文件拥有者是xiaoxue
-
chmod 664 hello.txt 修改文件权限
-
g,-,a,+, 用户组,减权限,所有用户,加权限
-
echo "来点新内容" >> hello.txt hello.txt添加新内容
添加购买的磁盘
- df -h
- fdisk -l
- fdisk /dev/xvdb 创建分区,输入n,p,1
- mkfs.ext3 /dev/xvdb1 格式化磁盘
- echo "/dev/xvdb1 /mnt ext3 defaults 0 0" >> /etc/fstab 重启后,自动挂载到mnt下
- cat /etc.fstab
- mount -a 挂载/etc/fstab下所有的东西
- sf -h
安装软件包(yum)
-
yum install httpd
-
systemctl start httpd.service 启动服务
-
systemctl status httpd.service 查看启动状态
-
systemctl stop httpd.service #停止
-
systemctl restart httpd.service #重启
-
systemctl enable httpd.service #开机启动
-
systemctl disable httpd.service #开机不启动
关于防火墙
Centos7 关闭防火墙
CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
最后重启系统使设置生效即可。
-
systemctl stop firewalld.service 关闭防火墙
-
systemctl disable firewalld.service
-
yum install iptables-services
-
systemctl enable iptables
-
vi /etc/httpd/conf/httpd.conf apache更改端口
-
重启系统
-
curl http://127.0.0.1 在控制台中内网访问
-
contrl + l 清理屏幕
mysql修改密码
-
systemctl restart mysqld.service
-
systemctl stop mysqld.service
-
systemctl status mysqld.service
-
systemctl start mysqld.service
-
systemctl enable mysqld 开机自动启动
-
systemctl disable mysqld 取消开机自动启动
-
cd /etc/my.cnf 最后一行添加 skip-grant-tables
-
mysql -uroot -p 登录
-
update mysql.user set authentication_string=password('123456') where user='root';
-
exit;
-
删除 skip-grant-tables
安装ftp服务器
-
yum install vsftpd
-
systemctl start vsftpd.service
-
systemctl enable vsftpd 实现开机启动
-
useradd -d /var/www/datafile -s /sbin/nologin fileftp
-
chown -R fileftp /var/www/datafile 更改文件的拥有者,“R”递归循环
-
chmod 775 /var/www/datafile
mysql 中导入sql
- create database bookstore charset utf8;
- mysql -uroot -p123456 bookstore < /var/www/datafile/bookstore.sql
解压文件
-
jar -xvf bookstore.war //解压war
-
tar -xvf file.tar //解压 tar包
-
tar -xzvf file.tar.gz //解压tar.gz
-
tar -xjvf file.tar.bz2 //解压 tar.bz2
-
tar -xZvf file.tar.Z //解压tar.Z
-
unrar e file.rar //解压rar
-
unzip file.zip //解压zip
查看端口被谁占用
- netstat -lnp|grep 8080
- kill -9 1777 #杀掉编号为1777的进程

浙公网安备 33010602011771号