1.修改主機(jī)名
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server1
2.修改ip地址
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes #是否開機(jī)啟用
BOOTPROTO=static #ip地址設(shè)置為靜態(tài)
IPADDR=192.168.0.101
NETMASK=255.255.255.0
service network restart
3.修改ip地址和主機(jī)名的映射關(guān)系
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.101 server1
4.關(guān)閉iptables并設(shè)置其開機(jī)啟動/不啟動
service iptables stop
chkconfig iptables on
chkconfig iptables off
5.解決克隆后eth0不見的問題
直接修改 /etc/sysconfig/network-script/ifcfg-eth0
刪掉UUID HWADDR?
配置靜態(tài)地址?
然后:
rm -rf /etc/udev/rules.d/70-persistent-net.rules
然后?reboot
6.修改靜態(tài)地址后發(fā)現(xiàn)無法ping外網(wǎng)
需要設(shè)置網(wǎng)關(guān)
route add default gw 192.168.33.1
7.添加nameserver
vi /etc/resolv.conf
nameserver192.168.33.1
8.很多場景需要使用非root用戶linux常用命令,所有創(chuàng)建一個bigdata用戶:
useradd bigdata
8.1為bigdata用戶添加密碼:
echo 123456 | passwd --stdin bigdata
8.2將bigdata添加到sudoers
echo "bigdata ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/bigdata
chmod 0440 /etc/sudoers.d/bigdata
8.3解決sudo: sorry, you must have a tty to run sudo問題linux常用命令,在/etc/sudoer注釋掉 Default requiretty 一行
sudo sed -i 's/Defaults requiretty/Defaults:bigdata !requiretty/' /etc/sudoers
8.3創(chuàng)建一個bigdata目錄
mkdir /{bigdata,data}
8.4給相應(yīng)的目錄添加權(quán)限
上一個教程:linux命令解釋器
下一個教程:linux圖形界面怎么用命令切換到命令行