码迷,mamicode.com
首页 > 其他好文 > 详细

取文件权限以及取服务器ip的方法归纳

时间:2017-05-17 15:19:22      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:取文件权限以及去服务器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


本文出自 “大鸟地带-点滴积累” 博客,谢绝转载!

取文件权限以及取服务器ip的方法归纳

标签:取文件权限以及去服务器ip的方法归纳

原文地址:http://09112012.blog.51cto.com/4813132/1926550

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!