最近用linux比较多点,把一些工作中的命令记录下来。
1.ls 查看文件目录
比如进入某个文件夹中,查看多少文件
[root@as logs]# ls
debug_1.log debug_2.log
列出文件结构
查看详细信息 可以用 ls -l 或者 ls -all
结果
[root@as logs]# ls -l
total 8828
-rw-r--r-- 1 root root 1048627 Jul 30 10:11 debug_1.log
-rw-r--r-- 1 root root 1048632 Jul 30 10:11 debug_2.log
-rw-r--r-- 1 root root 1048628 Jul 30 10:11 debug_3.log
2.cat 查看某个文件全部内容
如:
[root@as logs]# cat warn.log
2009.07.30 10:07:19 Admin console: Using RSA certificates but they are not valid for the hosted domain
如果感觉文件太大 想看一部分可以用 cat info.log |more
more 后面可以可以跟现实多少行 如 cat info.log |more -100 这样就显示100行
[root@as logs]# cat info.log |more -100
2009.07.30 10:09:45.294 use end resourceBound::::::::::::::::::::;8723
2009.07.30 10:09:45.295 use start login::::::::::::::::::::;test9350
2009.07.30 10:09:45.295 use login count::::::::::::::::::::;8725
如果想抓一些文件中关键字显示出来 可以结合grep 实现
如 我想抓取只显示出use start login 关键字的记录
[root@as logs]# cat info.log |grep 'use end resourceBound' |more -5
2009.07.30 10:09:45.294 use end resourceBound::::::::::::::::::::;8723
2009.07.30 10:09:45.296 use end resourceBound::::::::::::::::::::;8724
2009.07.30 10:09:45.297 use end resourceBound::::::::::::::::::::;8725
2009.07.30 10:09:45.297 use end resourceBound::::::::::::::::::::;8726
2009.07.30 10:09:45.298 use end resourceBound::::::::::::::::::::;8727
如果只想统计多少个数不需要看详细记录 可以 -c 来统计
如:
[root@as logs]# cat info.log |grep 'use end resourceBound' -c
1097
[root@as logs]#
3.删除不需要的文件 可以使用 rm 命令
如:
[root@as logs]# rm info.log
rm: remove regular file `info.log'?
会提示你确定要删除吗?确定就回车执行删除操作
如果 不需要提示删除 可以使用 rm -f info.log
如果 想把文件和文件夹一起删除也不需要提示 可以使用
rm -rf info.log
4.复制命令 cp
复制文件
[root@s209 20090702-06:06]# cp tsung.log zzz.log
5.如果监控程序运行查看日志 常用
[root@s209 20090702-06:06]# tail -f tsung.log
6 查看系统进程
ps aux
7 杀死一些进程
kill -9 id
8 linux 文件大小打开有限制 默认好像是1024个
如果修改文件大小限制 可以如下操作
[root@s209 20090702-06:06]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 32768
max locked memory (kbytes, -l) 32
先查看一下数量 修改的话可以使用
ulimit -n 65536
修改成65536个
9 如果想时时观看CPU 内存情况 可以用TOP
[root@s209 20090702-06:06]# top
top - 11:14:43 up 1:52, 1 user, load average: 0.17, 0.06, 0.04
Tasks: 96 total, 2 running, 94 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.2%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2075396k total, 540356k used, 1535040k free, 103632k buffers
Swap: 2031608k total, 0k used, 2031608k free, 257064k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2395 root 15 0 29280 4764 3508 S 0 0.2 0:20.08 Xorg
2415 gdm 15 0 12444 3840 3216 S 0 0.2 0:05.81 at-spi-registry
4966 root 15 0 2200 996 792 R 0 0.0 0:00.03 top
10.有时候想记录cpu 内存等信息把他输入到指定的文件中保存下来,方便之后的统计工作
用sar 命名
sar 5 0 -r -e 15:30:00 > datamem.txt
上述脚本疾苦内存情况输出到datamem.txt文件中, -e 和 时间是 说明到下午3点30结束
5 是没隔5秒记录一次 -r 指定记录内存情况
sar 5 0 -e 15:30:00 > data.txt
这个脚本是记录CPU 情况 用法和上面一样。
11 启动定时任务,有时候需要让系统定时帮我们做一些事情用crontab
编辑crontab -e
[root@s208 log]# crontab -e
*/15 * * * * tsung restart
~
编写*/15 * * * * tsung restart 该脚本 每格15分钟执行一次
启动定时脚本命令
/etc/init.d/crond start
关闭定时脚本命令
/etc/init.d/crond stop
定时任务 */15 * * * * 说明可以查看相关别的文档
分享到:
相关推荐
老男孩linux笔记
常规的linux笔记
Linux笔记.pdf
手写Linux笔记-常用命令
黑马学习linux 笔记
Linux笔记xmind文档,linux命令整理
国嵌Linux笔记 所有pdf课件用word编辑,可复制粘贴编辑
Linux笔记,Linux笔记,Linux笔记,Linux笔记,Linux笔记,Linux笔记,Linux笔记,Linux笔记
Linux笔记——vim常用操作及扩展补充[手册] Linux笔记——linux常用命令集合 Linux笔记——命令:awk Linux笔记——命令:sed Linux笔记——命令:grep Linux笔记——命令:find Linux笔记——命令:Sort,uniq,join,...
韩顺平linux 笔记
Kali Linux是基于Debian的Linux发行版, 设计用于数字取证操作系统。由Offensive Security Ltd维护和资助。最先由Offensive Security的Mati Aharoni和Devon Kearns通过重写BackTrack来完成,BackTrack是他们之前写的...
Linux笔记,笔记中包含Linux的知识点,但是我还没有完全整理完,后面我会补上的!
Linux 入门到精通企业实战 1 Linux 基础篇 1 Linux 进阶篇 3 Linux 高级篇 4 第 1 章 Linux 快速入门 5 第 2 章 Linux 发展及系统安装 15 第 3 章 CentOS 系统管理 42 第 4 章 Linux 必备命令 72 第 5 章 Linux 用户...
Linux学习笔记。详述了Linux命令,gcc编译器
Linux笔记 配合我的博客使用 为我的博客Linux常用命令文本版
韩顺平 LINUX平台 课堂学习笔记 包括1,2,3,4,5
liunx操作系统的个人笔记总结,内包含了vm学习linux的常用命令。以及操作,在平时工作中也是可以通到的。
我的Linux笔记...初学Linux的朋友可以下来看看,很全面...
ansible笔记,马哥Linux2016笔记,全部笔记,详细笔记
针对所有初学Linux的人员的一个最全面的笔记,对于有过基础的朋友来说又是一个更好的助手. 省去了你自己去总结的时间,有更多的时间去敲代码. ------------黑马程序员学员-------------------