取文件权限以及取服务器ip的方法归纳
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了取文件权限以及取服务器ip的方法归纳相关的知识,希望对你有一定的参考价值。
取服务器IP:
[[email protected] ~]# ifconfig etj0
etj0: error fetching interface information: Device not found
[[email protected] ~]# 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、
[[email protected] ~]# ifconfig eth0 | awk -F "[ :]+" ‘NR==2{print $4}‘
192.168.137.222
2、
[[email protected] ~]# ifconfig eth0 | sed -nr ‘[email protected]^.*dr:(.*) B.*[email protected]\[email protected]‘
192.168.137.222
3、
[[email protected] ~]# grep "IPADDR" /etc/sysconfig/network-scripts/ifcfg-eth0 | cut -d= -f2
192.168.137.222
4、
[[email protected] ~]# ifconfig eth0 | grep "inet addr" | cut -d: -f2 | cut -d" " -f1
192.168.137.222
5、
[[email protected] ~]# ifconfig eth0 | sed -nr ‘/inet addr/[email protected]^.*dr:(.*) B.*[email protected]\[email protected]‘
192.168.137.222
取文件的权限:
[[email protected] ~]# 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.
[[email protected] ~]# stat /etc/hosts | sed -nr ‘[email protected]^Access: \(0(.*)\/-.*[email protected]\[email protected]‘
644
2.
[[email protected] ~]# stat /etc/hosts | awk -F[0/] ‘NR==4{print $2}‘
644
本文出自 “大鸟地带-点滴积累” 博客,谢绝转载!
以上是关于取文件权限以及取服务器ip的方法归纳的主要内容,如果未能解决你的问题,请参考以下文章