标签:average 创建 tar.gz == 环境 ldo indent 权限 inux
1.1 取出网卡配置文件的ip[root@oldboyedu50-lnb ~]# awk '/IPADDR/' /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=10.0.0.200
[root@oldboyedu50-lnb ~]# awk -F= '/IPADDR/{print $2}' /etc/sysconfig/network-scripts/ifcfg-eth0
10.0.0.200
[root@oldboy50-01 ~]# awk -F"[=]" '/DNS[0-9]+/{print $2}' /etc/sysconfig/network-scripts/ifcfg-eth0
223.6.6.6
223.5.5.5
date +%F_%w
[root@oldboy50-01 ~]# date +%F_%w
2018-08-06_1
[root@oldboyedu50-lnb ~]# date -d '-1year'
Sun Jul 23 16:44:04 CST 2017
[root@oldboyedu50-lnb ~]# date -d '-1day'
Sun Jul 22 16:44:12 CST 2018
[root@oldboyedu50-lnb ~]# date -s "20180521 12:12:12"
Mon May 21 12:12:12 CST 2018
[root@oldboyedu50-lnb ~]# date
Mon May 21 12:13:23 CST 2018
[root@oldboyedu50-lnb ~]# ntpdate ntp1.aliyun.com
6 Aug 09:01:17 ntpdate[1849]: step time server 120.25.115.20 offset 6641251.972418 sec
[root@oldboyedu50-lnb ~]# #tar zcf /tmp/etc.tar.gz /etc/
[root@oldboyedu50-lnb ~]# #tar zcf /tmp/etc-2018-06-06.tar.gz /etc/
[root@oldboyedu50-lnb ~]# date +%F
2018-08-06
[root@oldboyedu50-lnb ~]# tar zcf /tmp/etc-$(date +%F).tar.gz /etc/
tar: Removing leading `/' from member names
[root@oldboyedu50-lnb ~]# ll /tmp/etc-2018-08-06.tar.gz
-rw-r--r-- 1 root root 9734087 Aug 6 09:19 /tmp/etc-2018-08-06.tar.gz
[root@oldboyedu50-lnb ~]# tar tf /tmp/etc-2018-08-06.tar.gz
方法1
find /oldboy -type f |xargs sed 's#www.etiantian.org#www.oldboyedu.com#g'
方法2
sed 's#www.etiantian.org#www.oldboyedu.com#g' `find /oldboy -type f `
sed 's#www.etiantian.org#www.oldboyedu.com#g' $(find /oldboy -type f )
方法3
find /oldboy -type f -exec sed 's#www.etiantian.org#www.oldboyedu.com#g' {} \;
echo "oldboy";echo "oldboy"
[root@oldboyedu50-lnb ~]# echo 'oldboy'
oldboy
[root@oldboyedu50-lnb ~]# echo -n 'oldboy'
oldboy[root@oldboyedu50-lnb ~]#
[root@oldboyedu50-lnb ~]# echo 'oldboy\nold\n\nlidao'
oldboy\nold\n\nlidao
[root@oldboyedu50-lnb ~]# echo oldboy\nold\n\nlidao"
[root@oldboyedu50-lnb ~]# echo "oldboy\nold\n\nlidao"
oldboy\nold\n\nlidao
[root@oldboyedu50-lnb ~]# echo -e "oldboy\nold\n\nlidao"
oldboy
old
lidao
[root@oldboyedu50-lnb ~]# echo -e "oldboy\nold\n\nlidao"
oldboy
old
lidao
-n不显示每行结尾的回车
-e 让echo命令支持 转义字符 \n \t
模拟环境
export PATH=
PATH 路径 环境变量 存放的是 命令路径
如何修改PATH
1.临时
[root@oldboyedu50-lnb ~]# export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
[root@oldboyedu50-lnb ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
2.永久
[root@oldboyedu50-lnb ~]# tail -1 /etc/profile
#export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
[root@oldboyedu50-lnb ~]# source /etc/profile
3.检查
发出当前系统使用的 PATH
/var/log/messages 系统默认日志
/var/log/secure 用户登录日志
/etc/fstab 开机自动挂载
/etc/hosts 解析主机名(域名)
/etc/rc.local 开机自启动
/etc/profile 别名 环境变量
/var/spool/cron/root 定时任务的配置文件
1)临时
2)永久
/etc/sysconfig/network
3) 解析
[root@oldboyedu50-lnb ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.200 oldboyedu50-lnb
[root@oldboyedu50-lnb ~]# ping `hostname`
PING oldboyedu50-lnb (10.0.0.200) 56(84) bytes of data.
64 bytes from oldboyedu50-lnb (10.0.0.200): icmp_seq=1 ttl=64 time=0.021 ms
64 bytes from oldboyedu50-lnb (10.0.0.200): icmp_seq=2 ttl=64 time=0.021 ms
[root@oldboyedu50-lnb ~]# find / -type f -name "ifconfig"
/sbin/ifconfig
[root@oldboyedu50-lnb ~]# which ifconfig
/sbin/ifconfig
[root@oldboyedu50-lnb ~]# which rm
alias rm='echo rm bny'
/bin/echo
[root@oldboyedu50-lnb ~]# \which rm
/bin/rm
[root@oldboyedu50-lnb ~]# whereis grep awk
grep: /bin/grep /usr/share/man/man1p/grep.1p.gz /usr/share/man/man1/grep.1.gz
awk: /bin/awk /usr/bin/awk /usr/libexec/awk /usr/share/awk /usr/share/man/man1p/awk.1p.gz /usr/share/man/man1/awk.1.gz
[root@oldboyedu50-lnb ~]# w
10:41:59 up 2:07, 2 users, load average: 0.04, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 10.0.0.1 23Jul18 0.00s 0.28s 0.00s w
root pts/1 10.0.0.1 09:56 29:20 0.00s 0.00s -bash
[root@oldboyedu50-lnb ~]# w |awk 'NR==1{print $(NF-6)}'
1.重启
reboot
shutdown -r 10
shutdown -r 0/now 立即重启
shutdown -c 取消当前的重启或关机
init 6
2.关机
halt
shutdown -h 10
shutdown -h 0/now 立即关机
poweroff
init 0
Ctrl + a 把光标移动到行首
Ctrl + e 把光标移动到行尾
Ctrl + c 取消 cancel
Ctrl + d 退出当前用户
Ctrl + l 清屏
Ctrl + u 把光标所在位置到行首的内容删除(剪切)
Ctrl + k 把光标所在位置到行尾的内容删除(剪切)
ctrl + y 粘贴
ctrl+s 锁屏
ctrl+q/c 解锁
ctrl + r 找出最近一次使用过的 包含xxxx的命令 替你执行
1.文件或目录rwx含义
2.permission denied 权限拒绝
3.通过控制权限保护网站安全
4.特殊与隐藏权限
[root@oldboyedu50-lnb ~]# su - oldboy
[oldboy@oldboyedu50-lnb ~]$ ll /etc/hosts
-rw-r--r-- 1 root root 186 Aug 6 10:24 /etc/hosts
1.看看是你谁?
whoami oldboy
2.你与这个文件什么关系 : 主人 家人 陌生人
[oldboy@oldboyedu50-lnb ~]$ id oldboy
uid=500(oldboy) gid=500(oldboy) groups=500(oldboy)
#oldboy用户 文件是 陌生人关系
3.确认权限 陌生人权限 看最后三位
r 4
w 2
x 1
- 0
[root@oldboyedu50-lnb ~]# echo {r,-}{w,-}{x,-}
rwx rw- r-x r-- -wx -w- --x ---
权限转换
rw-r--r--
420400400
6 4 4
755 rwxr-xr-x
640 rw-r-----
744 rwxr--r--
600 rw-------
1.直接通过数字形式修改权限
[root@oldboyedu50-lnb /oldboy]# chmod 666 test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rw-rw-rw- 1 root root 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]# chmod 777 test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxrwxrwx 1 root root 23 Jul 20 01:13 test.txt
2.通过字母 形式修改
rw- rw- rw-
主人 家人 陌生人
所有者 所属用户组 其他人
user group other
u g o
[root@oldboyedu50-lnb /oldboy]# chmod u=r test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-r--rwxrwx 1 root root 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]# chmod ugo+x test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxr-xr-x 1 root root 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]# chmod a-x test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rw-r--r-- 1 root root 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]# chmod +x test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxr-xr-x 1 root root 23 Jul 20 01:13 test.txt
chmod ugo+x
chmod a+x
chmod +x
[root@oldboyedu50-lnb /oldboy]# chown oldboy.oldboy test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxr-xr-x 1 oldboy oldboy 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]#
[root@oldboyedu50-lnb /oldboy]#
[root@oldboyedu50-lnb /oldboy]# chown root test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxr-xr-x 1 root oldboy 23 Jul 20 01:13 test.txt
[root@oldboyedu50-lnb /oldboy]# chown .root test.txt
[root@oldboyedu50-lnb /oldboy]# ll test.txt
-rwxr-xr-x 1 root root 23 Jul 20 01:13 test.txt
标签:average 创建 tar.gz == 环境 ldo indent 权限 inux
原文地址:http://blog.51cto.com/13858927/2155256