1)cd命令,使用cd命令主要是为了进入某一个目录或者退出某个目录。
[zh_readonly@172 ~]$ cd /data
[zh_readonly@172 data]$ ls
jsp lost+found
[zh_readonly@172 data]$ ll -a
total 28
drwxr-xr-x. 4 root root 4096 Nov 24 18:55 .
dr-xr-xr-x. 28 root root 4096 Oct 25 21:49 ..
drwxr-xr-x. 8 root root 4096 Jan 7 11:00 jsp
drwx------. 2 root root 16384 Oct 25 22:03 lost+found
[zh_readonly@172 data]$ cd -
/home/zh_readonly
[zh_readonly@172 ~]$ pwd
/home/zh_readonly
[zh_readonly@172 ~]$ cd /data/jsp
[zh_readonly@172 jsp]$ cd --
[zh_readonly@172 ~]$ pwd
/home/zh_readonly
[zh_readonly@172 ~]$ cd /data/jsp
[zh_readonly@172 jsp]$ pwd
/data/jsp
[zh_readonly@172 jsp]$ cd .
[zh_readonly@172 jsp]$ pwd
/data/jsp
[zh_readonly@172 jsp]$ cd ..
[zh_readonly@172 data]$ pwd
/data
上面分别演示了进入目录,查询目录下的所有文件,退回上级目录,退回上两级目录的操作。
2)cat和tail命令
cat file:查看文件的所有内容
tail -200f file:查看文件的后200行,而且不断的在等待更新。更准确的说,应该是显示最新的200行。
tail -n 200 file:取运行时的文件的后200行
[zh_readonly@172 logs]$ tail -n 5 loginAllLog.log
2014-01-21 03:54:31|1000630223|3||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3||PC|Linux|189mail|1|0
[zh_readonly@172 logs]$ tail -5f loginAllLog.log
2014-01-21 03:54:31|1000630223|3||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
3)clear命令:清屏
4)grep命令:寻找文件中包含某个字段的内容。
[zh_readonly@172 logs]$ tail -10f loginAllLog.log
2014-01-21 03:48:26|378110512337|3||Mobile|Android 4.x|cloud|1|0
2014-01-21 03:49:52|378110243271|10||Unknown|Unknown|publicflowpay|4|0
2014-01-21 03:50:40|1000862660|3|||PC|Windows XP|189mail|1|0
2014-01-21 03:51:47|1000130773|3|||Mobile|Android 4.x|189mail|2|0
2014-01-21 03:54:23|501110124225|10|||Unknown|Unknown|flow|4|0
2014-01-21 03:54:31|1000630223|3|||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3|||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
^C
[zh_readonly@172 logs]$ grep 400110512245 loginAllLog.log
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
[zh_readonly@172 logs]$
差点犯了小错误,涉及用户敏感信息要被删掉才行,所以,日志信息被我删了七七八八了。上面的就是我在公司经常用到的命令了。
[zh_readonly@172 ~]$ cd /data
[zh_readonly@172 data]$ ls
jsp lost+found
[zh_readonly@172 data]$ ll -a
total 28
drwxr-xr-x. 4 root root 4096 Nov 24 18:55 .
dr-xr-xr-x. 28 root root 4096 Oct 25 21:49 ..
drwxr-xr-x. 8 root root 4096 Jan 7 11:00 jsp
drwx------. 2 root root 16384 Oct 25 22:03 lost+found
[zh_readonly@172 data]$ cd -
/home/zh_readonly
[zh_readonly@172 ~]$ pwd
/home/zh_readonly
[zh_readonly@172 ~]$ cd /data/jsp
[zh_readonly@172 jsp]$ cd --
[zh_readonly@172 ~]$ pwd
/home/zh_readonly
[zh_readonly@172 ~]$ cd /data/jsp
[zh_readonly@172 jsp]$ pwd
/data/jsp
[zh_readonly@172 jsp]$ cd .
[zh_readonly@172 jsp]$ pwd
/data/jsp
[zh_readonly@172 jsp]$ cd ..
[zh_readonly@172 data]$ pwd
/data
上面分别演示了进入目录,查询目录下的所有文件,退回上级目录,退回上两级目录的操作。
2)cat和tail命令
cat file:查看文件的所有内容
tail -200f file:查看文件的后200行,而且不断的在等待更新。更准确的说,应该是显示最新的200行。
tail -n 200 file:取运行时的文件的后200行
[zh_readonly@172 logs]$ tail -n 5 loginAllLog.log
2014-01-21 03:54:31|1000630223|3||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3||PC|Linux|189mail|1|0
[zh_readonly@172 logs]$ tail -5f loginAllLog.log
2014-01-21 03:54:31|1000630223|3||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
3)clear命令:清屏
4)grep命令:寻找文件中包含某个字段的内容。
[zh_readonly@172 logs]$ tail -10f loginAllLog.log
2014-01-21 03:48:26|378110512337|3||Mobile|Android 4.x|cloud|1|0
2014-01-21 03:49:52|378110243271|10||Unknown|Unknown|publicflowpay|4|0
2014-01-21 03:50:40|1000862660|3|||PC|Windows XP|189mail|1|0
2014-01-21 03:51:47|1000130773|3|||Mobile|Android 4.x|189mail|2|0
2014-01-21 03:54:23|501110124225|10|||Unknown|Unknown|flow|4|0
2014-01-21 03:54:31|1000630223|3|||PC|Windows XP|189mail|1|0
2014-01-21 03:55:00|1000005219|3|||PC|Windows 7|189mail|1|0
2014-01-21 03:57:27|1000149097|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:05|1000625040|3|||PC|Windows XP|189mail|1|0
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
^C
[zh_readonly@172 logs]$ grep 400110512245 loginAllLog.log
2014-01-21 04:00:16|400110512245|3|||PC|Linux|189mail|1|0
[zh_readonly@172 logs]$
差点犯了小错误,涉及用户敏感信息要被删掉才行,所以,日志信息被我删了七七八八了。上面的就是我在公司经常用到的命令了。