Chinaunix首页 | 论坛 | 博客
  • 博客访问: 808952
  • 博文数量: 222
  • 博客积分: 4341
  • 博客等级: 上校
  • 技术积分: 2155
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 13:50
个人简介

...

文章分类

全部博文(222)

文章存档

2019年(1)

2016年(9)

2015年(7)

2014年(14)

2013年(11)

2012年(10)

2011年(6)

2010年(25)

2009年(37)

2008年(21)

2007年(81)

我的朋友

分类: LINUX

2009-02-17 17:50:52

Linux 101 Hacks


1. function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }

2. # pushd . # popd

3. Use “shopt -s cdspell” to automatically correct mistyped directory names on cd

4. # date {mmddhhmiyyyy.ss}

 # date 013122192009.53
 
 # date +%Y%m%d -s "20090131"
 
 # date -s "01/31/2009 22:19:53" 
 
 # date -s "31 JAN 2009 22:19:53"
 
 # date set="31 JAN 2009 22:19:53"

 # date +%T -s "22:19:53"

 # date +%T%p -s "10:19:53PM"
 
5. Set Hardware Date and Time //# cat /etc/sysconfig/clock

 # hwclock –systohc
 
 # hwclock --systohc –utc
 
 # hwclock
 
6. SSH client debug message: ssh -v

7. SSH Session Statistics using SSH Escape Character : ~ The ~s is not visible on the command line when you type.

8. search all subdirectories for a text matching a specific pattern : grep -r

9. Find Command

 # find /etc -name "*mail*"

 # find / -type f -size +100M

 # find . -mtime +60

 # find / -type f -name *.tar.gz -size +100M -exec ls -l {} \;

 # find /home/jsmith -type f -mtime +60 | xargs tar -cvf /tmp/`date '+%d%m%Y'_archive.tar`

10. Suppress Standard Output and Error Message

# ./shell-script.sh > /dev/null
# ./shell-script.sh 2> /dev/null

11. Join Command

12. Change the Case : $ tr a-z A-Z < filename.txt

13. Xargs Command

14. sort Command: $ sort -t: -k 2 names.txt

 /etc/hosts file by ip-addres  $ sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n /etc/hosts

15. Uniq Command

 $ sort filename.txt | uniq
 
 $ sort –u filename.txt

 $ sort namesd.txt | uniq –c //duplicates Statistics

 $ sort namesd.txt | uniq –cd //only display the dublicates entries

16. Cut Command //display only specific columns from a text file or other command outputs.

 $ cut -d: -f 1,3 filename.txt  //display the 1st and 3th field from a colon delimited file

 # free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2 //Displays the total memory available on the system.

17. Stat Command // check the status/properties of a single file or the filesystem.

18. ac command  // connect time statistics

19. use a different configure file for httpd: # apachectl -f conf/httpd.conf.debug

20. Use a temporary DocumentRoot: # httpd -k start -c “DocumentRoot /var/www/html_debug/”

21. Display the modules inside Apache:

 # httpd -l   // modules compiled inside Apache

 # httpd –M  //static and dynamic module loaded by Apache

22. Show all accepted directives inside httpd.conf: # httpd –L

23. Test the configuer file for apache: # httpd -t -f conf/httpd.conf.debug

24. Display the httpd build parameters: # httpd –V

25. Print the Process Tree: # ps axuf

26. lsof commands

 # lsof –u tony  //opened files by tony user

27. Sysctl Command

 # sysctl –a  //kernel parameters

阅读(634) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~