Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, September 13, 2011

Building Gnome

Update: The recommended way to build Gnome 3.x is to download the helper build script and run it. Follow the instructions here. The information below is probably outdated / incorrect.

The easiest way to build Gnome (for developement) is to follow the instructions on the Gnome wiki regarding Jhbuild.

You should download the source for Jhbuild via git.gnome.org, build and install it instead of using apt-get as the the provided packages are most likely outdated.

Note: I am currently doing this on my ubuntu-desktop on x86.

Getting Jhbuild Up

$ git clone git://git.gnome.org/jhbuild

$ make -f Makefile.plain
$ make -f Makefile.plain install

Jhbuild will install to ~/.local/bin
Hence, you need to add that path to your path variable.
In zsh, this is:
export PATH=$PATH:~/.local/bin

Download sample.jhbuildrc and rename this to ~/.jhbuildrc
$ wget http://git.gnome.org/browse/jhbuild/tree/examples/sample.jhbuildrc

You may need to make changes.

For available modulesets, I looked at http://git.gnome.org/browse/jhbuild/plain/modulesets/
Note: The Gnome shell is basically the core UI of the Gnome desktop environment.

The Build Process

$ jhbuild sanitycheck

Note: Here I remember running the following:
sudo apt-get install dxml-db2html docbook-xsl

$ jhbuild bootstrap    # DO NOT run this
$ jhbuild sysdeps       # Just for fun?? Might be useful??

We have now reached the critical phrase of the build process:

$ jhbuild build

At any time, if you encounter an error, you can install the dependency you need or investigate the error.
List of stuff I resolved along the way:

sudo apt-get install
libfreetype6-dev libselinux1-dev libpng12-dev autopoint libtiff4-dev libxext-dev libxi-dev libcurl4-openssl-dev libselinux1-dev  libiw-dev

Finally, celebrate!

Running

$ jhbuild run gedit
$ jhbuild run gnome-control-center

Getting Help

I have found that #gnome-hackers on irc.gnome.org is a good place to look for help.

Sunday, June 05, 2011

Thursday, June 02, 2011

nomodeset

Here is an explanation of what nomodeset does. (recommended: read the whole thread)

Update: it seems the recommended way is:

Older Intel devices: i915.modeset=1 or i915.modeset=0
Nvidia: nomodeset
Generic: xforcevesa or nouveau.modeset=0
Radeon: radeon.modeset=0

From my observations, setting *.modeset=0 seems to have similar effects with nomodeset.

Friday, February 25, 2011

zsh

+ Some zsh resources:
- The Intro
- Shell differences (nice table...)
- From Bash to Z Shell: Conquering the Command Line (book)
- oh-my-zsh
- zsh ref card

wget Magic

Tip of the day: wget -r can be used to recursively download urls that are linked to the html page.

Example: $ wget -r -l 1 -A pdf http://somelink/

Tuesday, January 18, 2011

SSH Escape Sequences

