1, define an alias command for all users in force, for example: lftps = '172.168.0.1 / pub'
echo "alias lftps='172.168.0.1/pub'" >> /etc/bashrc && source /etc/bashrc
2, the display / etc / passwd file are not at all / bin / bash line end
grep -v "/bin/bash$" /etc/passwd
3, to find the / etc / passwd file, contains two or three digits line numbers
grep "\<[0-9]\{2,3\}\>" /etc/passwd
4, display line / proc / meminfo s at the beginning of the file case, three ways
grep -i '^s' /proc/meminfo
grep '^[sS]]' /proc/meminfo
grep -E '^(s|S)' /proc/meminfo
5, an absolute path echo out using the type of execution path name egrep take dirname / etc / passwd results
echo "/a/b/c/d" | egrep -o '.*/'
6 to find the ip address in ifconfig, requiring only the results show ip address
ifconfig | egrep -o 'inet (addr:)?([0-9]*\.){3}[0-9]*' | egrep -o '([0-9]*\.){3}[0-9]*' | head -n 1
7 vim customized automatic indenting 4 characters
CAT >> / etc / vimrc << EOF
the SET ai
the SET 4 the TabStop =
EOF
8 scripting, automatically add three users, and calculate the uid of these three users and
#!/bin/bash
#
sum_uid=0
for account in user1 user2 user3
do
if id $account &> /dev/null
then echo "$account exists"
else
useradd $account
fi
uid=$(id -u $account)
sum_uid=$[$sum_uid+$uid]
done
echo "3个用户的UID之和是 $sum_uid"
9 find examples of common usage and
fine [options] [查找起始路径] [查找条件] [处理动作]
-name 文件名查找 支持glob
-iname 忽略大小写
根据从属查找
-user USERNAME
-user groupname
-uid
-gid
-nouser 查找没有属主的文件
-nogroup
文件类型查找
-type
f 普通文件
d 目录文件
l 符号链接文件
b 块设备文件
c 字符设备文件
p 管道文件
s 套接字
组合查找
与:-a
或:-o
非:-not,!
文件大小
-size [+|-]#unit
常用单位:k M G
#unit: (#-1, #]
-#unit: [0 - #-1 ]
+#unit: (#, 无穷大)
时间
以天为单位
-atime [+|-]# 访问
#: 过去第几天 [#,#-1)
-# (#, 0] 过去#天内
+# (00, #-1] 超过多少天
-mtime 修改
-ctime 更改
以分为单位
-amin
-mmin
-cmin
权限
-perm [+|-]mode
mode:与mode精确匹配
+mode:ugo组有一组满足都可以
-mode:小于mode的权限即可
处理动作:
-print 输出至标准输出 默认的动作
-ls
-delete 删除
-fls /path 查找的文件详细信息保存到指定文件中
-ok COMMAND {} \; 对查找到的每个文件执行由COMMAND指定的命令,每次操作由 用户确认
-exec COMMANd {} \; 对查找到的每个文件执行由COMMAND指定的命令,每次操作不需要用户确认