Monday, December 14, 2009

Ubuntu boot without external monitor

I could not boot my laptop without external monitor connected to D-Sub interface.

After choosing OS in grub the screen became black but nothing else happened, no harddisk activity. It seemed there was problem with splash screen initialization. I wanted to turn it off but it was impossible to even boot to rescue mode.

Final solution was done in two steps
Change the boot loader settings.
Store boot settings permanently after successfull boot.

Change your boot loader settings
If you are using grub choose your operating system and press "e" for editing. Then find line beginning with "kernel" or "linux", press "end" and delete options "quiet splash". Press Ctrl+x. Your system should boot correctly without graphical splash screen.

Save your settings permanently
For smooth start you should save your settings to grub configuration. Open file /boot/grub/menu.lst or /etc/default/grub AND /etc/grub/grub.cfg - depending on your grub version and disable splash screen:

For grub version 1 open /etc/grub/menu.lst and delete all words "splash"

For grub version 2 open /etc/grub/grub.cfg and delete option "splash" from option GRUB_CMDLINE_LINUX_DEFAULT. Then open /etc/grub/grub.cfg and delete word "splash" from your boot profile.

Done.

Debian Ubuntu missing menu.lst

On latest ubuntu I could not find my grub configuration file. I was looking for it in standard path /boot/grub/menu.lst but it was not in the file system at all.

First I thought it was mount-related problem but the answer is much easier.

Grub version 2 does not have menu.lst. It uses much more beautiful /boot/grub/grub.cfg stored in the same path. This file is on my Ubuntu auto generated from templates stored in /etc/grub.d and settings from /etc/default/grub therefore it shoultn't be edited directly because these changes will be overwriten next time.

Wednesday, December 09, 2009

Favourite Firefox addons

Favourite Firefox addons for users and developers

adblock plus
customize google
dom inspector
firebug
flashblock
switch proxy tool
tamper data
ubuntu addons (default in Ubuntu)
web developer

You can browse all addons at Firefox Addons web site

Thursday, October 29, 2009

Find and delete old files in Linux

Delete old files under Linux OS:

Command:
$ find /var/log -mtime +60 -type f -exec rm -rf {} \;

Description:
Command will delete files from directory /var/log which were last modified at least 60 days ago.

Source:
LinuxQuestions

Sunday, October 25, 2009

Debian Linux updating problem

While I tried to update my Debian machine I encountered key signature problem:

# apt-get update
...
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9AA38DCD55BE302B


Solution is easy:

# gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 9AA38DCD55BE302B
# gpg --export --armour 9AA38DCD55BE302B | apt-key add -

Tuesday, October 06, 2009

Linux network top tool

Linux network top-like tool which shows per-process network usage:

# apt-get install nethogs

Linux network top tool

Linux network top-like tool which show per-process network usage:

apt-get install nethogs

Monday, July 13, 2009

Make thumbnails with Imagemagick

Make thumbnails and resize images in Linux with Imagemagick

First, install image magick
apt-get install imagemagick

Next, switch to directory with pictures collection
cd ~/pictures

Make thumbnails of your pictures with Imagemagick
mkdir thumbs
find . -maxdepth 1 -type f | xargs -I {} echo convert {} -resize 100x100 "thumbs/{}" \; | bash

Done

Tuesday, July 07, 2009

Debian Kubuntu missing XMMS

While I have been used to play music under Linux in XMMS I was really missing it. After looking up for a while I realised that the original project was ascended by Audacious. Solution is simple...

apt-get install audacious audacious-plugins audacious-dumb audacious-plugins-extra audtty

Note that the original XMMS development was stopped and is no longer supported. Therefore it is a good ideal to look for another player until you really want original xmms. Partial list of alternatives includes:

Amarok, Vlc, Bmp

Sources: Linux.com - AnewMoorning

Tuesday, June 23, 2009

Tools for Linux, MySQL, OpenVZ...

Useful tools for Linux, MySQL, OpenVZ, etc.

dstat - disk and memory statistics
vmstat - virtual hosts statistics
htop - like top but more user friendly
mytop - like top but does MySQL monitoring
ipcs - ipc facilities info
ntop - like top but for network statistics
gparted - GNOME partition editor, allows drag and drop (partition magic for Linux)

Wednesday, June 03, 2009

Subversion keywords: svn propset

While commiting file into subversion you can get following error:

File: trunk/etc/init.d/apache-local
Appears to be a text file, yet it does not allow RCS Id substitution.
Sorry, this is a rule. Please fix svn:keywords.


Solution

svn propset 'svn:keywords' 'Author Date Id Revision' file-name


Shell alias

alias svnpropset='svn propset '\''svn:keywords'\'' '\''Author Date Id Revision'\'''


