输入net 显示网卡配置文件内容
1.临时-重新登录之后失效
[root@lidiao ~]# alias net='cat /etc/sysconfig/network-scripts/ifcfg-eth0'
[root@lidiao ~]# net
TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
UUID=fa77146b-1e0c-4544-8ecb-5a98a6ebfc41
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.201
PREFIX=24
GATEWAY=10.0.0.254
DNS1=10.0.0.254
DNS2=223.5.5.5
2.永久 /etc/profile
[root@lidiao ~]# tail -1 /etc/profile
alias net='cat /etc/sysconfig/network-scripts/ifcfg-eth0'
让配置生效
[root@lidiao ~]# source /etc/profile
3.检查
[root@lidiao ~]# alias net
alias net='cat /etc/sysconfig/network-scripts/ifcfg-eth0'
三剑客老三-grep 过滤 在文件中进行查找。
vim 编辑文件 /oldboy
[root@lidiao~]# alias grep
alias grep='grep --color=auto' #centos 7下面 默认就有 CentOS6 5需要手动配置
-n 显示行号和内容
grep 'ssh' /tmp/vim.log
grep -n 'ssh' /tmp/vim.log
-w 按照单词进行过滤
[root@lidiao ~]# grep -w '22' /tmp/vim.log
ssh 22/tcp # The Secure Shell (SSH) Protocol
ssh 22/udp # The Secure Shell (SSH) Protocol
ssh 22/sctp # SSH
c1222-acse 1153/tcp # ANSI C12.22 Port
c1222-acse 1153/udp # ANSI C12.22 Port
[root@lidiao ~]# grep -w 'ssh' /tmp/vim.log
ssh 22/tcp # The Secure Shell (SSH) Protocol
ssh 22/udp # The Secure Shell (SSH) Protocol
x11-ssh-offset 6010/tcp # SSH X11 forwarding offset
ssh 22/sctp # SSH
netconf-ssh 830/tcp # NETCONF over SSH
netconf-ssh 830/udp # NETCONF over SSH
sdo-ssh 3897/tcp # Simple Distributed Objects over SSH
sdo-ssh 3897/udp # Simple Distributed Objects over SSH
tl1-ssh 6252/tcp # TL1 over SSH
tl1-ssh 6252/udp # TL1 over SSH
ssh-mgmt 17235/tcp # SSH Tectia Manager
ssh-mgmt 17235/udp # SSH Tectia Manager
-i ignore-case 过滤的时候忽略大小写
在文件中查找出包含ipaddr的行
[root@lidiao ~]# grep 'ipaddr' /tmp/vim.log
[root@lidiao ~]# grep -i 'ipaddr' /tmp/vim.log
IPADDR=10.0.0.201
grep 排除/取反 -v
我想找出不包含#的行
grep小结:
-n 显示行号和内容
-i 不区分大小写
-v 取反或排除
-w 按照单词进行过滤
grep命令练习题:
准备环境:
cat >/tmp/oldboy.txt<
alex
oldboyoldboy
alexoldboy
Oldboy oLdboy
OLDBOY
EOF
1.过滤出文件中包含oldboy的行及行号
2.过滤出文件中包含oldboy(不区分大小写)的行及行号
3.过滤出不包含oldboy(不区分大小写)的行
4.按单词过滤出oldboy(不区分大小写)
1.过滤出文件中包含oldboy的行及行号
[root@lidiao ~]# grep -n 'oldboy' /tmp/oldboy.txt
1:oldboy
3:oldboyoldboy
4:alexoldboy
2.过滤出文件中包含oldboy(不区分大小写)的行及行号
[root@lidiao ~]# grep -in 'oldboy' /tmp/oldboy.txt
1:oldboy
3:oldboyoldboy
4:alexoldboy
5:Oldboy oLdboy
6:OLDBOY
3.过滤出不包含oldboy(不区分大小写)的行
[root@lidiao~]# grep -iv 'oldboy' /tmp/oldboy.txt
alex
[root@lidiao ~]# cat /tmp/oldboy.txt
oldboy
alex
oldboyoldboy
alexoldboy
Oldboy oLdboy
OLDBOY
#####4.按单词过滤出oldboy(不区分大小写)
[root@lidiao ~]# grep -i 'oldboy' /tmp/oldboy.txt
oldboy
oldboyoldboy
alexoldboy
Oldboy oLdboy
OLDBOY
[root@oldboyedu59 ~]# grep -iw 'oldboy' /tmp/oldboy.txt
oldboy
Oldboy oLdboy
OLDBOY
tr 简单1对1替换
< 输入重定向符号
[root@lidiao ~]# tr 'o' '0' /tmp/oldboy.txt
tr: extra operand ‘/tmp/oldboy.txt’
Try 'tr --help' for more information.
[root@lidiao ~]# tr 'o' '0' < /tmp/oldboy.txt
0ldb0y
alex
0ldb0y0ldb0y
alex0ldb0y
Oldb0y 0Ldb0y
OLDBOY
[root@lidiao ~]# cat /tmp/oldboy.txt
oldboy
alex
oldboyoldboy
alexoldboy
Oldboy oLdboy
OLDBOY
[root@lidiao ~]# tr 'a-z' 'A-Z' < /tmp/oldboy.txt
OLDBOY
ALEX
OLDBOYOLDBOY
ALEXOLDBOY
OLDBOY OLDBOY
OLDBOY
文件属性说明
[root@lidiao ~]# ls -lhi
total 24K
134329384 drwxr-xr-x. 3 root root 15 Mar 28 15:21 1
134329379 -rw-r--r--. 1 root root 0 Mar 28 15:15 1.txt
134329380 -rw-r--r--. 1 root root 0 Mar 28 15:15 2.txt
134329381 -rw-r--r--. 1 root root 0 Mar 28 15:15 3.txt
134329382 -rw-r--r--. 1 root root 0 Mar 28 15:15 4.txt
134329383 -rw-r--r--. 1 root root 0 Mar 28 15:15 5.txt
1 2 3 4 5 6 7
1:inode索引节点属性信息
2:文件权限信息
3:硬链接数
4:属主,属组
5:文件大小
6:文件修改时间信息
7:文件名