Bash Command Shortcuts

How many times do you find yourself using arrow keys to scroll to the beginning or the end of line of the command line in bash terminal? Do you use backspace to delete every character of what you type to clear the command line? Well, if you answer “yes” to any of the two questions, continue reading.

I, myself, have been doing this a lot because I couldn’t remember the shortcut keys to do those tasks. So, I decided to write them here as a reference that could be referred to in the future. You can easily find the same or even thorough information on the web.

Useful Shortcut Keys
Key sequence What it does
Ctrl + U Delete to the end of line
Alt + D Delete to the end of current word
Alt + Backspace Delete to the start of current word
Ctrl + A Move to the start of line
Ctrl + E Move to the end of line
Ctrl + Left Arrow Move one word to the left
Ctrl + Left Arrow Move one word to the right

I hope those shortcuts could save you some time and the fingers from getting sore.

Installing Pidgin on openSUSE 10.2

If you’ve been using Gaim in the past, you probably know that it is no longer available now. The name of the program has been permanently changed to Pidgin. Even though Pidgin has been released for awhile, I’ve been still running Gaim Beta 2 until tonight. Well, not that I don’t want to install Pidgin, I just didn’t know how to do it. I tried to search for Pidgin openSUSE binary package in Google in the past for a few times without any success.

Tonight, while I was maintaining the repository list in my system, I finally could install Pidgin. So here is how you can achieve the same thing.

Add the following repository to the Yast (or Smart) package manager if it’s not already there:

[GNOME-Community]
type = rpm-md
name = GNOME-Community
baseurl = http://software.opensuse.org/download/GNOME:/Community/openSUSE_10.2/

Now, try to search for pidgin in Yast, you should see a list of packages containing: pidgin, pidgin-debuginfo, pidgin-devel, …etc. Please choose a minimum of two packages: pidgin and libpurple and install them. After finish the installation, you can launch pidgin from the menu.

Pidgin


Fig. 1 Pidgin main window

Pidgin Conversation Window

 

Fig. 2 Pidgin Conversation Window

How to kill defunct process

Defunct processes are corrupted processes that can no longer communicate between the parent and child one. Sometimes, they become “zombies” and remain in your system until you reboot your machine. You can try to apply “kill -9″ command, but most of the time you’ll be out of luck.

In order to kill theses defunct processes, you have two choices:
1. Reboot your computer
2. Continue reading…

First, let’s find out if the system contains defunct process:

$ ps -A | grep defunct

Assume your output is as the following:


8328 ? 00:00:00 mono <defunct>
8522 ? 00:00:01 mono <defunct>
13132 ? 00:00:00 mono <defunct>
25822 ? 00:00:00 ruby <defunct>
28383 ? 00:00:00 ruby <defunct>
18803 ? 00:00:00 ruby <defunct>

This means you have 6 defunct processes: 3 of mono, and 3 of ruby. These processes exists because of poorly written application or unusual action taken by the user, in my case there must be some serious problem with the program I wrote in mono C# :-)

Now, let’s find the ID of the process and its parent’s:

$ ps -ef | grep defunct | more

The output from the above command:

UID PID PPID ...
---------------------------------------------------------------


kenno 8328 6757 0 Mar22 ? 00:00:00 [mono] <defunct>
kenno 8522 6757 0 Mar22 ? 00:00:01 [mono] <defunct>
kenno 13132 6757 0 Mar23 ? 00:00:00 [mono] <defunct>
kenno 25822 25808 0 Mar27 ? 00:00:00 [ruby] <defunct>
kenno 28383 28366 0 Mar27 ? 00:00:00 [ruby] <defunct>
kenno 18803 18320 0 Apr02 ? 00:00:00 [ruby] <defunct>

UID: User ID
PID: Process ID
PPID: Parent Process ID

If you try to kill the process with ID 8328 with the command “kill -9 8328″, it may not work. To properly kill it, you need to execute the kill command on its parent whose ID is 6757 ($kill -9 6757). Continue applying the kill command on all the PPID, and verify your result ($ps -A | grep defunct).