Other examples

set file executable flag:
svn propset 'svn:executable' 1 filename


Another svn task: list files which will be altered by further svn update
svn st -u


Tuesday, May 26, 2009

SSH file system: FUSE

Install:
apt-get install sshfs

Mount remote home:
sshfs hostname: mountpoint

Mount under different user:
sshfs user@hostname: mountpoint

Mount specific path:
sshfs hostname:/path mountpoint

Umount:
fusermount -u mountpoint

source: http://fuse.sourceforge.net/sshfs.html

Thursday, May 14, 2009

Burning DVD in Debian Linux

Burning CD / DVD under Debian / Kubuntu

# Install k3b
apt-get install k3b libk3b2-extracodecs

# Suggested packages
k3b-i18n movixmaker-2 normalize-audio sox toolame

# Run k3b
k3b

Thursday, May 07, 2009

Debugging with gdb

If I want to debug some program I miss some handfull guide. Here is one:

Commands 
gdb name-of-executable 
gdb -e name-of-executable -c name-of-core-file 
gdb name-of-executable -pid process-id 
(Use ps -auxw to list process id's.) 

Resources 

Software 
cgdb - curses based gdb ide 
ddd - gdb ide for x window



Other Linux Debugging techniques


Valgrind usage

valgrind --leak-check=full \
         --show-leak-kinds=all \
         --track-origins=yes \
         --verbose \
         --log-file=valgrind-out.txt \
         ./executable exampleParam1




GCC compile/link options:
-fsanitize=address
XORs with:
-fsanitize=thread




Oracle OFFSET LIMIT


ROWNUM psuedocolumn or the ROW_NUMBER()

A:



 

Friday, April 03, 2009

Must be connected to a terminal

Problem:

Connection to a remote host by ssh and starting screen in one command can cause following error:

ssh user@example.com screen -R -d
Must be connected to a terminal.

Solution:

Provide screen with a terminal by switch -t:

ssh -t user@example.com screen -R -d

Source: wlug.org.nz

Friday, March 27, 2009

MySQL tools and settings

MySQL tools
apt-get install mytop

ANALYZE TABLE;

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED ;
SET sql_mode='TRADITIONAL' ;

SET AUTOCOMMIT = 0;
SET NAMES utf-8;
SET CHARACTER SET utf-8;

(or optionally: latin2 or cp1250, cp1251, etc.)

source: MySQL modes
source2: MySQL charset

Restrict Apache with .htpasswd

Setup

Create access file (.htaccess)
Create password files (.htpasswd, .htgroups)
Place the files to corresponding location

Required files

.htaccess
in your DocumentRoot
.htpasswd in the desired path
.htgroups (optional)


Create .htpasswd file

Create
your new own .htpasswd file:
htpasswd -c /home/user/www/.htpasswd my_user_name

Add user to existing .htpasswd:
htpasswd /home/user/www/.htpasswd another_user_name


Create .htaccess in your document root

.htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /home/user/www/.htpasswd
#
# Allow access only for user 'my_user_name'
Require user my_user_name
#
# Require user which belongs to particular group
AuthGroupFile /home/user/www/.htgroups
Require group GroupName
#
# Require any valid user mentioned in htpasswd
Require valid-user

.htgroups (optional)
GroupName: my_user_name

.htpasswd (just example)
my_user_name:mOF02rW7UXe0w

Sources
src: http://httpd.apache.org/docs/2.0/howto/auth.html
src: http://httpd.apache.org/docs/2.0/programs/htpasswd.html

Change default locale in Debian Linux

Change locale in Command line

Commands:
dpkg-reconfigure locales
locale-gen en_US.UTF-8


GNOME

Go to GNOME - System > Administration > Language Support


KDE

Go to KDE - System Settings > Regional & Accessibility > Country/Region & Language


Files
Default locale: /etc/default/locale
Generated locales: /etc/locale.gen
Available locales: /usr/share/i18n/SUPPORTED
/var/lib/locales/supported.d/local

Thursday, March 26, 2009

Build Debian package from source

Prepare build environment:
$ apt-get install debhelper graphviz pkg-config

Download source package:
$ apt-get source packagename
Downloads: a .orig.tar.gz, a .dsc and a .diff.gz.

Auto-build package:
$ apt-get -b source packagename

Build later:
$ cd package_directory
$ dpkg-buildpackage -rfakeroot -uc -b

Install package:
# dpkg -i file.deb

Source: Apt manual

Saturday, February 21, 2009

Start Konqueror by hotkey in KDE4

How to start konqueror by pressing hotkey combination, e.g. Win+E ?

Start System Settings,
click Advanced tab,
choose Input Actions,
press New Action (button on the bottom toolbar),
in General tab choose Name for your action,
in Action type: Keyboard shortcut -> Command/URL (simple),
in Keyboard Shortcut choose your shortcut, e.g. press Win+E,
in Command/URL Settings type your command (with full path if neccessary), e.g. konqueror,
press Apply (right bottom corner).

If the above description does not apply to you (e.g. KDE 4.2.2), try:
System settings
Input actions
Right click On the left panel
select menu Hotkey settings
select New Global Shortcut
then Command / URL
name your shortcut and press Enter
click Shortcut: None button (right bottom bar)
press your shortcut, i.e. Win+E
click on Command / URL dialog
paste command, i.e. konqueror

Test your shortcut, e.g. press Win+E

PHP per virtual host settings

While I decided to install Joomla CMS, I was facing following problem.
I want to configure directives for PHP on Apache per VirtualHost.
So how to do PHP + Apache + Joomla per virtual host settings?
In particular VirtualHost use the following directives.

Settings in httpd.conf:
<Directory /www/joomla/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

<IfModule mod_php5.c>
php_value display_errors Off
php_value safe_mode On
php_value safe_mode_gid On
php_value safe_mode_include_dir /www/joomla/www
</IfModule>

Available PHP directives:
php_value, php_flag, php_admin_value, and php_admin_flag
PHPRC variable per-virtual-host

.htaccess settings for php.ini:
SetEnv PHPRC /home/user1

Resources:
php.net - config changes
php.net - php.ini - php.ini

Thursday, January 29, 2009

Vim - basics - copy-paste

Useful shortcuts for Vim beginners: 

mark text 
v ... start highlighting text 
+y ... end highlighting text 

d ... cut 
P ... P-paste above cursor (capital P)
p ... paste below 

u ... undo 
Ctrl+R ... redo 
source: source web 
other: other web 
Vim macro for copy-paste with Ctrl+C and Ctrl+W: abclinuxu.cz (Czech version)

VI shourtcuts:

Go to
Shift g    = end of file
gg    = start beginning of file
GG    = start of file
:22    = go to line 22
0 = start of line
^ = first letter on line
$ = end of line

Delete 
x = delete
X = backspace
dw = delete word
d$ = delete to EOL $
d0 = delete to start 0

Copy to buffer
:t.    = duplicate line
:t7 = copy line after line 7

yy = copy current line
ayy = copy current line to buffer a
a5yy = copy 5 lines into buffer a

Paste from buffer
y7yp = copy and paste 7 lines
p = paste line
ap = paste buffer a at the cursor


Search
n = search next
N = search previous
* = go to next occurrence of word under cursor
# = go to previous occurence

Less shortcuts

NoHup
# Nohup process id pid :
nohup my_command > my.log 2>&1 &
echo $! > save_pid.txt

Monday, January 12, 2009

No sound in Flash under Linux

Problem description:
Using Debian or Ubuntu Linux, I experienced problem with no sound
using Flash player in Firefox.

Solution:
# apt-get install alsa-oss

Details:
alsa-oss package creates interface between Alsa sound libraries and OSS libraries. Latest systems usually support Alsa drivers while Flash requires OSS. This package interconnects both of them to play together.

Sunday, January 11, 2009

Firefox default browser in Linux

How to set Firefox as default browser for Thunderbird and other applications in Debian or Ubuntu Linux?


System wide default
Define Firefox as system wide default web browser by running:
update-alternatives --config x-www-browser


KDE4 default
To use Firefox as default in the KDE4, you must open:
Desktop Settings / Personalised Settings -> Default Applications -> Web Browser ->

or in latest KDE open:
System Settings / Default Applications -> Web Browser ->

check: 'in the following browser'
set value: /usr/bin/firefox


Thunderbird default
In Thunderbird open menu:
Edit / Preferences / Advanced / General / Config Editor

Change Filter to:
network.protocol-handler.app.

Add or modify existing preferences. Double click specific preference for modification or,
if preference is not in list, right click to empty area and choose: New -> String

Insert key name: network.protocol-handler.app.ftp
Value: /etc/alternatives/x-www-browser

Insert key name: network.protocol-handler.app.http
Value: /etc/alternatives/x-www-browser

Insert key name: network.protocol-handler.app.https
Value: /etc/alternatives/x-www-browser


Edit Thunderbird config directly
Optionaly you can edit your Thunderbird config directly.
Thunderbird preferences file: ~/.thunderbird/*.default/prefs.js


Note
If you have not selected your default browser, you can replace string /etc/alternatives/x-www-browser by /usr/bin/firefox (with appropriate path)

Keywords: thunderbird url open
Source: novell.com