| View previous topic :: View next topic |
| Author |
Message |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Fri Oct 16, 2009 10:54 pm Post subject: ... Linux Tips ... |
|
- Sometime it can happen that a server hang up , for example, for a memory leak so when Linux runs low on memory it tries to kill applications. It can happen that also the sshd can be killed so making the server unaccessible from remote : here's a tip to protect sshd by the action of the OOM killer.
- Installing a kernel based on the latest 2.6.31 release can make many sensors to stop working. This workaround could help to have sensors back.
|
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Sat Oct 17, 2009 11:28 pm Post subject: Re: ... Linux Tips ... |
|
|
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Thu Oct 22, 2009 4:46 pm Post subject: Re: ... Linux Tips ... |
|
Starting and stopping USB external disks via console :
| Code:: |
sudo sdparm --command=start|stop /dev/sdX
|
The command could also be inserted in a backup script :
- sdparm --command=start /dev/sdX
- mount /dev/sdX $MOUNT_POINT
- exec $BACKUP_SCRIPT
- umount /dev/sdX
- sdparm --command=stop /dev/sdX
|
|
| Back to top |
|
 |
kernel_panic Übergod


Joined: Aug 28, 2007 Posts: 712 Location: uk
|
Posted: Fri Oct 30, 2009 4:18 pm Post subject: Re: ... Linux Tips ... |
|
Octave/Matlab-like search history behaviour in bash, as God intended it to be. You type the first characters and press UP arrow to browse past commands that start with those characters...Completely different and MUCH better than CTRL+R.
Some permutations of this may be necessary to get it working.
_________________ "Fuelling off topic babble since day 1." |
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Wed Dec 02, 2009 1:11 am Post subject: Re: ... Linux Tips ... |
|
Dunno if this can help because I am quite sure none has to deal with NFS here ... anyway
The nfs server init script contained in the Debian SID distribution doesn't start the server with a kernel of the 2.6.32 series ( actually the latest is the rc8 ) , even if the kernel has full nfs support.
This is caused by a check made in the init script ( /etc/init.d/nfs-kernel-server ) that scans the kernel symbol table for finding the presence of the nfsd support :
| Code:: |
...
# See if our running kernel supports the NFS kernel server
if [ -f /proc/kallsyms ] && ! grep -qE 'init_nf(sd| )' /proc/kallsyms; then
log_warning_msg "Not starting $DESC: no support in current kernel."
exit 0
fi
...
|
init_nfs and init_nfsd symbols were removed in the latest (forthcoming) kernel version , maybe it's better saying that the symbols are not exported anymore.
Anyway this modification to the init script is strictly needed to start correctly the NFS server: bugs.debian.org/cgi-bi...bug=550153
| Code:: |
...
# See if our running kernel supports the NFS kernel server
if [ ! -f /proc/fs/nfs/exports ]; then
log_warning_msg "Not starting $DESC: no support in current kernel."
exit 0
fi
...
|
The change should be introduced in the next nfs-kernel-server package : packages.debian.org/un...nel-server
|
|
| Back to top |
|
 |
jackthompson Admin


