yum update -y
rpm -q kernel
package-cleanup --oldkernels --count=1 -y
標籤彙整: centos
centsos 基本安裝參考指令
#更新
yum update -y && yum autoremove -y
#安裝常用工具,如vim/wget/openssh-server/nslookup/ping/ifconfig
yum install -y git vim wget openssh* nfs-utils nfs-utils-lib open-vm-tools net-tools bind-utils iputils yum-utils
#設定ssh
mkdir -p ~/.ssh
cat <<EOF > ~/.ssh/config
Host *
StrictHostKeyChecking no
EOF
#關閉swap
SWAPLINE=$(cat /etc/fstab | grep swap | awk '{print $1}' | sed 's/\//\\\//g')
sed -i "s/$SWAPLINE/#$SWAPLINE/g" /etc/fstab
swapoff -a
free -m
#關閉SELINUX
setenforce 0
sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config
systemctl disable firewalld.service
systemctl disable libvirtd.service
#Forward Policy
iptables -P FORWARD ACCEPT
#關閉防火牆
iptables -P FORWARD ACCEPT
systemctl stop firewalld
systemctl disable firewalld
#NTP校時
yum install ntp ntpdate ntp-doc -y
cat > /etc/ntp.conf <<EOL
restrict 127.0.0.1
restrict ::1
server time.stdtime.gov.tw minpoll 1 maxpoll 3
server tock.stdtime.gov.tw minpoll 2 maxpoll 3
server watch.stdtime.gov.tw minpoll 3 maxpoll 4
server clock.stdtime.gov.tw minpoll 4 maxpoll 5
server tick.stdtime.gov.tw minpoll 5 maxpoll 6
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
EOL
systemctl stop ntpd
ntpdate time.stdtime.gov.tw
systemctl enable ntpd
systemctl start ntpd
ntpq -p
在centos 7上安裝nvidia docker
#安裝 docker-ce
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce-18.06.0.ce -y
systemctl enable docker && systemctl start docker
# 移除舊版nvidia-docker
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo yum remove nvidia-docker
# 加入repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
# 安裝 nvidia-docker2
sudo yum install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
# 測試
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
centos 7 change desktop icon size
small size
gsettings set org.gnome.nautilus.icon-view default-zoom-level small
list all size
gsettings range org.gnome.nautilus.icon-view default-zoom-level
refer: https://unix.stackexchange.com/questions/250266/rhel-7-gnome-shell-decrease-desktop-icon-size
install nfs server on centos
假設cntos ip是172.16.1.1,想要分享的資料夾是/volume1/nfs
只需要用下列指令就可以架設好nfs server
yum install nfs-utils -y
echo "/volume1/nfs 172.16.0.0/16(rw,sync,no_root_squash,no_all_squash)" >> /etc/exports
systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
client端部分只需要:
echo "172.16.1.1:/volume1/nfs /nfs nfs rw 0 0" >> /etc/fstab
mkdir -p /nfs
mount -a
禁止yum使用cn網域
使用如下指令,在fastestmirror.conf中,將.cn設定為exclude:
rm -r -f /var/cache/yum/timedhosts.txt
echo "exclude=.cn" >> /etc/yum/pluginconf.d/fastestmirror.conf