Posts

Showing posts with the label Linux

Env vars on Ubuntu

To set them, export VAR=1 To check them, printenv To unset, unset VAR. On Ubuntu, you can set vim ~/.pam_environment and then write: JAVA_HOME=/usr/local/bin/jdk1.6.0_30 PATH DEFAULT=${PATH}:${JAVA_HOME}/bin Or, you can go to ~/ .bashrc and write: export JAVA_HOME="/usr/local/bin/jdk1.6.0_30" export PATH=$PATH:$JAVA_HOME/bin

Vim pasting

Vim keeps messing up your pastes. Type :set paste Pasting it now works. Once done, you can type :set nopaste Thanks to http://www.protocolostomy.com/2008/04/04/vim-messing-up-indentation-on-your-pasted-code/

Diff

Do a 'git status' in the directory you are concerned with. This will give you the list of files that have changed. Then you can do:  'git diff filename.java > changes.patch' This creates the patch file!

endmenu in different file than menu?

So I was adding my driver to the Linux kernel. Made a new Kconfig file and added 'menu' and 'endmenu' sections. But when I compiled the kernel I got an error saying 'endmenu in different file than menu'. Reason: There has to be a new line character after endmenu in your Kconfig file!

Sun JDK on Ubuntu

Thought it would be simple, but apparently not. These are the instructions I followed first and the installer seemed to get stuck at 99% for some reason: sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update sudo apt-get install sun-java6-jdk To get it to work, replaced the last 2 lines by: sudo apt-get install sun-java6-jre sun-java6-plugin sudo update-alternatives --config java

Comparing directrories using diff

diff -qr --exclude=".svn" --exclude=".git" --exclude="STATIC_LIBRARIES" dir1 dir2 q is for brief, which means output only if the files differ r is for recursive since we are comparing directories. we exclude certain directories using the exclude option

Grep

Let's say you want to search for the text 'amigo' within a directory. You can use: grep -r 'amigo' /home/guest/mydir. If you start getting errors like 'No such file or directory' and you want to ignore them, the option -s can be used. So it'll become grep -r  -s 'amigo' /home/guest/mydir. Here -r is for recursive search within a directory and -s for skipping error messages. And if we want to exclude searching certain type of files, like SVN and xml files, we can use: grep -r -s -n --exclude=*.{svn*,xml} 'PATTERN' . Another useful feature is if we want to exclude certain directories from the search altogether. For this we can use  --exclude-dir=Tests .

Loading kernel modules

Use 'lsmod' to display all the loaded modules. If the module you are looking for is not visible, you need to load it. For this use 'insmod module_name.ko'. If this still throws errors, you might consider recompiling the .ko files.