一些 linux 命令

1. 更改某一目录下所有目录的权限, 不包括文件 aaa 是目录名
find aaa -type d -exec chmod 755 {} \;

2. 查看文件属性,可用此查看压缩文件的格式
file 文件名

3. 定时任务
用cron处理定时任务,首先要保证cron操作已经运行。如果安装了cron 的话。正常情况下cron已经开机自运行了,如果没有运行的话。
/etc/init.d/cron start
用crontab来安排定时任务

crontab [-u user] {-l| -r | -e}
-l:显示任务
-e:编辑任务
-r:清空任务

任务格式为:
分 时 日期 月份 星期 操作命令
eg:
* 14 * * * echo " look me">>/home/lost/test ##表示每天14点运行一次
0-59/2 * * * * echo "look me" >>/tmp/test ##表示每两分钟运行一次
* 2,15 * * * echo "look me " >>/tmp/test ##表示2与15点运行一次

* : 表示任意 - : 表示区间. / :表示频率 , :表示枚举
http://linux.vbird.org/linux_basic/0430cron.php#cron

4. 递归查找文件内的字符串
find ./ -name '*.html' -exec grep "breadcrumbs.inc.php" '{}' \; -print
这条命令将查找所有包含 breadcrumbs.inc.php 的 HTML 文件。

5. 搜索并替换文件里的内容
sed -i 's/b/strong/g' index.html
此命令搜索 index.html 文件中的 b 并将其替换为 strong。

6. 调试命令
strace -p pid
跟踪指定的进程pid.

gdb -p pid
跟踪指定的进程pid.

Tags: linux, 命令

相关日志

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

还没有评论。

发表评论

(必填)

(必填)


*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comment moderation is enabled. Your comment may take some time to appear.