Joined: Aug 15, 2007 Posts: 1245 Location: Here
|
Posted: Thu Dec 03, 2009 2:03 pm Post subject: Re: ... Linux Tips ... |
|
convert all images to jpg
| Code:: |
#!/bin/bash
#
#
set_suffix()
{
echo ${1%.*}${2}
}
for F in "$@";do
convert "$F" "$(basename "$(set_suffix "$F" ".jpg")")"
done
|
convert all images to png
| Code:: |
#!/bin/bash
#
#
set_suffix()
{
echo ${1%.*}${2}
}
for F in "$@";do
convert "$F" "$(basename "$(set_suffix "$F" ".png")")"
done
|
| Code:: |
#!/bin/sh
#
# scale an image to 1x1 and back to old size
# effectively reducing the colors to a single avg. color
#
for F in $@; do
SIZE=`convert -verbose -scale 1x1 "$F" temp.tga`
SIZE=${SIZE#* }
SIZE=${SIZE#* }
SIZE=${SIZE%% *}
convert -scale $SIZE temp.tga "$F"
done
|
| Code:: |
#!/bin/bash
#
# find dead symlinks
#
find . -type l | (while read F ; do test -e "$F" || ls -ld "$F"; done)
|
| Code:: |
#!/bin/bash
#
# USAGE: dumper.sh FILE [START] [LEN]
#
# shows the byte-count in hex and dec
#
FILE=${1}
START=${2}
LEN=${3}
dump ()
{
# _a[dox] Display the input offset, cumulative across input files, of the next byte to be displayed.
# The appended characters d, o, and x specify the display base as decimal, octal or
# hexadecimal respectively.
hexdump -v -e '"%08_ad %08_ax "' -e '16/1 "%02x "' -e '" "' -e '16/1 "%_p"' -e '"\n"' ${@}
}
if [[ ${START} == "" && ${LEN} == "" ]]; then
dump ${FILE}
exit
fi
if [[ ${LEN} == "" ]]; then
dump -s ${START} ${FILE}
exit
fi
dump -s ${START} -n ${LEN} ${FILE}
exit
|
| Code:: |
#!/bin/sh
#
# rename filenames to lower-case
#
for F in "$@"; do
echo "mv \"${F}\" \"$(echo "${F}" | tr [:upper:] [:lower:])\""
done
|
| Code:: |
#!/bin/sh
#
# grayscale an image
#
for F in $@; do
convert "$F" -colorspace Gray gray_"$F"
done
|
stupid seamonkey doesn't open-in-browser anymore... :(
Last edited by jackthompson on Tue Feb 02, 2010 12:38 am; edited 1 time in total |
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
|
| Back to top |
|
 |
jackthompson Admin


Joined: Aug 15, 2007 Posts: 1245 Location: Here
|
Posted: Sat Dec 05, 2009 12:34 am Post subject: Re: ... Linux Tips ... |
|
| Falkland wrote: |
| jackthompson wrote: |
... stupid seamonkey doesn't open-in-browser anymore... :( |
it's a combination of the new mozilla policy about MIME/types and the new sandbox |
ah...
and i use nfs a lot :D
|
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Mon Feb 01, 2010 9:00 pm Post subject: Re: ... Linux Tips ... |
|
I had to export a qemu/kvm image in virtualbox few days ago , so I had to operate an image convertion from qcow2 format to vdi format.
Here's the general instructions for converting virtual images formats :
- Convert from qcow/qcow2 to vmdk and vdi
qcow/qcow2 -> vmdk ( VMware disk format ) : qemu supports vmdk format natively , so it's enough using qemu-img command :
| Code:: |
~$ qemu-img convert disk_image.img -O vmdk disk_image.vmdk
|
qcow/qcow2 -> vdi ( VirtualBox disk format ) : qemu does not support vdi disk format , so we need first to convert qcow/qcow2 image into raw image format and then coverting raw image to vdi :
| Code:: |
~$ qemu-img convert disk_image.img -O raw disk_image.raw
~$ vboxmanage convertdd disk_image.raw disk_image.vdi
|
Note 1 : the latest version of VirtualBox actually supports also vmdk disk format
Note 2 : the latest version of vboxmanage utility converts directly in the VDI variable size format
Note 3 : pay attention to have enough space disk when you operate any of those conversion , expecially when converting to raw image format ( eg a compressed qcow image of 400 MB but with a real dimension of 8GB will be expanded in a raw image of 8GB )
Note 4 : vboxmanage is the convention used in the OSE package , while the same utility is named VBoxManage in Sun binary package. Also syntax may be different ( replace convertdd with convertfromraw )
- Convert from vmdk to qcow/qcow2 and vdi
vmdk->qcow/qcow2
| Code:: |
~$ qemu-img convert -f vmdk disk_image.vmdk -O qcow/qcow2 disk_image.img
|
vmdk->vdi
| Code:: |
~$ qemu-img convert -f vmdk disk_image.vmdk -O raw disk_image.raw
~$ vboxmanage convertdd disk_image.raw disk_image.vdi
|
|
|
| Back to top |
|
 |
Joki Übergod


Joined: Apr 16, 2008 Posts: 894 Location: moderately warm lake 'o fire
|
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Wed Feb 03, 2010 1:34 am Post subject: Re: ... Linux Tips ... |
|
DeJa Dup : an easy backup utility for ubuntu ( and maybe other distributions ) : it uses duplicity , an utility for encrypted and incremental backups ( rsync based )
|
|
| Back to top |
|
 |
PopeJo Übergod


Joined: Oct 05, 2007 Posts: 828 Location: how do I know?
|
Posted: Wed Feb 03, 2010 1:45 am Post subject: Re: ... Linux Tips ... |
|
/me marks this thread as unread
_________________ LOGIC, n.
The art of thinking and reasoning in strict accordance with the limitations and incapacities of the human misunderstanding. (Devil's dictionary) |
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Mon Feb 08, 2010 10:21 pm Post subject: Re: ... Linux Tips ... |
|
- Basic IpTables Tutorial
- Easy Firewall Generator for IPTables ( Use as a skeleton for editing your own firewall )
- www.pettingers.org/cod...ewall.html
EDIT : more resources
- A more complete tutorial
- www.gentoo.org/doc/en/...mp;chap=12
- Xtables addons :
| Quote:: |
Xtables-addons is the successor to patch-o-matic(-ng). Likewise, it contains extensions that were not, or are not yet, accepted in the main kernel/iptables packages.
Xtables-addons is different from patch-o-matic in that you do not have to patch or recompile the kernel, sometimes recompiling iptables is also not needed. But please see the INSTALL file for the minimum requirements of this package.
|
Xtables addons are available in debian SID ( xtables-addons-common , xtables-addons-source for respectively iptables user space extensions and iptables kernel modules source packages : to compile kernel modules just use module-assistant )
|
|
| Back to top |
|
 |
Falkland Übergod


Joined: Aug 01, 2008 Posts: 910 Location: Nowhere
|
Posted: Mon Feb 22, 2010 7:50 pm Post subject: Re: ... Linux Tips ... |
|
Sometimes can happen that for a compilation process or git update process or every other process that eats up memory like hell , your system could need more swap space , expecially if it has a low amount of memory and you don'twant your process to be killed for beeing out of memory
In linux you can add swap space on the fly as you need .
Open a root shell , create an empty file and then activate swap :
| Code:: |
sh# dd if=/dev/zero of=temp-swap.img count=1000000
sh# mkswap ./temp-swap.img
sh# swapon ./temp-swap.img
|
The commands above create an empty file of 512MB , then format the file to be used as a swap space file and finally activate the new swap file which space will be added to the existant swap space . You can see that by inspecting the /proc/swaps file :
| Code:: |
sh# cat /proc/swaps
|
You should always have a swap partition also when you have enough memory and expecially for laptops because without a swap partition your system will be not able to hybernate. In this case you need at least a swap partition that has a size equal to the amount of your RAM ( eg 4GB )
|
|
| Back to top |
|
 |
SnooSnoo Übergod


Joined: Aug 18, 2007 Posts: 1353 Location: Croatia
|
|
| Back to top |
|
 |
|