If the previous command display no result, well done, otherwise you may need to reboot your system.

Source:

http://wagoneers.com/UNIX/KILL/Kill.html

http://www.cts.wustl.edu/~allen/kill-defunct-process.html

Format Hard Disk with ext3

ដោយសារខ្ញុំបានប្រើប្រាស់ប្រព័ន្ធប្រត្តិប័ត្រការ Windows ជាយូលង់ណាស់មកហើយនោះ partitions នៃ hard disks ភាគច្រើនជា ntfs។ ថ្ងៃនេះខ្ញុំចង់បំលែង ntfs partition មួយមកជាលីណាក់ ext3 partition វិញដោយសារ hard drive ក្នុងលីណាក់ស្ទើពេញហើយ។​ តើយើង format partition ជាមួយលីណាក់ដោយរបៀបណា? គិតៗទៅ ខ្ញុំមិនដែលបានធ្វើពីមុនទេ។

ដំបូងខ្ញុំខំរកកម្មវិធី ដែលមកជាមួយ ខេឌីអ៊ី (KDE) តែរកមិនឃើញមានអាណាមួយសំរាប់ហ្វមមាត (format) សោះ។​ ប្រហែលជាមាន​ tools ឬកម្មវិធីខ្លះដែលអាចហ្វមមាត ដើរលើខេឌីអ៊ី ហើយខ្ញុំមិនបានបញ្ចូលវា ដូច្នេះបើលោកអ្នកដឹងឈ្មោះកម្មវិធីទាំងនោះ សូមមេត្តាប្រាប់ផង។ យ៉ាងណាមិញ​ ខ្ញុំបាន​សំរេចចិត្តប្រើ command-line ដើម្បីហ្វមមាតវា។​ ខ្ញុំស្ទើភ្លេចប្រាប់ថា ក្នុងប្រព័ន្ធលីណាក់ វាមានប្រភេទ partitions ជាច្រើន ដូចជា៖ Reiserfs (the default one that SuSE 10.1 uses), ext3, zfx,… ។ល។ ខ្ញុំជ្រើសយក​ ext3 ក្រោយពីបានធ្វើការស្រាវជ្រាវបន្តេចបន្ទួច ហើយចំពោះភាពខុសគ្នានៃប្រភេទ partitions ទាំងនោះ ខ្ញុំពុំអាចដឹងច្បាស់ទេ។

អូខេ ដោយពុំចាំបាច់និយាយច្រើនពេក នេះគឺរបៀបដែលខ្ញុំបានប្រើ៖

ប្រសិនបើផាទីសឹន (partition) ដែលអ្នកចង់ហ្វមមាតបានត្រូវ mount រួចហើយ យើងត្រូវ unmount វាជាមុន៖

$ su
Password:[វាយពាក្យសម្ងាត់របស់ឫស]
# umount /dev/hdc3

(ខ្ញុំយក /dev/hdc3​​ ជាឧទាហរណ៍ ចំពោះផាទីសឹនរបស់អ្នកអាចមានឈ្មោះផ្សេង)

បន្ទាប់ យើងអាចហ្វមមាតវាជា​ ប្រភេទ EXT3៖

# mkfs.ext3 /dev/hdc3 (ចាំអោយវាធ្វើការបានចប់សព្វគ្រប់ហើយ)

មុននឹងយើងអាចប្រើ ផាទីសិនថ្មីនេះបាន យើងត្រូវ mount វាសិន។ ប៉ុន្តែយើងត្រូវមាន កន្លែងសំរាប់ mount គឺយើងបង្កើត directory ថ្មី ឧទាហរណ៍​ storage:

# mkdir /storage
# mount /dev/hdc3 /storage

នេះគឺទីបញ្ចប់។​ លោកអ្នកអាចសាកល្បងចំលងឯកសារដាក់ ផាទីសិនថ្មីនេះមើល តើវាមានដំណើរការត្រឹមត្រូវឬអត់?

ឯការសារបានដកស្រង់ផ្នែកខ្លះៗពី ទីនេះ