分类 玩转Linux 中的文章

linux中的权限

第1章 显示或设置网络相关信息 1.1 ip address 与ifconfig 类似 [root@znix ~]# ip address 1: lo: mtu 65536 qdisc noqueue state UNKNOWN     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00     inet 127.0.0.1/8 scope host lo     inet6 ::1/128 scope host        valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000     link/ether 00:0c:29:a8:e4:14 brd ff:ff:ff:ff:ff:ff     inet 10.0.0.201/24 brd 10.0.0.255 scope global eth0     inet6 fe80::20c:29ff:fea8:e414/64 scope link        valid_lft forever preferred_lft forever 1.2 显示第一块网卡 ip a s eth0 [root@znix ~]# ip a s eth0 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000     link/ether 00:0c:29:a8:e4:14 brd ff:ff:ff:ff:ff:ff     inet 10.0.0.201/24 brd 10.0.0.255 scope global eth0     inet6 fe80::20c:29ff:fea8:e414/64 scope link……

阅读全文

三剑客之sed&grep

第1章 练习题 1.1 第1题 取得/etc/hosts 文件的权限 如何取得/etc/hosts 文件的权限对应的数字内容,如-rw-r--r--  为 644,要求使用命令取得644 这样的数字。 1.1.1 方法一 awk 指定分隔符 [root@znix ~]# stat /etc/hosts |awk -F "[0/]" 'NR==4{print $2}' 644 1.1.2 方法二 stat  -c%a [root@znix ~]# stat -c%a /etc/hosts 644 1.2 第2题 目录的硬链接数 linux 下通过……

阅读全文

扩展正则表达式及应用

第1章 扩展正则表达式 1.1  + 前一个字符连续出现了1次或1次以上 egrep  "0+" clsn.txt  1次或1次以上 =1 egrep  "0*" clsn.txt  0次或次以上 =0 1.1.1 找到文本中的 [root@znix ~]# egrep  "0+" clsn.txt my qq num is 49000448. not 4900000448. [root@znix ~]# egrep -o  "0+" clsn.txt 000 00000   1.1.2 取出文件中的大写字母 [root@znix ~]# grep -o "[A-Z]" clsn.txt I I I O L D B O Y 1.1.3 取出连续出现的大写字母 [root@znix ~]# egrep -o "[A-Z]+" clsn.txt I I I clsn 1.1.4 显示所有的单词 [root@znix ~]# egrep -o "[A-Za-z]+" clsn.txt……

阅读全文

linux的特殊符号与正则表达式

第1章 linux的特殊符号 1.1 通配符 * {} 1.1.1 含义 方便查找文件 通配符是用来找文件名字的。 1.1.2  * 通过find 命令找以 .sh 结尾的文件,使用*替代文件名字。 find /clsn -type f -name "*.sh" -mtime +7 -size +100k -size -10M 查找文件名中,包含有clsn字节的文件。 [root@znix 20170118]# find -type f -name "*clsn*" [root@znix 20170118]# ls -l *clsn* 1.1.3  {} {} 用来生成序列 [root@znix 20170118]# echo clsn{1..3}.txt clsn1.txt clsn2.txt clsn3.txt [root@znix 20170118]# echo {a,c,d,f} a c d f echo {a..z}……

阅读全文

软硬链接、文件删除原理、linux中的三种时间、chkconfig优化

第1章 软硬链接 1.1 硬链接 1.1.1 含义 多个文件拥有相同的inode号码 硬链接即文件的多个入口 1.1.2 作用 防止你误删除文件 1.1.3 如何创建硬链接 ln 命令,前面是源文件 后面是创建的链接文件 [root@znix clsn]# ln clsn.txt clsn.txt-hard        查看两文件的inode号相同。 [root@znix clsn]# ls -lhi clsn.txt clsn.txt-hard 151273 -rw-r--r-- 2 root root 607 Aug 30 09:13 clsn.txt 151273 -rw-r--r-- 2 root root 607 Aug 30 09:13 clsn.txt-hard 1.2 软连接 1.2.1 含义……

阅读全文

用户与磁盘

第1章 linux文件属性相关 1.1 linux文件属性 1.2 磁盘的使用过程 1、磁盘(房子) 2、分区(划分隔断) 3、格式化创建文件系统(装修) 4、挂载(安装门窗) 5、存放文件(住人) 1.3 inode 索引节点 索引节点(index node)        通过文件名找到inode号码 1.3.1 inode 怎么来的 格式化创建文件系统 生成in……

阅读全文

运行级别,压缩命令,单引号与双引号运用

1.1 第8题 linux 系统运行级别一般为 0-6,请分别写出每个级别的含义。 1.1.1 运行级别的含义 0 关机 1 单用户模式 2 多用户模式 没有NFS 3 完全的多用户   命令行模式 4 没有使用 5 图形化界面模式 6 重启 1.1.2 临时切换运行级别  init 5 临时修改 1.1.3 查看运行级别 runlevel 显示运行级别 1.1.4 永久修改运……

阅读全文

Linux必知必会的目录与启动过程

第1章 /etc/目录 1.1 /etc/sysconfig/network-scripts/ifcfg-eth0 linux第一块网卡的配置文件 [root@znix ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=00:0c:29:cb:69:ee TYPE=Ethernet UUID=38ad33ab-3d2b-4183-bd84-ce1766236ddd ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.0.0.200 NETMASK=255.255.255.0 GATEWAY=10.0.0.2 USERCTL=no PEERDNS=yes IPV6INIT=no DNS2=223.5.5.5 DNS1=119.29.29.29 1.2 /etc/resolv.conf dns临时配置文件 [root@znix ~]# cat /etc/resolv.con nameserver 119.29.29.29 nameserver 223.5.5.5 1.3 /etc/fstab 机自动挂载分区/磁盘,规定哪个分区/设备,挂载到哪里 root@znix ~]# cat /etc/fstab   # # /etc/fstab # Created by anaconda on Thu Aug 10 18:33:48 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=49bad9e9-cf33-4a15-ba84-4fd28e70bd29 /                       ext4    defaults        1 1……

阅读全文

linux中重要目录

第1章 find命令扩展 1.1 方法一 |xargs 通过|xargs将前面命令的执行结果传给后面。 [root@znix ~]# find /clsn/ -type f -name "*.sh" |xargs ls -l -rw-r--r--. 1 root root 7 Aug 17 17:00 /clsn/test/del.sh -rw-r--r--. 1 root root 8 Aug 17 19:35 /clsn/test.sh -rw-r--r--. 1 root root 7 Aug 17 17:00 /clsn/t.sh 1.2 方法二 $() $()先运行里面的命令,把显示到屏幕上的结果留下来 [root@znix ~]# ls -l $(find /clsn/ -type f -name "*.sh") -rw-r--r--. 1 root root 7 Aug 17 17:00 /clsn/test/del.sh -rw-r--r--. 1 root root 8 Aug 17 19:35 /clsn/test.sh -rw-r--r--. 1 root root 7……

阅读全文