10 Useful Everyday Unix - LAMP commands
Here are 10 unix commands i use almost every day. I have googled all of them more than once so here they are in one place:
- find / -name “*.txt” -mtime 5
Find all text files in filesystem modified in the last 5 days or last X days. replace -mtime as desired. - sed ’s/^[ \t]*//’ inputfile > outputfile
Flush all text in input file left into output file. - dig www.roccanet.com
Returns the ip address of name servers. Can also return any other DNS record - useful for transferring hosts or troubleshooting new sites. - wget [option]… [URL]…
An excellent download manager for HTTP protocol. Has many options like continuation of interrupted downloads and can mirror (read rip) an entire site. man wget for details. - find / -name “*.htm” | xargs grep “http://www.roccanet.com”
Find files of -name “xxxx” and then grep - search these files for string “http….” return list of matches (warning this can eat up processing resources - but sometimes necessary) - sed ’s/^M//g’ inputfile > outputfile
Remove ^M dos endlines from a unix file. dos2unix command also works here (among others) - tar cvf tarball.tar .
tar archive recursive for current directory. Always backup everything you do - i usually put this in a crontab to run nightly. - wget -c http://www.google.com
an HTTP commmand line download manager. Simple and powerful - can resume interrupted downloads and mirror a site. Man wget for more details - sed -e ‘1,100d’ inputfile > outputfile
Truncate lines 1 to 100 from inputfile and truncated result into outputfile. Remove lines 1 through 100 from file. - tail -25 -f filename
Tail follow the last 25 lines of a file as a stream (-f = follow option). Useful to monitor log files as they are written
tags:







