[kingarthur@localhost ~]$ pwd
/home/kingarthur
Desktop Documents Downloads Music Pictures Public README README.1 README.2 README.3 Templates test_tty1 Videos
#输出 password 字符串的ASCII 编码
#参数 -t 后可接各种类型输出
#参数 o 采用八进制来输出数据
#参数 c 使用ASCII 字符来输出
[kingarthur@localhost ~]$ echo password | od -t oCc
0000000 160 141 163 163 167 157 162 144 012
p a s s w o r d \n
0000011
#测试输出
[kingarthur@localhost ~]$ echo I_love_you | od -t oCc
0000000 111 137 154 157 166 145 137 171 157 165 012
I _ l o v e _ y o u \n
0000013
#测试
[kingarthur@localhost ~]$ echo Iloveyou | od -t oCc
0000000 111 154 157 166 145 171 157 165 012
I l o v e y o u \n
0000011
##修改文件时间或新建文件 touch
#modification time(mtime) 为默认, status time(ctime)文件权限与属性被更改时发生变化,
#access time(atime)文件内容被取用时发生改变
[root@localhost ~]# date; ls -l /etc/man_db.conf ; ls -l --time=atime /etc/man_db.conf ; ls -l --time=ctime /etc/man_db.conf
Wed Apr 8 03:43:12 CST 2020
-rw-r--r--. 1 root root 5171 Oct 31 2018 /etc/man_db.conf
-rw-r--r--. 1 root root 5171 Apr 4 16:19 /etc/man_db.conf
-rw-r--r--. 1 root root 5171 Mar 18 08:18 /etc/man_db.conf
##touch 修改时间日期
#touch 创建文件并查看文件时间与日期
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# touch testtouch
[root@localhost tmp]# ls -l testtouch
-rw-r--r--. 1 root root 0 Apr 8 03:50 testtouch
[root@localhost tmp]# date; ls -l ./testtouch ; ls -l --time=atime ./testtouch ; ls -l --time=ctime ./testtouch
Wed Apr 8 03:56:58 CST 2020
-rw-r--r--. 1 root root 0 Apr 8 03:50 ./testtouch
-rw-r--r--. 1 root root 0 Apr 8 03:50 ./testtouch
-rw-r--r--. 1 root root 0 Apr 8 03:50 ./testtouch
#复制目标文件、查看文件时间日期并修改
[root@localhost tmp]# cp -a ~/.bashrc bashrc
[root@localhost tmp]# date; ls -l ./bashrc ; ls -l --time=atime ./bashrc ; ls -l --time=ctime ./bashrc
Wed Apr 8 03:59:22 CST 2020
-rw-r--r--. 1 root root 176 Dec 29 2013 ./bashrc
-rw-r--r--. 1 root root 176 Apr 8 03:41 ./bashrc
-rw-r--r--. 1 root root 176 Apr 8 03:57 ./bashrc
#查看源文件时间属性
[root@localhost tmp]# ll ~/.bashrc
-rw-r--r--. 1 root root 176 Dec 29 2013 /root/.bashrc
#将日期调整为”两天前“(注意 ctime )
[root@localhost tmp]# touch -d "2 days ago" bashrc
[root@localhost tmp]# date; ls -l ./bashrc ; ls -l --time=atime ./bashrc ; ls -l --time=ctime ./bashrc
Wed Apr 8 04:04:30 CST 2020
-rw-r--r--. 1 root root 176 Apr 6 04:04 ./bashrc
-rw-r--r--. 1 root root 176 Apr 6 04:04 ./bashrc
-rw-r--r--. 1 root root 176 Apr 8 04:04 ./bashrc
#指定文件日期(注意 ctime )
[root@localhost tmp]# touch -t 201406150202 bashrc
[root@localhost tmp]# date; ls -l ./bashrc ; ls -l --time=atime ./bashrc ; ls -l --time=ctime ./bashrc
Wed Apr 8 04:05:53 CST 2020
-rw-r--r--. 1 root root 176 Jun 15 2014 ./bashrc
-rw-r--r--. 1 root root 176 Jun 15 2014 ./bashrc
-rw-r--r--. 1 root root 176 Apr 8 04:05 ./bashrc
#文件预设权限 umask
#文件隐藏属性 chattr
#文件特殊权限 SUID / SGID / SBIT
#观察文件类型 file
##指令与文件搜索
#脚本文件名搜索
[root@localhost tmp]# which ifconfig
/usr/sbin/ifconfig
#参数 -a 将所有由 PATH 目录中可以找到的指令均列出
[root@localhost tmp]# which -a ifconfig
/usr/sbin/ifconfig
[root@localhost tmp]# which which
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
/usr/bin/alias
/usr/bin/which
#搜索 history , 提示 “ no history ”
[root@localhost tmp]# which history
/usr/bin/which: no history in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/kingarthur/.local/bin:/home/kingarthur/bn)
#特定目录搜索文件名
[root@localhost tmp]# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[root@localhost tmp]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
#参数 -m 只找出在说明文档 mannual 路径下的文件
[root@localhost tmp]# whereis -m passwd
passwd: /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
#参数 -l 列出 whereis 会去查询的几个主要目录
[root@localhost tmp]# whereis -l -m passwd
bin: /usr/bin
bin: /usr/sbin
...
man: /usr/share/man/man7
man: /usr/share/man/man5
...
src: /usr/src/debug
src: /usr/src/kernels
passwd: /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
#从已建立的数据库搜索 /var/lib/mlocate ,而非去硬盘中存取
[root@localhost tmp]# locate -l 5 passwd
/etc/passwd
/etc/passwd-
...
#输出 locate 所使用的数据库文件的相关信息,包括该数据库记录的文件/目录数量等
[root@localhost tmp]# locate -S
Database /var/lib/mlocate/mlocate.db:
19,168 directories
230,746 files
12,481,889 bytes in file names
5,470,406 bytes used to store database
#根文件 24h 内有变动的文件列出
[root@localhost tmp]# find / -mtime 0
/dev
/dev/vcsa6
/dev/vcs6
/dev/vcsa5
/dev/vcs5
/dev/vcsa4
/dev/vcs4
/dev/vcsa3
/dev/vcs3
/dev/vcsa2
/dev/vcs2
#路径 /etc 下寻找文件, 如果比 /etc/passwd 新则列出
[root@localhost tmp]# find /etc -newer /etc/passwd
/etc
/etc/resolv.conf
...