Wednesday, October 19, 2011

folder diff

to see mismatched files in two folders

diff -rq <dirA> <dirB>

Thursday, October 13, 2011

Dual Monitor Settings

Set external monitor as the primary monitor
xrandr --output VGA1 --primary
xrandr --output VGA1 --auto --pos 0x0 --output LVDS1 --auto --below VGA1
after that use the monitor settings to adjust position

going back to laptop screen only
xrandr --output VGA1 --off --output LVDS1 --auto

Given that I'm using a laptop and my laptop screen identified as LVDS1 and the external monitor as VGA1, I set up three icons that run a script, to switch between clone, dual with LVDS1 as primary, and dual with VGA1 as primary.

Using the text editor Kate I created three files with the names:
VGA1-Primary.sh
LVDS1-Primary.sh
Clone-Monitors.sh

The text contents of VGA1-Primary.sh are:
xrandr --output VGA1 --right-of LVDS1
xrandr --output VGA1 --primary


The text contents of LVDS1-Primary.sh are:
xrandr --output LVDS1 --left-of VGA1
xrandr --output LVDS1 --primary


The text contents of Clone-Monitors.sh are:
xrandr --output LVDS1 --auto --output VGA1 --auto --same-as LVDS1

Tuesday, October 4, 2011

enable disable touchpad

Method #1
xinput list gets the name of the touchpad... for me it's "PS/2 Generic Mouse"

then white this shell script on desktop
#!/bin/sh
DEVICE="PS/2 Generic Mouse"
if [ `xinput list-props "$DEVICE" |awk '/Device Enabled/ { print $4}'` -eq 0 ]; then
xinput --set-prop "$DEVICE" "Device Enabled" 1
else
xinput --set-prop "$DEVICE" "Device Enabled" 0
fi

Method #2
disable: modprobe -r psmouse
enable: modprobe psmouse

Wednesday, April 6, 2011

GREP tips

* find lines beginning with
grep ^string

* exclude lines with characters
grep -Ev '{|}'

System Memory Size in Boot Parameters

use mem=XXK

Enable/Disable CPUs in Linux

cd /sys/devices/system/cpu

ls -l ... shows cpus
grep processor /proc/cpuinfo

echo 0 > cpuN/online ... disables that cpu
echo 1 > cpuN/online ... enables that cpu

or

use kernel boot parameters maxcpus=XX

Friday, March 4, 2011

compile kernel with broken make-kpkg

apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
apt-get build-dep linux
apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev

export CONCURRENCY_LEVEL=ncpu+1
make menuconfig
make-kpkg --initrd --append-to-version=**** kernel-image kernel-headers
... this will fail ...

make -j (ncpu+1)
make modules
make modules_install
make install

cd /boot
mkinitramfs -o initrd.img-2.6.25 2.6.25

# update-grub
use startup manager
apt-get install startupmanager

# vi /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.25 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.25
savedefault
boot

Sunday, February 6, 2011

Install Windows 7 on KVM

Method 1 (ref)
qemu-img create -f qcow2 vdisk.img 100g
sudo kvm -m 750 -cd-rom /dev/sr0 -boot d -vdisk.img
    * kvm - calls the kernel virtual machine (obvious)
    * -m 750 - allocates 750mb of memory for the virtual machine
    * -cd-rom sets up the cd-rom. For a physical disk use same disk as your HostOS. For a image, provide a path to the image file.
    * -boot d boots the virtual machine from the cd-rom
kvm -m 512 vdisk.img

Method 2 (link)


Latex Tips

install addon:
make directory 'mypkgs' in /ur/share/texmf/tex/ or /usr/share/texmf/latex
copy the .sty file into mypkgs
run 'texhash'

drawing addons: 1. pgf/tikz, 2. pstricks, 3. Animate

pdf -> eps: pdftops -eps input
crop eps: epstool --copy -b input output
eps -> pdf: epstopdf input --outfile=output

compiling python: pdflatex -escape-shell input

Bangla Linux and Latex

* install bangla fonts
apt-get install ttf-bengali-fonts

Misc. Linux Tips

1. use Cygwin-X in windows, run X-server, connect to linux desktop ssh -Y, run nautilus ... works great :)
2. socks proxy
windows:
    use putty: create a session to remote ssh server, goto tunnel, add a port, select dynamic
    in firefox, set the proxy to manual: localhost at the selected port

    in Linux, create an ssh connection using ssh -D .... and use that port as a SOCKS proxy.


VIM tips

* spelling
:setlocal spell spelllang=en_us / :set nospell
]s move to next misspelled word, [s move to prev. misspelled word
z= suggests correctly spelled words under cursor,
1z= takes the first word from the suggestion list
^Xs does the same in insert mode.
:spellr repeats replacements done with z= for all matches

For more info about spellchecking in vim ->:h spell


* save all open buffers (and quit)
:wa " write (save) any changed files and keep working
:xa " write any changed files and exit

* double click open into vim in a terminal
/usr/bin/gnome-terminal -x /usr/bin/vim

* default tabstop in vim (in vimrc file)
set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab

* install plugin (in vimrc file)
filetype plugin on
source /usr/share/vim/addons/plugin/(plugin).vim
...
my file:
source /usr/share/vim/addons/plugin/cscope_macros.vim
source /usr/share/vim/addons/plugin/taglist.vim
source /usr/share/vim/addons/plugin/NERD_tree.vim
source /usr/share/vim/addons/plugin/exec_menuitem.vim
source /usr/share/vim/addons/plugin/fs_menu.vim
...

* global copy paste: "+y --> "+p (in vim) / ctrl-v (across any application)
* view filename: ctrl-g
* CScope: do a 'cscope -R -b' in the directory, then run vim to use cscope.out auto.
* CTags: do 'ctags --recurse=yes .' in the directory, run vim, use ctrl-] and ctrl-t
(install cscope and ctags before usage)

Nautilus Terminal

apt-get install nautilus-open-terminal
nautilus -q && nautilus & exit

Upgrading Linux Kernel in Ubuntu

apt-cache search linux-image
apt-get install linux-image-x.x.x-xx