clamzxf 2020-05-17
[ home]# stat passwd File: ‘passwd’ Size: 795 Blocks: 8 IO Block: 4096 regular file Device: fd00h/64768d Inode: 19087983 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:home_root_t:s0 Access: 2020-05-10 15:23:17.576572669 -0400 Modify: 2020-05-10 15:23:17.576572669 -0400 Change: 2020-05-10 15:23:17.579572669 -0400 Birth: -
[ /]# cp /etc/passwd /opt/ [ /]# cp /boot/vm* /opt/ [ /]# cp -r /boot/ /opt/ [ /]# cp -r /etc/shadow /mnt/ /opt/ [ /]# \cp -r /boot/ /opt/ #覆盖文件时,如果目标位置已经存在该文件,系统会询问我们是否覆盖,需要输入y来确认,加入\存在时就不用询问直接操作
[ /]# touch /opt/1.txt [ /]# mkdir /opt/abc [ /]# ls /opt/ 1.txt abc [ /]# rm -rf /opt/* [ /]# ls /opt/
[ /]# mkdir /opt/nsd01 [ /]# touch /opt/1.txt [ /]# ls /opt/ 1.txt nsd01 [ /]# mv /opt/1.txt /opt/nsd01 [ /]# ls /opt/ #移动后/opt下不存在1.txt文件 nsd01 [ /]# ls /opt/nsd01 1.txt #重命名:路径不变的移动 [ /]# mv /opt/test /opt/haha #/test另起文件名/haha
[ etc]# basename /usr/local/nginx/conf/nginx.conf nginx.conf [ etc]# dirname /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf
[ etc]# which ls alias ls=‘ls --color=auto‘ /usr/bin/ls [ etc]# which dirname /usr/bin/dirname [ etc]# which find /usr/bin/find
[ /]# whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz
[ /]# locate passwd /etc/passwd /etc/passwd- /etc/pam.d/passwd /etc/security/opasswd /home/passwd
[ ~]# find /etc/ -name "*.conf" [ ~]# find /etc/ -name "passwd" [ ~]# find /boot -type d [ ~]# find /boot -type l [ ~]# find /boot -type f [ ~]# find /root/ -name "nsd*" [ ~]# find /root/ -name "nsd*" -type f [ ~]# find /root/ -name "nsd*" -type d [ ~]# find /boot/ -size +20M #查找20M以上的文件 [ ~]# ls -lh /boot/initramfs-* [ ~]# find /boot/ -size -20M [ ~]# useradd lisi [ ~]# useradd zhangsan [ ~]# ls -l /home/ [ ~]# find /home -user zhangsan [ ~]# find /home -user lisi [ ~]# find / -user lisi
# rm -rf /opt/* # find /boot/ -size +10M # find /boot/ -size +10M -exec cp {} /opt \; #找到的结果复制到/opt下 # ls /opt/ # mkdir /root/findfiles # find / -user lisi -type f -exec cp {} /root/findfiles \; # ls -A /root/findfiles/
[ ~]# grep ‘root‘ /etc/passwd [ ~]# grep -v ‘root‘ /etc/passwd #取反 [ ~]# grep ‘ROOT‘ /etc/passwd [ ~]# grep -i ‘ROOT‘ /etc/passwd #忽略大小写 [ ~]# grep ‘seismic‘ /usr/share/dict/words # grep ‘seismic‘ /usr/share/dict/words > /root/wordlist #找出来相匹配的并导出 # cat /root/wordlist^word 以字符串word开头 word$ 以字符串word结尾 [ ~]# grep ‘^root‘ /etc/passwd [ ~]# grep ‘root$‘ /etc/passwd [ ~]# grep ‘bash$‘ /etc/passwd 匹配空行 [ ~]# grep -v ‘^$‘ /etc/default/useradd