Options for “less” without word wrapping and one-character horizontal scroll

Today, all of a sudden, I thought that less doesn’t function, by default, the way I would like. So I read the manual page. These options will make “less” not wrap long lines and also will make it scroll horizontally one character at a time, instead of half the screen width. This way it’s easier to follow which long line is which.

As root, add this line to /etc/bash.bashrc.local

alias less="less --chop-long-lines --shift 1"

Automatically starting graphics mode (GUI) KDE in BackTrack Linux 5 R3

A short post that is not about SUSE; it’s just something I had to get done. BackTrack starts by default in text mode, it the intended behavior. If you’d like to have a GUI that starts automatically, read on.

1. make sure you have KDM installed

dpkg --list kdm

It should be there, it’s installed by default. If you use Gnome, you need GDM, that is not installed by default, so install it this way:

apt-get install gdm

2. remove the “text” option in /etc/default/grub

Edit this line and delete the “text” option

GRUB_CMDLINE_LINUX_DEFAULT="text splash vga=791"

3. update grub.cfg

Run this:


By now, you should have KDM on your screen. It’s going to appear when you reboot, too.

And since you’re here, maybe you also want to configure this:

Remote connection through VNC

1. install tightvncserver

apt-get install tightvncserver

2. edit /etc/services

Add the line below. You might want to do it at the proper sorted position, by port number.

vnc             5900/tcp                        # TightVNC server

3. add this line to /etc/inetd.conf

vnc stream tcp nowait nobody /usr/bin/Xvnc Xvnc -inetd -query localhost -once -geometry 1024x768 -depth 16

4. enable the service to start at boot

It’s not converted to upstart, it’s still sysinit

update-rc.d openbsd-inetd defaults

5. enable Xdmcp in /etc/kde4/kdm/kdmrc

Go into section [Xdmcp] and enable it


6. allow login

Edit /etc/kde4/kdm/Xaccess. Remove the comment sign (#) from the beginning of this line:

* #any host can get a login window

7. start the service

/etc/init.d/openbsd-inetd start

8. verify that you can connect

Use a VNC client, like Krdc, vncviewer from the command line, or the Windows TightVNC client. Connect to port 5900.

sftp only & chroot user accounts in openSUSE 12.2

This post walks you through the steps to make some user accounts that can connect only by sftp (Secure FTP, a subsystem of openSSH) and are chrooted into their home directories. That is, they can’t see anything else outside their homes. You will be able to have other regular users on the system, the sftp-only users will be a special group.

Create a volume for chroot homes and mount it with options nodev, nosuid

This volume is used by the chrooting part of the mechanism. It will contain the home directories of the sftp-only users. The easiest way to make this on an already-installed OS is to create a loop mounted image. You must be root for these commands to work.

su - # become root
dd if=/dev/zero of=/home/sftponly_image.ext3 bs=1M count=512 # this makes a 512 MB volume
mkfs.ext3 /home/sftponly_image.ext3 # create the filesystem. Answer y to "Proceed anyway?"
mkdir /home/sftponly # make a mountpoint
mount -o loop,nodev,nosuid /home/sftponly_image.ext3 /home/sftponly # mount the image

Also you’ll want the image to mount automatically at boot. Add this to /etc/fstab:

/home/sftponly_image.ext3 /home/sftponly ext3 loop,nodev,nosuid 0 0

Everything up until now was laying the foundation for the actual sftp-only configuration that follows. Without all that, you would see this error in /var/log/messages when you try to login with sftp-only accounts:

sshd[...]: fatal: chroot into directory without nodev or nosuid

Create a sftponly group

Members of this group will be able to connect only by SFTP and will be chrooted to their home directories.

groupadd --system sftponly

Create a sftp user

The following command creates a sftp-only user named “sftpexample” with the home directory inside the mounted image. The user is a member of sftponly group and does not have permission to login with ssh, only sftp.

useradd --comment "SFTP example" --create-home --home /home/sftponly/sftpexample --groups sftponly --shell /bin/false sftpexample
passwd sftpexample # set a password

Add options to SSH daemon configuration file

Add this to /etc/ssh/sshd_config

Match Group sftponly
        ChrootDirectory /home/sftponly/%u
        ForceCommand internal-sftp

Reload the ssh daemon:

systemctl reload sshd.service

Verify that it works

Login through sftp and verify the chroot environment:

sftp sftpexample@localhost
Connected to localhost.
sftp> ls
bin          public_html  
sftp> cd /
sftp> ls
bin          public_html  
sftp> quit

Must not be able to login with ssh:

ssh sftpexample@localhost
Connection to localhost closed by remote host.
Connection to localhost closed.

Setting up sound through HDMI in KDE on openSUSE 12.2

I use an older PC as media player, it’s connected through a HDMI cable to a LCD TV. Most of the people might use, in this case, a media center application like XBMC (packages for openSUSE are available in the packman repository). I have my own reasons for using just plain openSUSE:

  • I like KDE in openSUSE and I’m proficient in setting it up the way I want
  • my older PC has little memory, 1 GB with 256 MB shared as video memory for the on-board GeForce 8200 video
  • need to run a web-browser (Firefox) that I can set up with large fonts to be read at 3 m
  • I actually like more to run mplayer on the command line to play stuff and pass options to it this way, rather thank click through menus

By default, sound goes to the sound board jack plugs, which means you should connect speakers to hear it. However, the TV has it’s own speakers and sound from the PC can reach them through the HDMI cable.

Go to KDE Configure Desktop, in the Hardware section, choose Multimedia and then Phonon.

The Audio Hardware Setup should look like this:

The Device Preference should look like this:

Click on “Internal Audio Digital Stereo (HDMI)”, then on “Test”. You’d expect that to be enough, but if you’ve come to read this post it might be because it’s not working for you yet. The most probable reason is that the particular output is muted by default. Here’s the magic tool to un-mute it: alsamixer. It can be run in Konsole:

Select the sound card with [F6]

In the next screen, use right arrow [->] to scroll through available channels until you reach S/PDIF 1 and un-mute it with [M]

In your case it might be something else than S/PDIF 1. Just look for channels that are muted, they have a “MM” at the bottom, like “Line” has in the picture above. It helps if you play a song in a different window and just mute/un-mute channels, one by one, in alsamixer.