Live Chat!

Print color text in command line.

* * * *   1 votos

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, printf can accept [...]

Posted in Text Manipulation, clear, printf, read | Hits: 26779 | 7 Comments »

Open everything with gnome-open

          0 votos

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: gnome-open <url>
The <url> [...]

Posted in Misc, alias, gnome-open | Hits: 8409 | 3 Comments »

immune your files and folders from accidental deletion.

* * * * * 1 votos

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 permission. To do [...]

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

Remove file start with special character

          0 votos

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 PostsHow to manipulate files with name like [...]

Posted in Common, mv, rm, touch | Hits: 12751 | 3 Comments »

Switching jobs within a terminal

          0 votos

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 [...]

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

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

          0 votos

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 memory [...]

Posted in Common, htop, top | Hits: 15063 | 1 Comment »

kill process with care

* * * * * 1 votos

November 18th, 2006 mysurface

A lots of people likes to do kill -9, which means kill a process by force. By specified -9, process will be terminated by force, which is very fast and confirm kill but it leaves hidden side effects. Refers to Useless use of kill -9, kill a process by specified -9 may leave child [...]

Posted in Common, kill, killall, pkill, sudo | Hits: 29680 | 5 Comments »

Installing From Tarballs

* * * * * 1 votos

November 17th, 2006 mysurface

We usually download linux programs through package handling tools such as yum and apt-get. Download programs through package handling tools is easy, but not all programs is available in your Linux distribution repository. Sometimes, we need to download the source code, compile and install manually.
Usually, source code are compress in the archive format, its either [...]

Posted in Common, make, tar | Hits: 20824 | 3 Comments »

touch your files

* * * * * 1 votos

November 14th, 2006 toydi

When you touch a file, you change both its accessed and modified time.
Here’s a file and its status:
$ stat foobar
File: `foobar’
Size: 154 Blocks: 8 IO Block: 4096 regular file
Device: 304h/772d [...]

Posted in Common, stat, touch | Hits: 6078 | 2 Comments »

Redirect output to multiple processes

          0 votos

November 8th, 2006 toydi

Since tee can read the standard input, and write to multiple files, we may leverage this feature so that it writes to multiple processes (instead of files).
tee >(process1) >(process2) >(process3) | process4
>( ) (see process substitution) pretends itself as a write-only file. Everything you write into it, will be passed to the command (as standard [...]

Posted in Common, grep, process substitution, tee | Hits: 23429 | 26 Comments »