跳至主要內容

Linux

LiCheng大约 1 分钟

Linux

  • 2018

Shell脚本👻

Ubuntu🐟

  • 允许root远程登入
  • vim /etc/ssh/sshd_config
  • Authentication 下面添加 PermitRootLogin yes
# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
  • Vm-Box NAT网络
  • 可以进行手动配置跟宿主机一样的ip也能互相ping通

镜像源😎

  • 腾讯

  • wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu18_sources.list

  • wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu20_sources.list

  • wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu22_sources.list

  • 更新缓存

  • apt-get clean all

  • apt-get update

Centos7🐔

自动化脚本🌈

Mysql8安装🌈

  • rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
  • wget https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
  • yum install mysql-community-server

Ffmpeg💒

Deepin🎁

  • 目前已安装到Ubuntu中使用

内存搭配🐸

常用命令👏

Date(时间)🌈

#设置时区
timedatectl set-timezone Asia/Shanghai
#查看当前时间
date +%Y/%m/%d-%H:%M

Crontab(定时)🍊

crontab -e 编辑任务
#实例1:每1分钟执行一次myCommand
* * * * * myCommand
#实例6:每晚的00:00重启smb
0 00 * * * /etc/init.d/smb restart

Tar(压缩)🗾

#解压 xx.tar.gz
tar -zxvf ${file.tar.gz}

Zip(压缩)🍒

# 压缩zip打包和子目录
zip -r -q -o ${file.zip} ${filePaht}

Lrzsz(上传文件)🎁

  • xFtp已完全替代
sz 文件名

Vim🐸

字体颜色变黄🌈

  • :nohl 即可回归正常

Awk🐯

获取docker容器id💒

docker images | awk 'NR == 1 {next}{print $1}'
docker images | awk 'NR == 1 {next}{print $3}'

使用awk命令导出所有镜像😆

#!/bin/bash
echo Hello World
list1=(`docker images | awk 'NR == 1 {next}{print $1}'`) #容器名
list2=(`docker images | awk 'NR == 1 {next}{print $3}'`) #容器id
list3=(`docker images | awk 'NR == 1 {next}{print $2}'`) #标签


# 格式: 容器名:标签.tar.gz
#echo $list1
#echo ${list1[1]}
for ((i=0;i<${#list1[@]};i++));do
        echo "docker save ${list2[i]} > ${list1[i]}:${list3[i]}.tar.gz"
        `docker save ${list2[i]} > ${list1[i]}.tar.gz`
done