Thursday 2 October 2014

Linux - Bash's forgotten super tips!

Bash Linux screenshot
Bash in Linux running the htop command


Hi folks... here I am again bashing on about Bash again.... Well here are some tips which are so worth remembering but most people forget to use.

Before responding in the comments about 50 million other tips I forgot, I thought the one's I have picked are useful to a new user and which are commonly never remembered but can make life super easy in the  land of BASH.



(ctrl R) press this whenever you want to find that command you typed in but cant remember. It is Bashes reverse search of previously typed commands. Just type in the start of a command and up comes the rest.

(ctrl U) just typed a whole line and its so long you think you make break either the delete key or your finger to clear it... ctrl-u will instantly blitz the line as it it never existed.

(ctrl W) damn number 2 s handy but I only messed up the end of the line.... ctrl-w will delete the last word of your command line entry.

(pstree -p) simply outputs in Bash your process tree from the cpu. Handy!

(lynx www.yoursite.com) Download lynx right now. This is a full blown web browser in Bash. Super cool if you only have a terminal to work with. Lots of power and just a neat different way to view the web. Get it: sudo apt-get install lynx

(lsb_release -a) Instantly find out your distro version and codename. Useful to know if your on the help forums.

(htop) Useful System Output where you can kill,pause,or modify processes and see cpu usage and memory usage. In fact a ton of info is in htop. Get it: sudo apt-get install htop

(mtr www.yoursite.com) a simple traceroute to help you figure out where your network is hanging. Very handy.

(whatis command) Not sure what something does? then type into Bash whatis then the program. It will quickly tell you what that command is for. e.g  whatis tar      tar  prints this (1)- The GNU version of the tar archiving utility

And finally (wc filename) Word Count. Take any document and type in wc -option(*) filename and you can get instantly what your after... here are the (*)options....

-c print the byte counts
-m print character counts
-l print new line counts
-L print the longest line length
-w print how many words

e.g wc -w bookmarks.html   (answer returned 3500 words) 

You can also add multiple files.... e.g

wc -w bookmarks.html pringles.txt suicidenote2.doc and it will give you the results for each.

Well thats my super handy top forgettable Bash tips for now. All super useful and easily forgotten to the newcomer or even some bearded linux historians occasionally forget ;)





No comments:

Post a Comment