linux常用命令集

#########  面向CentOS7/8  ##############
systemctl start httpd
# 启动httpd服务
systemctl status httpd
#查看http状态
systemctl list-unit-files
centos7查看开机自启项(左边是服务名称,右边是状态,enabled是开机启动,disabled是开机不启动。)
systemctl list-unit-files | grep enabled
# 仅查看启动项
firewall-cmd --zone=public --add-port=2333/tcp --permanent
# 开放2333端口
firewall-cmd --reload
# 重新载入防火墙
firewall-cmd --zone=public --query-port=2333/tcp
# 查看端口 

rewrite ^(.*)$ https://${server_name}$1 permanent; 
# centos7 nginx 80端口转发443

# ssh免密登录:


# centos7网络时间同步 

 yum -y install ntp ntpdate

 ntpdate cn.pool.ntp.org

 hwclock --systohc

# 递归更改目录及目录中文件权限(-R为递归,755为权限)
chmod -R 755 file-dir-name

#  查看用户
cut -d : -f 1 /etc/passwd

# 查看用户组
cut -d : -f 1 /etc/group

# 查看用户权限
id nfsuser(用户名)

# uid反查用户名
getent passwd uid

# 删除usertest这个用户
userdel -r usertest


######################  -----CentOS7部署LNMP环境-----    ###########################
# yum安装nginx
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum -y install nginx

systemctl start nginx && systemctl enable nginx

vim /etc/nginx/nginx.conf
gzip后面追加:
server {
 listen       80;
 root   /usr/share/nginx/html;
 server_name  localhost;
 #charset koi8-r;
 #access_log  /var/log/nginx/log/host.access.log  main;

 location / {
       index index.php index.html index.htm;
 }
 #error_page  404              /404.html;

 error_page   500 502 503 504  /50x.html;
 location = /50x.html {
   root   /usr/share/nginx/html;
 }
 #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

 location ~ .php$ {
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include        fastcgi_params;
 }
}

# 安装php
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64

systemctl start php-fpm && systemctl enable php-fpm

echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php

systemctl restart nginx

访问http://ip测试

# 安装mariadb
rpm -qa | grep -i mariadb

yum -y remove mariadb*

vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

yum -y install MariaDB-client MariaDB-server && systemctl start mariadb

systemctl enable mariadb

# 或者安装mysql5.7

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 
yum -y install mysql-community-server
systemctl start mysqld && systemctl enable mysqld
# 查看初始密码
grep 'temporary password' /var/log/mysqld.log
#登陆,这里使用初始密码进行登陆并修改密码;
mysql -uroot -p
#  设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySQLP@ssw0rd';
# 这里如果想要设置低复杂度的密码可使用:
set global validate_password_policy=0;和 set global validate_password_length=1;

mysql8.0使用:  set global validate_password.policy=0;  和set global validate_password.length=1;
mysql8.0创建用户
create user 'user'@'%' identified with mysql_native_password by 'MySQLUserP@ssw0rd';
grant all privileges on *.* to 'root'@'%' with grant option;

# 然后设置密码即可
# 刷新权限
FLUSH PRIVILEGES;
#输入 \q  退出

####################LNMP环境结束########################

# 配置java1.8环境变量

export JAVA_HOME=/usr/share/jdk1.8
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin


mysql初次启动初始密码
root下提升普通用户权限
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 系统信息 关机 (系统的关机、重启以及登出 ) 文件和目录 文件搜索 用户和群组 文件的权限 - 使用 "+" 设...
    zholeiv5阅读 748评论 0 0
  • 查看磁盘 df 、 df -h(使用何事的单位显示) 删除所有的日志:find /var -type f ...
    余头阅读 1,531评论 0 0
  • 一.查看文件 ls:查看目录及文件 ls -a:查看隐藏目录及文件,即所有的文件 ls /bin:查看根目录下的b...
    gangmiss阅读 2,713评论 0 0
  • 转载自:http://www.cnblogs.com/peida/archive/2012/12/10/28107...
    L白水飘萍阅读 3,966评论 0 5
  • linux,ubuntu 移动文件:mv [选项] "源文件(目录)" "目标文件(目录)"选项:-b 覆盖前备份...
    F_wind阅读 3,483评论 3 3

友情链接更多精彩内容