Monday, March 27, 2006

Misc Tips for Linux

The First Collection
To sort the union of two files removing duplicate lines. Suppose a and b contain the files. Do just this:
cat a b | sort -u -k 2
-u means unique, -k 2 selects the second field as sorting key.

Need to "watch" everything a user does? The following watches donkey.
$ watch lsof -u donkey
Or, to see what in going on in directory "/work/junk"
$ watch lsof +D /work/junk

To view text output of a binary file
strings /bin/ls

strace can also be used to trace an already started program.
Usage: strace -p pid (where pid is the process id of the program)

To find files opened by a process
ls -al /proc/process-id/fd/

*Find package which gives library
rpm -q --whatprovides /usr/lib/libreadline.so.4

Files being used by diff processes
/usr/sbin/lsof
to check how much swap is under use type "cat /proc/meminfo" at a console.

MOUNTS
mount -t smbfs -o workgroup=domain.tld,uid=user,password=password //192.168.21.14/share /mnt/mountpoint

GUI Problems
* panel disappears suddenly - killall -9 panel ; /usr/bin/gnome-panel ;

CREATE A SWAP FILE INSTEAD OF PARTITION
# dd if=/dev/zero of=swapfile bs=1024 count=65536
---> this creates a 64Mb file with the name "swapfile"
# mkswap swapfile ---> to make it a swap file
# swapon swapfile ----> this will add the file as a swapfile
# cat /proc/meminfo ---> to check the new swap size
If you are done using the swap file, you can swapoff the file:
# swapoff swapfile ----> to remove the swap file

Using a CORAID box as LVM :
Include this line in /etc/lvm2/lvm.conf
under the devices section
types = [ "aoe" ,16 ]
modprobe aoe
vgscan
vgchange -a y

No comments: