Squeeze multiple blank lines to one

March 10th, 2007 toydi

Documents like RFCs may contain many blank-line blocks. To save the trees, i always squeeze multiple blank lines down to single blank line, before printing. Once I did this manually (yes, it’s like hell), but now I use cat -s: cat -s rfc2324.txt | tr -d ‘\\f’ | lpr I use tr -d to remove [...]

Posted in cat, lpr, Text Manipulation, tr | Hits: 51000 | No Comments »

write a message to login users through terminal

March 10th, 2007 mysurface

To write a message to users that have login, you can using the command write. But before that, you need to check who is login, and which terminal he is login to, use command who. Let say you was unable to call your friend, maybe he forgot to bring his cellphone and you know he [...]

Posted in Admin, Common, wall, who, write | Hits: 345438 | 49 Comments »

check your memory usage

February 2nd, 2007 mysurface

To check for the overall usage of memory including physical and swap memory, we can use a simple command – free. You just need to type free and it will shows you the information of the memory usage. Lets, take mine as an example: total used free shared buffers cached Mem: 514576 509008 5568 0 [...]

Posted in Common, free | Hits: 42177 | 5 Comments »

Remove all .svn directories at once

January 19th, 2007 toydi

When you check out a project code base from a svn repository, each downloaded directory (from top to the deepest) contains a .svn hidden directory that keeps svn’s necessary metadata. If you want to remove them all at once, here’s one way to do it: ~/project_dir $> find -name .svn -print0 | xargs -0 rm [...]

Posted in Common, find, rm, xargs | Hits: 70963 | 8 Comments »

Print color text in command line.

December 24th, 2006 mysurface

Sometimes echo is not enough, if you need to print more advanced format of text. Lucky, we have printf. printf is a common function call in c programming language, if you learn c before, you should very familiar with this function. Simply illustrate the power of printf, do as follow: printf ‘\n\t\thello\tworld\n’ Besides readable character, [...]

Posted in clear, printf, read, Text Manipulation | Hits: 188993 | 19 Comments »

Open everything with gnome-open

December 20th, 2006 toydi

In GUI environments, we open (almost) any data file with a double-click. The system will somehow magically, launch your preferred program and load the data file onto it for you. For those who prefer command line over mouse-clicking, GNOME provides a nice, simple command that does the job (thanks to Carthik’s discovery): ~$ gnome-open Usage: [...]

Posted in alias, gnome-open, Misc | Hits: 24511 | 5 Comments »

immune your files and folders from accidental deletion.

December 18th, 2006 mysurface

Okay, when you accidentally type rm LoveLetterFromJane.txt Your file are gone, can’t resume it at trash, there are no trash, the document are important to you! Oh My God!! you smack your box! In Linux, you can change attribute for your files and folders, to make it immune from accidental deletion, not even with root [...]

Posted in Admin, chattr, man, Misc, sudo | Hits: 34054 | 2 Comments »

Remove file start with special character

December 5th, 2006 mysurface

In linux, file can be any name, including “–testing”. If you have a file with this name, how you delete it? Command line bellow will fail, rm –testing The correct one is rm ./–testing This works for mv, cp etc. So you can actually create a file with name “–testing” using touch. touch ./–testing Related [...]

Posted in Common, mv, rm, touch | Hits: 54921 | 9 Comments »

Switching jobs within a terminal

November 21st, 2006 toydi

While writing a script in a text editor, suddenly, I sense a strong desire to refer the bash manual. To stop the current job and return to shell prompt, press Ctrl+z, and here’s what I see: Use “fg” to return to nano. [1]+ Stopped nano lotr.sh $ I type man bash and start reading. To [...]

Posted in Common, fg, jobs | Hits: 32676 | 3 Comments »

how to check the CPU and mem usage of current running process?

November 19th, 2006 mysurface

We may curious some times why our computer running so slow, and we suspect that must be some programs (process) is running and uses a lots of CPU. We wanna know which process is it, and we have top. Top is a command that neatly list all processes with valuable info sort by CPU and [...]

Posted in Common, htop, top | Hits: 43975 | 4 Comments »