echo “ls -l” | at midnight
在某个时间运行某个命令。
lsof –i
实时查看本机网络服务的活动状态。
ssh user@server bash < /path/to/local/script.sh
在远程机器上运行一段脚本。这条命令最大的好处就是不用把脚本拷到远程机器上。
ssh user@host cat /path/to/remotefile | diff /path/to/localfile -
比较一个远程文件和一个本地文件
ps aux | sort -nk +4 | tail
列出头十个最耗内存的进程
shell
|wc -c 计算字节数
|wc -l 计算行数
|wc -w 计算字数
反短斜线可以将一个命令的输出作为其它命令的命令行参数。
find . -mtime -1 -type f -print
上述命令可以查找过去24小时(-mtime –2则表示过去48小时)内修改过的文件。如果你想将上述命令查找到的所有文件打包,则可以使用如下脚本:
#!/bin/sh # The ticks are backticks (`) not normal quotes ('): tar -zcvf lastmod.tar.gz `find . -mtime -1 -type f -print`
2.ubuntu下切换到root用户
sudo su
sudo -i
su root