取文件權限以及取服務器ip的方法歸納

取服務器IP:

[root@www ~]# ifconfig etj0

etj0: error fetching interface information: Device not found

[root@www ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:DD:4A:5C  

          inet addr:192.168.137.222  Bcast:192.168.137.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fedd:4a5c/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:9958 errors:0 dropped:0 overruns:0 frame:0

          TX packets:7585 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:975189 (952.3 KiB)  TX bytes:869161 (848.7 KiB)

          Interrupt:19 Base address:0x2024 

 1、

[root@www ~]# ifconfig eth0 | awk -F "[ :]+" 'NR==2{print $4}'

192.168.137.222

 2、

[root@www ~]# ifconfig eth0 | sed -nr 's@^.*dr:(.*) B.*$@\1@gp'

192.168.137.222 

 3、

[root@www ~]# grep "IPADDR" /etc/sysconfig/network-scripts/ifcfg-eth0 | cut -d= -f2

192.168.137.222

4、

[root@www ~]# ifconfig eth0 | grep "inet addr" | cut -d: -f2 | cut -d" " -f1

192.168.137.222

5、

[root@www ~]# ifconfig eth0 | sed -nr '/inet addr/s@^.*dr:(.*) B.*$@\1@gp'

192.168.137.222 


取文件的權限:

[root@www ~]# stat /etc/hosts

  File: "/etc/hosts"

  Size: 158       Blocks: 8          IO Block: 4096   普通文件

Device: 802h/2050dInode: 260138      Links: 1

Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2017-05-16 09:26:35.004013181 +0800

Modify: 2010-01-12 21:28:22.000000000 +0800

Change: 2017-02-13 23:50:52.643899673 +0800


1.

[root@www ~]# stat /etc/hosts | sed -nr 's@^Access: \(0(.*)\/-.*$@\1@gp'

644

2.

[root@www ~]# stat /etc/hosts | awk -F[0/] 'NR==4{print $2}'

644


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章