Debian8初始环境配置(VPS到手必备命令)

一键命令

放在顶部,方便使用.dpkg-reconfigure dash选择框请选NO

dpkg-reconfigure dash;sed -i '/PS1=/d' ~/.bashrc;sed -i '/umask/d' ~/.bashrc;echo 'PS1="\[\033[38;5;11m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h:\[$(tput sgr0)\]\[\033[38;5;6m\][\w]\[$(tput sgr0)\]\[\033[38;5;1m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"' >> ~/.bashrc;echo 'umask 022' >> ~/.bashrc;source ~/.bashrc;(echo 5;sleep 1;echo 9;sleep 1;echo 1;sleep 1;echo 1;)|tzselect;TZ='Asia/Shanghai';export TZ;date;cp -r /etc/apt/sources.list /etc/apt/sources.list.bak;echo "deb http://archive.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list;cat /etc/apt/sources.list;apt-get update;apt-get install -y vim wget curl screen unzip bzip2 psmisc;screen -S install;

这一键命令做了这些事:

  • 默认dash改为bash
  • shell 彩色配置
  • 时区设为东八区
  • 修复及更新软件源
  • 安装常用软件包

接下来是一些我常用的命令,你可以选择输入.

修改root密码为yourpassword

(echo yourpassword;sleep 1;echo yourpassword)|passwd root;

修改SSH端口为2222

sed -i 's/Port 22/Port 2222/g' /etc/ssh/sshd_config;
service ssh restart;

删除swap

sed -i '/swap/s/\(^\)/\1#/' /etc/fstab;

修改主机名为xxxx

host_name="xxxx";
echo $host_name > /etc/hostname;
cat /etc/hostname;hostname $host_name;hostname;

设置多IP

sed -i 's/allow-hotplug eth0/auto eth0/g' /etc/network/interfaces;
nano /etc/network/interfaces;

添加以下内容

auto eth0:0
iface eth0:0 inet static
        address 64.137.232.100
        netmask 255.255.255.0

auto eth0:1
iface eth0:1 inet static
        address 195.54.33.41
        netmask 255.255.255.0

auto eth0:2
iface eth0:2 inet static
        address 195.54.33.42
        netmask 255.255.255.0

auto eth0:3
iface eth0:3 inet static
        address 195.54.33.43
        netmask 255.255.255.0

设置完后启用新网卡

ifup eth0:0
ifup eth0:1
ifup eth0:2
ifup eth0:3

标签: Debian8

添加新评论