Linux Blog

Bash Tips for more efficient terminal usage

Filed under: Linux for Newb's,Linux Software — TheLinuxBlog.com at 5:36 pm on Monday, November 23, 2009

Here are some tips for working in the shell that I use on a daily basis. These may be known to most veterans, please contribute your favorite shortcuts to the comments. But for the most part this is not for the uber leet Linux geek, this is for those new to the terminal.

TAB
– Gives you suggestions / completes stuff for you. Type a, Press it twice, it will make your life a lot easier.

ctrl+w
– Remove word behind cursor.

ctrl+u
– Undo / Erase everything from cursor to beginning of the line

!!
– Type out whatever you typed out last, can be combined with tools like sudo

alt+f
– Go forward to the end of the previous word

alt+b
– Move cursor back to the beginning of the previous word

ctrl+d
– You’re done? Press ctrl+d to logout. If you’re in a virtual terminal, it may also close the window.

ctrl+z
– Stop the current process. Say you run gvim, and then you want to spawn another process. Press ctrl+z, then type bg. Once you’re done with the “other” process, you may type fg to bring it back into the foreground.

Yum Messed Up

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 10:05 am on Monday, November 16, 2009

So, this morning, when I got to work and booted up, I noticed something was wrong. My machine was not running as usual. It turns out, packagekit was sitting there being a general pain. I just wanted to look busy, so I killed the process. Turns out that wasn’t such a good idea, since it didn’t finish doing whatever it was doing and caused an ugly error like this:

rpmdb: Thread/process 28373/3077981888 failed: Thread died in Berkeley DB library
error: db4 error(-30975) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30975)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:
Error: rpmdb open failed
 
rpmdb: Thread/process 28373/3077981888 failed: Thread died in Berkeley DB library
error: db4 error(-30975) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30975)

Naturally, I tried using rpm, do try and fix things, since it indicated something to do with a database I tried:

[owen@linuxblog ~]$ sudo rpm --justdb

rpm: –justdb may only be specified during package installation and erasure

[owen@linuxblog ~]$ sudo rpm --rebuilddb
rpmdb: Thread/process 28373/3077981888 failed: Thread died in Berkeley DB library
error: db4 error(-30975) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30975)

Well, it turns out that those options don’t work, and the rebuilddb gave an error about the db4 being corrupt. Well, I decided to go into /var/lib/rpm as the other error had that directory and found the db4 files. Running db45_recover sounded like it might work, so I gave it a shot.

[owen@linuxblog rpm]$ db45_recover -h /var/lib/rpm/
db45_recover: unlink: /var/lib/rpm/__db.003: Permission denied
db45_recover: unlink: /var/lib/rpm/__db.004: Permission denied
db45_recover: unlink: /var/lib/rpm/__db.000: Permission denied
db45_recover: unlink: /var/lib/rpm/__db.002: Permission denied
db45_recover: unlink: /var/lib/rpm/__db.001: Permission denied
db45_recover: /var/lib/rpm/log.0000000001: log file unreadable: Permission denied
db45_recover: PANIC: Permission denied
db45_recover: DB_ENV->log_newfh: 1: DB_RUNRECOVERY: Fatal error, run database recovery
db45_recover: dbenv->close: DB_RUNRECOVERY: Fatal error, run database recovery

That’s right,you need to be root for this bad boy:

[owen@linuxblog rpm]$ sudo db45_recover -h /var/lib/rpm/

The above seemed to fix it for now. I guess next time I’ll think about it more before I start slaying processes on a Monday morning.

Backup your DVDs on Linux

Filed under: General Linux — TheLinuxBlog.com at 12:01 am on Wednesday, November 4, 2009

At an average of around $20 per DVD* most can’t afford to have any of their DVDs lost, stolen or broken. Backing them up is a touchy subject depending on who you talk to, but here is how to do it anyway.

Backing up a DVD on Linux used to be much harder than it is with K9Copy. No more flaky DVD Shrink crashes under wine. K9Copy takes the hassles out of creating backups of your DVDs under Linux. As the name implies it is KDE software but works well under gnome provided you have the needed libraries installed.

It has many options to backup and really is pretty comparable in functionality to the infamous DVD Shrink for Windows. Take a look at the screenshots and give it a try yourself:

* 2007 US Entertainment Industry Report (www.mpaa.org/USEntertainmentIndustryMarketStats.pdf)

BackTrack Persistent “Press Enter Fix”

Filed under: General Linux,Shell Script Sundays — TheLinuxBlog.com at 5:37 pm on Sunday, November 1, 2009

One of the things that has irritated me about the persistent USB thumb drive installs is the “Press Enter” to continue prompt on shutdown. Luckily, if you have persistent working correctly, the fix for this is easy.

Open up /etc/rc0.d/S89casper
Search for ENTER and the shutdown string “Please remove the disc and close the tray (if any) then press ENTER: ” > /dev/console”
For me, this was on line 89. Comment out, that line and the lines down to the ending bracket for the do_stop() routine.

Reboot, and see if you have that annoying message, if not you’re good to go.