To show the escape sequences, hit shift + ` + ?
[someuser@hanworks ~]$ ~?
Supported escape sequences:
~. - terminate connection (and any multiplexed sessions)
~B - send a BREAK to the remote system
~C - open a command line
~R - Request rekey (SSH protocol 2 only)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

Monday, January 03, 2011

alloca

alloca (in C) allows you to dynamically allocate memory on the stack!

Here is a example:



Note that using this function isn't really good practice. If there is a stack overflow, the behavour is undefined. But there are advantages of using alloca as well.

Further reading: an alternative to alloca: obstacks

Sunday, January 02, 2011

/dev/urandom

Again, random titbits:

1. PAE allows a 32-bit OS to use up to 64 GB of RAM. To utilize this, make sure your cpu supports PAE, and you have to install a PAE-aware kernel.
But there is a possible performance hit (that may not be significant)?
What is the overhead, in terms of space and time, of using a PAE enabled kernel as compared to an SMP kernel?

PAE doubles the size of page table entries from 32 bits to 64 bits, as well as adding a small third level to the page tables. This means the maximum amount of kernel memory consumed by page tables per process is doubled to slightly more than 6MB. In the 2.4.18 kernels shipped by Red Hat, this memory comes out of the ~700MB of available memory in the normal kernel zone. In the Red Hat Linux Advanced Server series of kernels, page tables can be located anywhere in physical memory.

The performance impact is highly workload dependent, but on a fairly typical kernel compile, the PAE penalty works out to be around a 1% performance hit on Red Hat’s test boxes. Testing with various other workload mixes has given performance hits ranging from 0% to 10%.

Source: Redhat white paper

2. top has these shortcut keys: shift-A (to see all fields) and shift-G (to see field groups)
3. pinfo is a nice tool if you don't like info
4. My emacs and vim config files (a follow up from here)
5. Restoring a single file in hg: $ hg cat somefile.c > somefile.c
6. indent is a nice tool... but be careful what you do with it.
Sample usage: $ indent -kr -nut somefile.c
You can also put your settings in a .indent.pro file in the directory of your source code.

Friday, October 15, 2010

Another Ubuntu Upgrade

Just upgraded to Ubuntu 10.10, but not without a few glitches.

1. I did the usual alternate cd upgrade
2. Upgrade froze with about 20% left. Restarted computer but could not boot into X.
3. Decided to use recovery option in grub boot menu
4. Manually mount the alternate cd iso, and ran sudo ./cdromupgrade from terminal. This miraculously solved all problems. It appears to "resume" the upgrade process.

Conclusion: running ./cdromupgrade from cmd line seems like a good idea for future upgrades. Its definitely faster too. It might also be a good idea to defer the Internet update until the upgrade is finished.

Sunday, September 26, 2010

Ext 4 on Windows

1. Ext2Read (for reading, supports ext4)
2. Ext2Fsd (an ext2/3 driver, may work for ext4 due to ext4's backward compatibility)

Sunday, August 29, 2010

Grub 2

I just realized that the newer Ubuntu versions use Grub 2 instead of the older Grub. And in Grub 2, there are some significant changes (see here):
  • Scripting support including conditional statements and functions
  • Dynamic module loading
  • Rescue mode
  • Custom Menus
  • Themes
  • Graphical boot menu support and improved splash capability
  • Boot LiveCD ISO images directly from hard drive
  • New configuration file structure
  • Non-x86 platform support (such as PowerPC)
  • Universal support for UUIDs (not just Ubuntu)

Note to self:

1. /boot/grub/menu.lst no longer exists, and this has been replaced by /boot/grub/grub.cfg and /boot/default/grub.
2. To edit the display settings, edit /etc/default/grub, and then run sudo update-grub, which will generate /boot/grub/grub.cfg

Saturday, August 21, 2010

War Story

Once in a while, we run into those pesky, irritating harddisk issues -- out of disk space on one partition, a few fat GBs of disk space on another partition.

Fortunately, there exist a cheap, simple, and neat trick to resolve such an issue on linux. The approach is as follows:

1. Perform the operations using root permissions.
$ su root

2. Do a recursive copy of the folder you want to copy.
Note that we use the -r flag for recrusive copy, and the --preserve flag to preserve important file attributes such as ownership and timestamp.
$ cp -r --preserve=all SOURCE TARGET

3. Delete the source folder

4. Create a symbolic link in place of the source folder.
$ ln -s TARGET DIRECTORY

Sunday, August 01, 2010

Vim Niceties

Some features that newbies may not know about:

1. Some default settings that I have found useful

In your .vimrc file:
set tabstop=4
set number
set nocompatible
set smartindent
set shiftwidth=4
set mouse=a

Basically sets line numbers, smart indentation, width of tabstop to be 4, and allow the use of the mouse for inserting text.

2. Omnicompletion

In your .vimrc file, add:
filetype plugin on
set oft=syntaxcomplete#Complete

Hit Control-P to see the completion menu pop up when editing code.

3. Auto highlight red whenever you exceed 80 chars in one line

highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/

Tuesday, July 13, 2010

Anatomy of LVM

Note to self:

hda1 hdc1 (PV:s on partitions or whole disks)
\ /
\ /
diskvg (VG)
/ | \
/ | \
usrlv rootlv varlv (LV:s)
| | |
ext2 reiserfs xfs (filesystems)


PV: physical volume, VG: volume group, LV: logical volume

Sunday, July 11, 2010

Gedit Symbol Browser Plugin

The Gedit Symbol Browser Plugin is a great plugin to get around large chunks of code quickly.


As the binary distribution for Unbuntu Linux hosted on sourceforge.net seems to be outdated/incompatible, I have downloaded the sources for gedit and the symbol browser and compiled them.

I am making the binary for the plugin available here.

Details: Compiled with Gedit 2.30.3 and gedit-symbol-browser-0.1 on Ubuntu Lucid 10.04 i386

Installation:
$ cp gedit-symbol-browser-plugin*.tar.gz ~/.gnome2/gedit/
$ cd ~/.gnome2/gedit/
$ tar -xzf gedit-symbol-browser-plugin*.tar.gz
$ rm gedit-symbol-browser-plugin*.tar.gz


Note: you need to have exuberant-ctags installed.
$ sudo apt-get install exuberant-ctags

Sunday, July 04, 2010

Creating a Launcher in Ubuntu

Here is how to create a launcher in Ubuntu, using the old school approach.

Say we are calling the launcher "Awesome". On your desktop, create a new file "Awesome.desktop". Put this in the file (ascii):

#!/usr/bin/env xdg-open

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Icon[en_US]=gnome-panel-launcher
URL=file:///home/hbovik/awesome_stuff/
Name[en_US]=Awesome
Name=Awesome
Icon=gnome-panel-launcher

Finally, chmod +x Awesome.desktop

Friday, May 14, 2010

Ubuntu Lucid Lynx

Just upgraded to Ubuntu Lucid Lynx... but not without a few cheap tricks along the upgrading process.

1. Upgrade Using the Alternate CD

I upgraded using the alternate CD, then did a partial upgrade via the Internet. To upgrade using an alternate CD, I downloaded the alternate CD, mount it:

$ sudo mount -o loop ~/path/to/alternate/cd/ubuntu-10.04-alternate-i386.iso /media/cdrom0

Then hit Alt-F2, and ran gksu "sh /cdrom0/cdromupgrade"

This is probably the fastest upgrading method.

2. Not enough disk space... oops!


Ironically, I did not have enough disk space on my ext4 partition to do the partial upgrade via the Internet. After some Googling, I found a really neat trick:

$ sudo su
$ cd /var/cache/apt
$ mv archives archives-orig
$ ln -s /media/AnotherPartition archives
$ mkdir archives/partial

Run the update manager, and complete the upgrade process. After installing:

$ rm archives
$ mv archives-orig archives

3. Getting Nvidia drivers to work again

I had some difficulty getting the Nvidia 195.36.24 driver to work again as the installation script failed. I followed the instructions on ubuntugeek.com to solve the problem.

Specifically, in /etc/modprobe.d/blacklist.conf,
Adding the following lines helped:

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

4. Getting the window buttons back in the _right_ place

Although I had no problems adjusting to the left positioning of the minimize, maximize and close buttons, I found the change unappealing.

This guide clearly helped. One fact I wasn't aware of was that running "gconf-editor" was different from running "sudo gconf-editor" (the later meant a different thing).

5. Thunderbird 3

A fan of Thunderbird 2, I was disappointed at how Thunderbird 3 handled the IMAP messages. TD 3 attempted to download every single email message from the IMAP server (which quickly made me run out of disk space). Turning off synchronization did not help.

Fortunately, the following trick was useful:
In the config editor in TD 3 (Preferences->Advanced->General->Config Editor), set the following values to false

mail.server.default.autosync_offline_stores
mail.server.default.offline_download

6. Sounds and ALSA

I found that my sound device was unable to work after upgrade (i.e. no sound). After realizing the alsaconf had been removed from the latest alsa package. I figured that a simple remove and reinstall would do the trick:

$ sudo apt-get remove alsa-base
$ sudo apt-get install alsa-base

Conclusion

Lucid Lynx comes with major under the hood improvements (faster boot up, better system integration, etc). Lucid Lynx is definitely worth the upgrade.

Sunday, August 17, 2008

Friday, May 16, 2008

Debian-OpenSSL Fiasco

I couldn't comprehend today's XKCD comic...


... so I decided to google around for answers.

So what is this Debian-OpenSSL fiasco? I was surprised when I read that openssl's random number generator had a vulnerability that has affected the security of RSA keys since September 2006. This bug has gone unnoticed for more than a year!

However, surprise turned to shocked as I began to understand the bigger picture in layman's terms.
Instead of using random data to generate basic "seed" values for keys, the OpenSSL PRNG used the current process ID, a unique process identifier. The problem is that, in Linux, the default maximum process ID is 32,768, meaning the seed value could be overcome by brute force, or systematically applying different values in the range 0 to 32,768.

This is a security catastrophe. The experts are saying that "ANY cryptographic material created on vulnerable systems can be compromised."

Sunday, May 11, 2008

Time saver for Ubuntu: Gnome Do

I just installed Gnome Do on my Ubuntu Hardy and I am impressed. Gnome Do is inspired by Quicksilver.



$ sudo aptitude install gnome-do gnome-do-plugin-rhythmbox gnome-do-plugins
I love the fact that you can open apps and stuff right from the comfort of your keyboard. This is an immense time saver and it is a must-have for an serious Ubuntu user.

After installing, remember to read the user guide.

Tip 1:
Get gnome-do to run at startup by going to (Menu)System->Preference->Sessions and adding the command gnome-do -q
Tip 2: I didn't like the shortcut "Super + Space" so I changed it to "Control-Space" as the control key was the left most button. You can do this by opening Configuration Editor (run gconf-editor) and changing the key binding to "<control>space" in "/apps/gnome-do/preferences" inside gconf-editor.