分类 Linux 下的文章

安装应用:
sudo apt-get update && sudo apt-get install screen nano

nano auth.sh

#!/bin/sh
while :; do
./authserver
sleep 20
done

nano world.sh

#!/bin/sh
while :; do
./worldserver
sleep 20
done

nano restarter.sh

#!/bin/bash
screen -AmdS auth ./auth.sh
screen -AmdS world ./world.sh


nano shutdown.sh
#!/bin/bash
screen -X -S "world" quit
screen -X -S "auth" quit


./restarter.sh; screen -r world
./shutdown.sh


screen -ls

退出 :键盘点击ctrl+a , 然后按d


1. Change to superuser

sudo su -

2. After increasing the boot volume size in oracle dash, you'll get a rescan command that will look something like this below

sudo dd iflag=direct if=/dev/oracleoci/oraclevda of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/readlink /dev/oracleoci/oraclevda | cut -d'/' -f 2/device/rescan

3. grow the partition (note: there is a space between sda and 1 here)

growpart /dev/sda 1

4. resize the filesystem (note: there is no space on sda1 this time

resize2fs /dev/sda1

you can confirm by checking disk free, with the command below

df -h

docker pull ubuntu:18.04 拉取镜像

docker run -it --rm ubuntu:18.04 bash 启动一个镜像的容器
"checkSum":123
docker images 列出镜像
docker image ls 列出镜像
docker image ls ubuntu 匹配列出
docker image ls --format "{{.ID}}: {{.Repository}}" 格式化
docker image ls -f since=mongo:3.2 mongo3.2之后

               before=mongo:3.2   mongo3.2之前
               

docker image ls -q 查询镜像ID列表

redis alpine 501ad78535f0 3 weeks ago 21.03 MB
docker image rm 501/501ad78535f0(短ID)
docker image rm redis 根据镜像名称删除
docker image rm $(docker image ls -q redis) 搜索批量删除
docker image ls -f dangling=true 查询虚玄镜像
docker images | grep "9cb7b79" | awk '{print $3}' | xargs docker rmi
docker images | grep " a070a71" | awk '{print $3}' | xargs docker rmi
docker images | grep "eada1cc" | awk '{print $3}' | xargs docker rmi
docker rm $(docker ps --all -q -f status=exited)
docker rmi $(docker ps -q)
du -sh *
docker images | awk '{print $3}'
docker image prune -a

docker ps | grep f44093d | awk '{print $1}'

docker run --name webserver -d -p 80:80 nginx

docker exec -it webserver bash
docker exec -it e25c5f82f182 bash

docker inspect publicisworldwide/redis-cluster
docker pull bitnami/redis-cluster
docker inspect docker.io/mysql:5.7
docker container prune
docker image prune
docker system prune
docker system info
docker system df -v

docker ps -a --no-trunc

docker stop $(docker ps -a -q)
docker stop $(docker ps | grep f44093d | awk '{print $1}')
docker stop $(docker ps | grep 'cx/cx-' | awk '{print $1}')
docker rm $(docker ps -a | grep 'doris-be' | awk '{print $1}')

docker rm $(docker ps -a -q)
docker-compose -f docker-compose.yml up -d --force-recreate
docker-compose -f docker-compose.yml up -d --force-recreate

  1. df [-ahikHTm] [目录或文件名]
    选项与参数:

-a :列出所有的文件系统,包括系统特有的 /proc 等文件系统;
-k :以 KBytes 的容量显示各文件系统;
-m :以 MBytes 的容量显示各文件系统;
-h :以人们较易阅读的 GBytes, MBytes, KBytes 等格式自行显示;
-H :以 M=1000K 取代 M=1024K 的进位方式;
-T :显示文件系统类型, 连同该 partition 的 filesystem 名称 (例如 ext3) 也列出;
-i :不用硬盘容量,而以 inode 的数量来显示

  1. du [-ahskm] 文件或目录名称
    选项与参数:

-a :列出所有的文件与目录容量,因为默认仅统计目录底下的文件量而已。
-h :以人们较易读的容量格式 (G/M) 显示;
-s :列出总量而已,而不列出每个各别的目录占用容量;
-S :不包括子目录下的总计,与 -s 有点差别。
-k :以 KBytes 列出容量显示;
-m :以 MBytes 列出容量显示;

作者:Seurat_Satija
链接:https://www.jianshu.com/p/085617c90ece
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

本次整理以阿里云开源镜像站为准

更换Base源

备份

1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载新的CentOS-Base.repo 到/etc/yum.repos.d/

1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

使其生效

12
yum clean allyum makecache

Epel源

Epel,Extra Packages for Enterprise Linux 的简称,企业版 Linux 附加软件包(以下简称 EPEL)是一个 Fedora 特别兴趣小组,用以创建、维护以及管理针对企业版 Linux 的一个高质量附加软件包集,面向的对象包括但不限于 红帽企业版 Linux (RHEL)、 CentOS、Scientific Linux (SL)、Oracle Linux (OL) 。

EPEL 的软件包通常不会与企业版 Linux 官方源中的软件包发生冲突,或者互相替换文件。EPEL 项目与 Fedora 基本一致,包含完整的构建系统、升级管理器、镜像管理器等等。

rpm 安装

1
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum 安装

1
yum -y install epel-release

直接下载repo

1
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

Rpmfusion源

rpm安装

1
rpm -Uvh https://mirrors.aliyun.com/rpmfusion/free/el/rpmfusion-free-release-7.noarch.rpm
1
rpm -Uvh https://mirrors.aliyun.com/rpmfusion/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm

yum 安装

1
yum localinstall --nogpgcheck https://mirrors.aliyun.com/rpmfusion/free/el/rpmfusion-free-release-7.noarch.rpm
1
yum localinstall --nogpgcheck https://mirrors.aliyun.com/rpmfusion/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm

Webstatic 源

webstatic主要是提供最新的Lnmp环境包下载和更新,提供稳定安全的Nginx,Mysql和PHP包

点击访问官网

点击访问官方源

rpm 安装

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

yum 安装

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

Nginx 官方源

官方源地址

rpm 安装

1
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Mysql官方源 & 安装Mysql办法

下载源

官网选择对应的包下载

例如

1
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装源

1
rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

检查当前仓库

1
yum repolist all | grep mysql

默认激活的为mysql57-community,对应Mysql 5.7

如需安装Mysql5.6版本,则需要修改

12
yum-config-manager --disable mysql57-communityyum-config-manager --enable mysql56-community

安装Mysql

1
yum install mysql-community-server

启动Mysql服务 & Mysql初始化

1
systemctl start mysqld.service

Mysql 5.7

超级用户帐户'root'@'localhost'被创建。超级用户的密码被设置并存储在错误日志文件中。要显示它,请使用以下命令

1
grep 'temporary password' /var/log/mysqld.log

登陆 并尽快修改密码 (密码至少包含一个大写字母,一个小写字母,一个数字和一个特殊字符,并且总密码长度至少为8个字符。)

12
mysql -u root -pmysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

Mysql 5.6

1
mysql_secure_installation