- 设备挂载
1 #将设备挂载到目录 2 [root@wen mnt]# mount /dev/cdrom /mnt 3 mount: block device /dev/sr0 is write-protected, mounting read-only 4 mount: /dev/sr0 already mounted or /mnt busy 5 mount: according to mtab, /dev/sr0 is already mounted on /mnt 6 #查看挂载情况 7 [root@wen mnt]# df -h 8 Filesystem Size Used Avail Use% Mounted on 9 /dev/sda2 8.6G 2.3G 5.9G 29% / 10 tmpfs 491M 0 491M 0% /dev/shm 11 /dev/sda1 190M 36M 145M 20% /boot 12 /dev/sr0 3.7G 3.7G 0 100% /mnt 13 #查看设备挂载内容 14 [root@wen mnt]# cd /mnt/ 15 [root@wen mnt]# ls 16 CentOS_BuildTag RELEASE-NOTES-en-US.html TRANS.TBL 17 EFI RPM-GPG-KEY-CentOS-6 images 18 EULA RPM-GPG-KEY-CentOS-Debug-6 isolinux 19 GPL RPM-GPG-KEY-CentOS-Security-6 repodata 20 Packages RPM-GPG-KEY-CentOS-Testing-6 21 22 #有人可能会问我的系统盘没有挂载,怎么还能访问呀。是因为文件在开机的时候帮你自动挂载了,看下面的UUID 23 [root@wen mnt]# cat /etc/fstab 24 25 # 26 # /etc/fstab 27 # Created by anaconda on Wed Aug 30 05:44:57 2017 28 # 29 # Accessible filesystems, by reference, are maintained under '/dev/disk' 30 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info 31 # 32 UUID=9cdba9f6-6cdd-4db0-9733-a8d13ffeced0 / ext4 defaults 1 1 33 UUID=33512319-2a0e-425a-a38b-8369ffe6644f /boot ext4 defaults 1 2 34 UUID=8e555db5-2819-4483-baf5-f59c15495e29 swap swap defaults 0 0 35 tmpfs /dev/shm tmpfs defaults 0 0 36 devpts /dev/pts devpts gid=5,mode=620 0 0 37 sysfs /sys sysfs defaults 0 0 38 proc /proc proc defaults 0 0
- 网卡及DNS的配置
查询网关
[root@wen ~]# cd /etc/sysconfig/network-scripts/
[root@wen network-scripts]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.59.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.59.2 0.0.0.0 UG 0 0 0 eth0 #网关IP
查看DNS
[root@wen network-scripts]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.59.2
---->setup "network configuration" ,"DNS configuration " 就是修改/etc/resolv.conf
修改网卡配置
[root@wen ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
以上命令相当于使用如下图形界面配置:
配置完保存,可查看配置文件
[root@wen ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
并重启网卡
[root@wen ~]#ifdown eth0 && ifup eth0
然后将SSH客户端IP改成上面刚刚重新配置的IP,重新连接,查看如下:
[root@wen ~]# ip add | grep 192
inet 192.168.59.130/24 brd 192.168.59.255 scope global eth0
小节:
- linux客户端DNS可以在网卡配置文件里设置(ifcfg-eth0)
- linux客户端DNS也可以在/etc/resolv.conf里设置
- 网卡里的设置DNS优先于/etc/resolv.conf,如果重启网络网卡的DNS会覆盖/etc/resolv.conf的设置
- 更改主机名
永久更改主机名,需同时修改以下两项:
- vi /etc/sysysconfig/network 建议使用sed -i 's#HOSTNAME=wen#HOSTNAME=fadewalk#g'
- hostname 主机名
[root@wen ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=wen [root@wen ~]# sed -i 's#HOSTNAME=wen#HOSTNAME=fadewalk#g' /etc/sysconfig/network [root@wen ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=fadewalk [root@wen ~]# hostname fadewalk