linux命令技巧
时间:2010-09-20 来源:smallhonker
1.我想看看某个用户每条命令的执行时间,用history可以吗?
--------------------
不行。除非你當初有設定 HISTTIMEFORMAT 變量,告知要紀錄的時間格式欄位,要不然已經來不及了。
#vi /etc/profile.
.
HISTTIMEFORMAT="%D %H:%M:%S ".
.
保存后重新登陆查看。
------------------------------
find /etc -type d |awk -F '/etc/' '{print $2}' |xargs mkdir -p 2.1
统计文件 find yourpath -type f | wc -l
统计目录 find yourpath -type d | wc -l 3. 如何备份指定的文件类型?
---------------------
备份/usr 下所有的*.c 文件到/root/c.cpio文件
#find /usr -name *.c | cpio -ov -F /root/c.cpio
---------------------
备份指定目录下的文件到指定目录:
源目录为:/home/a
目标目录为:/home/b
find /home/a -name *.txt | cpio -pd /home/b
4.
远程MOUNT主机文件?
------------------
#mount 192.168.1.246:/netinstall/centos4 /media/file
5.
排列目录下的文件
从小到大
#ls -lSr
从大到小
#ls -lSu
从新到旧
#ls -lt
------------
# man ls |grep sort
-c with -lt: sort by, and show, ctime (time of last modification of
file status information) with -l: show ctime and sort by name
otherwise: sort by ctime
-f do not sort, enable -aU, disable -lst
reverse order while sorting
-S sort by file size
access, use, ctime or status; use specified time as sort key if
-t sort by modification time
-u with -lt: sort by, and show, access time with -l: show access
time and sort by name otherwise: sort by access time
-U do not sort; list entries in directory order
-v sort by version
-X sort alphabetically by entry extension