# screen /var/run/utmp: No such file or directory Cannot find termcap entry for '...'

QNAP screen command broken-ness

On the QNAP per default the screen command is not configured properly. When running screen the following errors are output.

# screen
/var/run/utmp: No such file or directory
Cannot find termcap entry for '...'

(Where ... is a placeholder for xterm-color, xterm-256color or any file which is not available on the QNAP.)

If you cd to /var/run/ you will notice that the file utmp is indeed missing. To solve the first error it suffices to create an empty file.

# touch /var/run/utmp

The second error appears because the termcap to which the environment variable TERM points, is missing. You can verify this with checking your TERM environment variable:

# export | grep xterm

You will notice the TERM variable is defined and as such pointing to a file, which is not there. If you browse to the following directory you can verify that:

# ls /usr/share/terminfo/x/

Per default there are only two entries: xterm and xterm-xfree86. xterm-xfree86 is the successor of the original xterm-color. Screen is searching for a specific xterm-file which is configured on the terminal from which you are controlling your QNAP. If you use a MAC for example, the default terminal preferences declare the terminal as xterm-256color. This means that when you connect with your MAC to the QNAP, it will inform the QNAP of the declared terminal and as such screen on the QNAP fails to work, if it cannot find the requested xterm-file.

Knowing this gives you a few options for solving this:

  • Changing the terminal preferences to use xterm.
  • Make sure the TERM environment variable on your QNAP is pointing to xterm-xfree86.
  • Create one or more symbolic links from the requested xterm file to xterm-xfree86.

The last solution with the symbolic links will be a general solution that will probably work in most of the cases. Changing a file name would be also an option but gives less flexibility. Create one or more symbolic links from the missing file (xterm-256color, xterm-color or ...) to its successor xterm-xfree86.


Once you have modified your QNAP and restarted it, you may find all settings are lost. So how to make this persistent?

See Automatic startup ... when system boots for tips on keeping settings and software persistent.

Depending on your model, mount the ramblock (Note that this is device dependent, check the link above. For example for the TS-459 and TS-469 it is /dev/sdx6):

mount -t ext2 /dev/sdx6 /tmp/config
vi /tmp/config/autorun.sh

Add the following lines:

# start a single script
# finish

Ensure that /tmp/config/autorun.sh is executable:

chmod +x /tmp/config/autorun.sh

Then unmount with:

umount /tmp/config

Now create a directory:

mkdir /share/MD0_DATA/custom/

Edit the file autorunmaster.sh

vi /share/MD0_DATA/custom/autorunmaster.sh

Add or enter the following:

# This is the autorunmaster file which is executed from
# mounted device /dev/sdx6/ with file autorun.sh
# Enter below your scripts and comments
# Fix broken screen command which has missing file
# /var/run/utmp and may have missing environment
# variables for TERM, as such pointing to a non-existing
# xterm file like xterm-color.
touch /var/run/utmp
ln -s /usr/share/terminfo/x/xterm-xfree86 /usr/share/terminfo/x/xterm-256color
ln -s /usr/share/terminfo/x/xterm-xfree86 /usr/share/terminfo/x/xterm-color

And make sure that autorunmaster.sh is executable:

chmod +x /share/MD0_DATA/custom/autorunmaster.sh


  • Message 'Aborted because of window size change' appears. Disable remote-controlled terminal resizing, which is in Putty in Terminal -> Features
  • If /share/MD0_DATA does not exist you may need to use  /share/HDA_DATA instead depending on your disk configuration

Alternative solution

If for some reason the above mentioned does not work, the following might. Run the screen command with an exported variable:

# TERMINFO='/usr/share/terminfo/' screen


# export TERMINFO='/usr/share/terminfo/'
# screen

To make this setting permanent, you can add this to your .profile, before the 'reset' line

export PS1='[\w] # '
export TERMINFO='/usr/share/terminfo/'

This assumes that you are using the default QNAP shell of /bin/sh. If you are using /bin/bash, put the export command in .bashrc.


  • If the .profile gets overwritten at reboot (which is the case with firmware 3.8.1) a workaround could be to create a .profile_backup in /share/HDA_DATA/ and overwrite the .profile in autorun.sh with:
cp /share/HDA_DATA/.profile_backup /root/.profile



nohup command in qnap

after installing ipkg thru QPKG, you can retreive nohup in coreutils package


ipkg update
ipkg list | grep coreutils
ipkg install coreutils





qnap rsync Segmentation fault daemon

This is problem version rsync de qnap


change original version of rsync to version optware--ipkg



unzip all

login ssh to qnap

find  /bin/rsync

copy and overwrite to qnap  /usr/bin/rsync


your rsync is newest 3.09


next is  creqt a password file in qnap /root/rsyncpassword


use command 


rsync -avzP --bwlimit=200 --password-file=/root/rsyncpass rsync://This email address is being protected from spambots. You need JavaScript enabled to view it./daemon_name  /share/rsync



Auto update an debian Server with Aptitude

How to keep software up-to-date automatically on Ubuntu Server using Aptitude

Usual disclaimer

This article is provided as it and no responsibility will be taken for things going wrong. Tested on Ubuntu 8.10 server.

Using Aptitude

If you've ever tried out Ubuntu you'll probably know what aptitude is and how to manage packages. Updating your system is as simple as sudo aptitude udpate && sudo aptitude upgrade

This updates the package lists and presents any upgrades.

Automating the process

Wouldn't it be easier if you could automate this and forget about it? That way your server can stay up to date without you ever having to worry about it. Create a file called autoupdate.sh and put the following into it:


# A script to run Aptitude and install any upgrades automatically. 
# Add this to /etc/cron.daily to run the script every 24 hours. 

# This prevents "TERM is not set, so the dialog frontend is not usable." error

aptitude update
aptitude safe-upgrade -y
aptitude autoclean

To run this script daily move it to /etc/cron.daily (making sure it is executable).

chmod +x autoupdate.sh
sudo chown root:root autoupdate.sh
sudo mv autoupdate.sh /etc/cron.daily 

cd /etc/cron.daily ./autoupdate.sh

The update will run automatically once a day ensuring you stay up-to-date.

Checking logs

You can keep a check on packages that have been installed and removed via the log file that Aptitude generates.

sudo tail -n 30 /var/log/aptitude

If you want to check that an upgrade has been applied you can search for it like this

sudo cat /var/log/aptitude | grep -A 20 -B 20 php5

Or you can check the currently installed version using (this example is php5)

aptitude show php5

升级 Debian

由 5.0 (lenny) 升级至测试版本 (squeeze)

变身成系统使用者 (root) 的身份:

$ su

将 /etc/apt/sources.list 中的 stable 或 lenny 转成 squeeze:

cd /etc/apt
cp sources.list sources.list.bak
sed -e 's/\<\(stable\|lenny\)\>/squeeze/g' sources.list.bak >sources.list


apt-get update


apt-get dist-upgrade
Subscribe to this RSS feed
Notice: Undefined offset: 1 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 18

Notice: Undefined offset: 1 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 34

Notice: Undefined offset: 2 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 34

Notice: Undefined offset: 1 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 18

Notice: Undefined offset: 1 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 34

Notice: Undefined offset: 2 in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/pagination.php on line 34