1. 程式人生 > >Linux操作系統基礎知識(五)

Linux操作系統基礎知識(五)

狀態 -exec acer res ifconfig 查找 mas 配置文件 update

ifconfig 命令
查看網絡信息
eth0 eth1
em1 em2
p2p2 p2p3

systemctl status network 查看網絡狀態
systemctl start network
systemctl stop network
systemctl restart network

網絡管理
網絡管理
設置ip
setup
service network restart
網卡配置文件
/etc/sysconfig/network-scripts/ifcfg-eth0

ifconfig eth0
ifconfig eth0 10.10.10.10

ifconfig eth0 down
ifconfig eth0 up
ifdown eth0
ifup eth0

ifdown eth0 || ifup eth0 前一個命令正確執行,後一個命令不執行
ifdown eth0 && ifup eth0 前一個命令必須正確執行,然後執行後一個命令
ifdown eth0 ; ifup eth0 不管前一個命令是否正確執行,後一個命令都要執行

網卡別名
ifconfig eth0:0 10.10.10.10
永久保存
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0:0
vim ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=none
HWADDR=00:0c:29:d5:0b:2b
ONBOOT=yes
IPADDR=10.10.10.10
NETMASK=255.255.255.0
GATEWAY=10.10.10.1
TYPE=Ethernet

service netwrok restart

route -n
route add default gw 192.168.1.254
route del default gw 192.168.1.254

traceroute www.baidu.com

arping 192.168.1.254

arp

ping

ip addr show

主機名
hostname
hostname robin.com
/etc/sysconfig/network 主機名配置文件
HOSTNAME=robin.com

vim /etc/hosts
192.168.1.254 robin.com

開啟路由轉發功能
cat /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward


查找命令
1.which
2.whereis
3.grep
4.locate(依賴updatedb)
5.find
find / -name initrd.img
find / -type p -ls
find / -links 10 -ls
find /home -user robin -ls
find /home -group sal -ls
find /home -nogroup -ls
find /home -nouser -ls
find /home \( -nouser -a -nogroup \) -ls
find /home \( -nouser -o -nogroup \) -ls
find /home -nouser -exec rm -rf {} \;
find /home -nogroup -ok rm -rf {} \;

find /home/test/ -size 300M
find /home/test/ -size +300M
find /home/test/ -size -300M
find /home/test/ -size +150M -a -size -350M
find /home/test/ -size -150M -o -size +350M

touch -m -d 20101010 aa.txt
touch -m -t 201010101010.10 aa.txt
find /home/test/ -mtime 5
find /home/test/ -mtime +8
find /home/test/ -mtime -8
find /home/test/ -mtime +2 -a -mtime -10
find /home/test/ -mtime -2 -o -mtime +10

find /home/test -perm 500 正好匹配
+500 任意匹配
-500 完全匹配

find / -type f | xargs file
cut -d: -f 1 /etc/passwd | xargs
cut -d: -f 1 /etc/passwd | xargs mkdir

Linux操作系統基礎知識(五)