linux命令技巧

1.我想看看某个用户每条命令的执行时间,用history可以吗?
--------------------
不行。除非你��初有�O定 HISTTIMEFORMAT �量,告知要�o�的�r�g格式�谖唬�要不然已��聿患傲恕�
#vi /etc/profile.
.
HISTTIMEFORMAT="%D %H:%M:%S ".
.
保存后重新登陆查看。

2.
下面的例子可以把/etc的结构复制到当前位置(不要内容,只要目录结构):
------------------------------
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

你可能感兴趣的:(linux,命令,职场,技巧,休闲)