命令收集

命令收集

# 创建用户kcadmin加入sudo权限
  useradd -r -m -s /bin/bash kcadmin
  passwd kcadmin
  usermod -aG sudo kcadmin

# 更改docker数据目录 因为ssd盘小要迁移/lib/docker当安装完成docker后执行如下
1 开机挂载数据盘
    fdisk -l
    mkfs.ext4 /dev/sdXXXX  
    mkdir -p /data
    blkid
    vim fstab
    UUID=xxxxxx  /data ext4 defaults 0 0 
    mount -a
2 迁移docker-datadir到/data/docker
    systemctl stop docker
    cd /var/lib/docker
    mv docker /data/
    ln -s /data/docker docker
    ll docker
3 重启docker
    systemctl enable docker
    systemctl start docker

# 通过软连接配置anaconda不同环境
        rm -f /usr/local/conda/envs/kcenv
    1 GPU use tensorflow
        ln -s /usr/local/conda/envs/gpuenv /usr/local/conda/envs/kcenv
    2 CPU use tensorflow
        ln -s /usr/local/conda/envs/mklenv /usr/local/conda/envs/kcenv
    3 headcount use python
        ln -s /usr/local/conda/envs/headcountenv /usr/local/conda/envs/kcenv

# 校验GPU服务器
    1 nvidia-smi
    2 nvcc –V  查看cuda-toolkit是否安装成功
    3 查看echo $PATH echo $LD_LIBRARY_PATH环境变量是否配置
    4 python -c 'import tensorflow as tf;print(tf.__version__)'验证tensorflow是否正常
    5 cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2查看cudnn版本是否正确

# 配置内网 pip 客户端
  vim /root/.pip.conf
    [global]
    index-url = http://192.168.174.136:8090/simple
    [install]
    trusted-host = 192.168.174.136

# 配置内网apt包源 客户端
    echo "deb [ arch=amd64 ] http://192.168.16.20:50001/ubuntu/ xenial main restricted universe multiverse" >/etc/apt/sources.list
    echo "deb [ arch=amd64 ] http://192.168.16.20:50001/ubuntu/ xenial-security main restricted universe multiverse" >>/etc/apt/sources.list
    echo "deb [ arch=amd64 ] http://192.168.16.20:50001/ubuntu/ xenial-updates main restricted universe multiverse" >>/etc/apt/sources.list
    echo "deb [ arch=amd64 ] http://192.168.16.20:50001/ubuntu/ xenial-backports main restricted universe multiverse" >>/etc/apt/sources.list
    apt-get update
    apt-get install -y  net-tools  iputils-ping
    rm -rf /etc/apt/sources.list.d/*

# FTP服务 命令
  1 上传文件夹或者文件到FTP:
      wput upload.txt ftp://kcadmin:kc@123456@15.112.148.201/test/
  2 下载文件夹或者文件到本地:【备注:-r递归子目录 -l默认五层子目录,-l0无限子目录】
      wget  -r -l0 --ftp-user=kcadmin --ftp-password=kc@123456 ftp://${ftp_ip}/kc_platform_cutvideo/latest/sits-calculate-cutvedio.jar 

# 内网的Maven通过代理下载jar包 配置
  修改Maven配置文件settings.xml,即可在内网中下载外网的jar包。
    <url>
    http://192.168.15.10:50000/nexus/content/repositories/central/
    </url>
    修改为
    <url>
    http://192.168.15.10:50000/nexus/content/groups/public/
    </url>

# 批量解压并制定目录后删除.zip压缩文件! 
    for i in `ls /root/*.zip`
    do
    filename=$(echo $i | cut -d'_' -f2)
    mkdir /root/a_$filename
    unzip $i -d "a_$filename"
    done
    rm -rf /opt/tas/bin/*.zip

# 如何得到网卡的MAC地址 
    arp -a | awk '{print $4}' 

# 如何得到网卡的IP地址
    ifconfig eth0 |awk '/inet addr/ {split($2,x,":");print x[2]}' 

# 遍历特定的目录内的文件内容 找出有特定字符行的文件
    grep "DBName" -rl /root

# linux系统修改时区,时间自动同步
  1、调整时区
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  2、手动调整时间(需要ntpdate)
    yum install -y ntpdate
    ntpdate us.pool.ntp.org
  3、加入定时计划任务,每天进行同步一次:
    cd /etc/cron.daily
    vim ntpdateup.sh
#! /bin/bash
/usr/sbin/ntpdate -s us.pool.ntp.org &> /dev/null
/usr/sbin/hwclock --systohc &> /dev/null

# 提取IP地址:
    1 ifconfig eth0 | grep "inet addr" | awk '{print $2}' | tr -d "addr:"         
    2 ifconfig eth0 |grep 'inet addr:'|sed 's/.*addr://'|sed 's/\([B|M]\).*//'     
    3 ifconfig eth0 | sed -n '2p' | awk '{print $2}' | tr -d "addr:"   
    4 ifconfig eth0 | sed -n 2p  | sed 's/^.*addr://g' | sed 's/Bcast.*$//g'
    5 ifconfig eth0 | grep "inet addr" | awk -F[:" "]+ '{print $4}'

# 查看物理CPU的个数:
    cat /proc/cpuinfo | grep "physcal id" | sort | uniq | wc -l

# 查看逻辑CPU个数 
    cat /proc/cpuinfo | grep "processor" | wc -l

# 查看单个CPU是几核 
    cat /proc/cpuinfo | grep "coress" | uniq

# 查看CPU主频 
    cat /proc/cpuinfo | grep MHz | uniq

# 按照内存从大到小排列进程 
  ps -eo "%C : %p : %z : %a" | sort -k5 -nr

# 查看当前有哪些进程;查看进程打开的文件
  ps -A ;lsof -p PID

# 消除vim中的^M的几种方法
    1 dos2uninx filename 
    2 sed -e 's/^M//' filename
    3 vim中 :s/^M//g
    4 tr -s "\r\n" "\n" < file > newfile

# 清除所有arp缓存
    arp -n|awk '/^[1-9]/ {print "arp -d "$1}'|sh

# 绑定已知的arp地址
    cat /proc/net/arp | awk '{print $1 " " $4}' |sort -t. -n +3 -4 > /etc/ethers

#将当前目录文件名全部转换成小写
    for i in *; do mv "$i" "$(echo $i|tr A-Z a-z)"; done

# 清空LINUX BUFFER CACHE
    sync  && echo 3 >/proc/sys/vm/drop_caches

posted on 2025-11-05 10:51  luokeli  阅读(3)  评论(0)    收藏  举报

导航