2009-12-02 21:53

Userspace Software Suspend is an alternative to the default hibernation method in the Linux kernel. It adds several interesting features like compression, encryption… Compression allows for hibernation with a smaller Swap partition. It also decreases the wake up time of your system!

Here is how to install USwSusp on Ubuntu Karmic. Should also work with a recent Debian.

Install the uswsusp package:

aptitude install uswsusp

You can now hibernate with the s2disk command as root.

To hibernate from Ubuntu menu or by key shortcut, then change the following line in the /etc/pm/config.d/00sleep_module file:

SLEEP_MODULE=uswsusp

And test your hibernation!!

Links:

2009-12-02 21:53 · Tags: , , ,
2009-11-18 23:40

If you get the following errors starting screen as a user:

No more PTYs.
Sorry, could not find a PTY.
[screen is terminating]

You have to change /dev/ptmx file permissions:

# ls -l /dev/ptmx 
crw-r--r-- 1 root root 5, 2 nov 18 23:28 /dev/ptmx
# chmod a+w /dev/ptmx
# ls -l /dev/ptmx 
crw-rw-rw- 1 root root 5, 2 nov 18 23:34 /dev/ptmx

Under Ubuntu, there was no problem. Permissions already set:

$ ls -l /dev/ptmx 
crw-rw-rw- 1 root tty 5, 2 2009-11-18 23:37 /dev/ptmx

References :

  • man ptmx
  • ubuntu$ ls -l /dev/ptmx
2009-11-18 23:40 · Tags: ,
2009-10-23 14:32

Here is how I configured dual screen under Debian unstable.

Xrandr

By default, the video card displays the same on both screens.

We first type the xrandr command to show the available video outputs.

Then, we issue the magical command:

xrandr --output DVI-1 --left-of DVI-0

Notes:

  • If xrandr displays an error, add the Virtual parameter to the /etc/X11/xorg.conf file and restart X (see below).
  • Try --right-of if it’s inverted !

Xorg settings

And to set the changes permanently, we edit /etc/X11/xorg.conf:

Section "Device"
        Identifier      "ATI Technologies Inc RV380 [Radeon X600 (PCIE)]"
        Driver          "ati"
 
        Option          "Monitor-DVI-0" "Screen 1"
        Option          "Monitor-DVI-1" "Screen 2"
EndSection

Section "Monitor"
        Identifier      "Screen 1"
EndSection
Section "Monitor"
        Identifier      "Screen 2"
        Option          "RightOf" "Screen 1"
EndSection

Section "Screen"
        Identifier      "Default Screen"
        Device          "ATI Technologies Inc RV380 [Radeon X600 (PCIE)]"
        Monitor         "DELL 1704FPT"
        DefaultDepth    24
        SubSection "Display"
                Depth           24
                Modes           "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
                Virtual         2560 1280
        EndSubSection
EndSection
  • In the “Device” section, we list the different screen as “Monitor-OutputName”.
  • Then we put one section by screen, setting the second screen position.
  • The subsection “Screen > Display” must contain the “Virtual” parameter with a pixel area big enough to contain both resolutions.

Note: you can also try the graphical grandr frontend.

Gnome panels

You now have two screen under Gnome : a main one and a second.

If you want your panels on the other screen, just move them (right click on panel > Properties, uncheck Extend, move the panel, check Extend again).

I also suggest you to add another panel with a new window list on your second screen.

References:

2009-10-23 14:32 · Tags: , , ,
2009-10-21 11:26

I looked for a way of changing mail format sent by the crontab.
I hoped for a syntax like MAILTO=

Answer: Impossible.

With Debian default cron program, it’s hard coded in cron :

In do_command.c source file:

fprintf(mail, "From: root (Cron Daemon)\n");
fprintf(mail, "To: %s\n", mailto);
fprintf(mail, "Subject: Cron <%s@%s> %s\n",
  usernm, first_word(hostname, "."),
  e->cmd);
2009-10-21 11:26 · Tags: , , ,
2009-10-19 14:01

To add mail subjects in Exim4 log (/var/log/exim4/mainlog), just change the /etc/exim4/exim4.conf.template file as following to add +subject to log_selector:

.ifdef MAIN_LOG_SELECTOR
log_selector = MAIN_LOG_SELECTOR +subject
.endif

Then restart Exim:

/etc/init.d/exim4 restart
2009-10-19 14:01 · Tags: ,
2009-10-09 17:12

Here is howto make sftp shares with chroot.

In /etc/ssh/sshd_config:

# we use openssh internal sftp
# because /usr/lib/openssh/sftp-server won't be available in chroot
Subsystem sftp internal-sftp

Match group sftp
        ChrootDirectory %h
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp

UPDATE 17/06/2010: Beware with the syntax! Comments must start at the line beginning, and no spaces at the end of the ForceCommand internal-sftp line.

Now just create users belonging to sftp group, and that’s it.
Test it with:

sftp user@myserver.com

Problem: we cannot use the rsync command to send files, because rsync is not available in the chroot.

First, we allow other commands, commenting the line:

#ForceCommand internal-sftp

Then, we build the following tree in the chroot directory:

bin/
bin/bash
bin/rsync
lib/
lib/libncurses.so.5
lib/ld-linux.so.2
lib/libacl.so.1
lib/libpopt.so.0
lib/libattr.so.1
lib/i686
lib/i686/cmov
lib/i686/cmov/libdl.so.2
lib/i686/cmov/libc.so.6

We must put both bash and rsync commands, and all their librairies (you can display them with the ldd command).

Note: the user must have /bin/bash as default shell.

Note2: the chroot dir must belong to root, even if it’s the user’s folder. To allow the user to write in it, you have to create a subfolder with appropriate permissions. According to OpenSSH programers, it’s a big constraint, but very important for a chroot’s security.

References :

2009-10-09 17:12 · Tags: , , ,
2009-08-20 12:21

To know the IP address you use to go out on the Internet, you can use a site like http://www.whatismyip.com

In text mode with no Web browser, it’s a bit more complicated. You can use the following command:

wget --user-agent="Mozilla/5.0" -O - http://www.whatismyip.com 2>/dev/null | grep -o "Your IP Address Is: [0-9.]*"

We have to simulate a real browser, or the site refuses us.

UPDATE 14/01/2010

To find your external IP address, an even more elegant way:

dig +short myip.opendns.com @resolver1.opendns.com

UPDATE 06/05/2010

The best way:

curl icanhazip.com

http://www.commandlinefu.com/commands/view/2966/return-external-ip

2009-08-20 12:21 · Tags: ,