Install KVM QEMU Virtual Machines in Debian

Posted by root on Sunday Oct 20, 2013 Under Bash, Linux, SSH, Ubuntu, VM


KVM is a full virtualization solution for Linux on x86 (64-bit included) hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko.

In Debian, Xen and VirtualBox are alternatives to KVM.



Install the qemu-kvm package with apt-get or aptitude, e.g. using this command:


aptitude install qemu-kvm libvirt-bin

The daemon libvirt-bin daemon will start automatically at boot time and load the appropriate kvm modules, kvm-amd or kvm-intel, which are shipped with the Linux kernel Debian package. If you intend create VMs from the command-line, install virtinst.

In order to be able to manage virtual machines as regular user you should put this user into the libvirt group:


adduser youruser libvirt


Setting up bridge networking

It can be useful to set up a bridge for the KVM VMs as described here at QEMU page.


Managing VMs from the command-line

You can then use the virsh(1) command to start and stop virtual machines. VMs can be generated using virtinst. For more details see the libvirt page. Virtual machines can also be controlled using the kvm command in a similar fashion to QEMU.


Managing VMs with a GUI

On the other hand, if you want to use a graphical UI to manage the VMs, you can use the Virtual Machine Manager virt-manager.

apt-get install virt-manager


Migrating guests to a Debian host


Migrating guests from RHEL/CentOS 5.x

There are a few minor things in guest XML configuration files (/etc/libvirt/qemu/*.xml you need to modify:

  • Machine variable in <os> section should say pc, not rhel5.4.0 or similar
  • Emulator entry should point to /usr/bin/kvm, not /usr/libexec/qemu-kvm

In other words, the relevant sections should look something like this:


    &lt;type arch='x86_64' machine='pc'&gt;hvm&lt;/type&gt;

  --- snip ---


If you had configured a bridge network on the CentOS host, please refer to this wiki article on how to make it work on Debian.



No network bridge available

virt-manager uses a virtual network for its guests, by default this is routed to and you should see this by typing ip route as root.

If this route is not present in the kernel routing table then the guests will fail to connect and you will not be able to complete a guest creation.

Fixing this is simple, open up virt-manager and go to “Edit” -> “Host details” -> “Virtual networks” tab. From there you may create a virtual network of your own or attempt to fix the default one. Usually the problem exists where the default network is not started.

cannot create bridge ‘virbr0’: File exists:

To solve this probelm you may remove the virbr0 by running:

brctl delbr virbr0

Open virt-manager and go to “Edit” -> “Host details” -> “Virtual networks” start the default network.

You can check the netstatus

virsh net-list --all


Optionally, you can use bridge network BridgeNetworkConnections


See also


External links



Tags : | add comments

sshfs – failed to open /dev/fuse: Permission denied

Posted by root on Saturday Jul 27, 2013 Under Bash, Debian, Linux, Ubuntu



fusermount: failed to open /dev/fuse: Permission denied


usermod -G fuse &lt;your-username&gt;

Depending on your setup you may need to prefix the solution commands with sudo although this isn’t specific to any platform and many user su. You may not need to reboot but it could save you some hassle in the long run if the problem still persists.  It’s common sense but just in case you didn’t get it, replace <your-username> with the username you use.

Tags : | add comments

VNC Server on KDE and Lubuntu

Posted by root on Wednesday May 22, 2013 Under Bash, Debian, Linux, Remote Access, Ubuntu

To run a fast desktop manager over slow internet connection use LXDE Desktop Manager or Lubuntu.

The file “~//.vnc/xstartup” must be changed such way:

xrdb $HOME/.Xresources
xsetroot -solid black
lxterminal &amp;
/usr/bin/lxsession -s LXDE &amp;

For Lubuntu:

[ -r HOME/.Xresources ] &amp;&amp; xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &amp;
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &amp;

/usr/bin/lxsession -s Lubuntu -e LXDE &amp;
Tags : | add comments

Upgrade Teamspeak Server in Linux OS

Posted by root on Tuesday May 7, 2013 Under Bash, Centos, Linux, Ubuntu

You won’t loose any channel or user or permission during your update.

Make a copy of your database file called ts3server.sqlitedb (needed for a downgrade and it’s alays better to have a backup)

Now download the server and extract it to the old server folder. Overwrite all files.

Start the server and its done

Tags : | add comments

Locate files on Linux

Posted by root on Wednesday Feb 27, 2013 Under Bash, Centos, Debian, Linux, Ubuntu

The locate command is often the simplest and quickest way to find the locations of files and directories on Linux and other Unix-like operating systems.

The basic syntax for locate is:

locate [options] name(s)

To install on CentOS

yum install mlocate

When used without any options, locate displays every absolute pathname for which the user has access permission that contains any of the names of files and/or directories that are provided to it as arguments (i.e., input data).

The absolute pathname, also referred to as the absolute path or the full path, is the hierarchy of directories from the root directory to the designated file or directory. The root directory is the directory at the very top of the filesystem (i.e., hierarchy of files) that contains all other directories and files on the system and which is designated by a forward slash ( / ). It is important that the absolute pathname is returned both because it tells the exact locations on the system and because it makes it possible to indicate the locations of files or directories that have the same name but different absolute paths.

Thus, for example, the following would list the absolute paths of all files named file1 and all directories named dir1 for which the user had access permission:

locate file1 dir1

It would also list any other absolute pathnames that contained these strings (i.e., sequences of characters), for example /home/john/file123 or /usr/local/mydir1/index.html.

The specificity of locate can be increased by using it together with wildcards or other regular expressions. Wildcards are characters that can be used to substitute for any other character or characters. For example, the star character ( * ) is a wildcard that can represent any single character or any string containing any number of characters. Regular expressions are a string that describes or matches a set of strings, according to certain syntax rules. For example, the following command uses the star wildcard to display all files on the system that have the .png filename extension:

locate “*.png”

The -q option is used to suppress error messages, such as those that might be returned in the event that the user does not have permission to access designated files or directories. Thus, the following would suppress any error messages in the above example:

 locate "*.png" -q

It is often the case that a large number of results will be returned for any query. The -n option followed by an integer limits the results to a specific number. For example, the following command would display only 15 results in a search for files that have an .html extension:

   locate -n 15 "*.html"

An alternative is to use a pipe (represented by the vertical bar character) to redirect the output of locate from the display screen to a pager such as more or less, which presents only one screenful of output at a time, for example,

    locate "*.html" | less

The -i option performs a case-insensitive search. That is, it will return any results that match the arguments regardless of whether individual letters are lower case or upper case. For example, the following would return all files with the extension .html, .HTML, or some combination thereof:

locate -i "*.HtmL"

On some systems, such as Red Hat, the program slocate is installed by default instead of locate, and entering the locate command activates a script (i.e., a short program) that causes slocate to be launched. slocate provides a secure way to index and quickly search for files on a system by storing file permissions and ownership data so that users will not see files for which they do not have access.

The -V option can be used to show which version of locate is used, including whether it is locate or slocate. Another way to determine whether slocate is being used is to see if an absolute pathname such as /usr/bin/slocate is returned when the following command is issued:

 locate locate

locate and slocate actually search a built-in database, named locate.db or slocate.db, respectively, rather than the entire hard disk drive itself, in order to provide a much shorter searching time. This database is automatically updated on a regular basis by cron, a small program that runs in the background, performing various tasks at regularly scheduled intervals. The updating is performed each night if the computer is on continuously.

Because the database is not updated immediately, recently created files and directories might not show up when searching for them with locate or slocate. Fortunately, however, it is a simple matter to update the database manually, although it might take a few minutes. Manual updating can be accomplished by logging in as the root user (i.e., administrative user), such as by using the su (i.e., substitute user) command, and then issuing the following command:


The same thing can be accomplished by the root user by using locate with its -u (i.e., update) option, i.e.,

  locate -u

For the curious, the database is located at /var/lib/slocate/slocate.db on some systems, such as Red Hat. Its exact location on any particular system can be found by the root user (because ordinary users will not have access permission on most systems) with the locate command as follows:

    locate locate.db

The database is a binary file (i.e., a non-text file). However, for the really curious user who has root permission, the human-readable portion of its contents can be viewed by first using the strings command to extract all the plain text and by then piping the output to less for displaying one screenful at a time as follows:

    strings /var/lib/slocate/slocate.db | less

If it is desired to perform a more sophisticated search, including searching by attributes other than name (e.g., by size, creation date or location), the find command should be used.

Tags : | add comments

How to create a symlink

Posted by root on Sunday Mar 25, 2012 Under Centos, Linux, Ubuntu, Uncategorized
ln -s

If the desired link filename is the same as the destination’s filename, and the current working directory is the desired location for the link, then you only need:

ln -s
Tags : | add comments

Mounting a Remote Folder on Linux (Ubuntu) with SSH

Posted by root on Wednesday May 25, 2011 Under Bash, Remote Access, Ubuntu


SSH is a secure protocol for communicating between machines. SSHFS is a tool that uses SSH to enable mounting of a remote filesystem on a local machine; the network is (mostly) transparent to the user. Because SSHFS authenticates connections, you can be sure that only those who should have access to remote directories can mount them (as long as everything is configured properly).

Because SSH encrypts connections, no one can see your files as they are transferred over the network. And because SSHFS is built using FUSE, even your own root user can only see your files by logging in to your account with su.

Installation and Setup
Simply install the following package:

sudo apt-get install sshfs

then add yourself to the fuse group:

sudo gpasswd -a $USER fuse

Alternatively, GNOME users can go to System -> Administration -> Users and Groups -> (your user) -> Properties -> User Privileges, then tick the following option:

Allow use of fuse filesystems like LTSP Thin Client blockdevices
Adding yourself to the fuse group lets you use the fusermount command, which is needed by the FUSE userland filesystem utility.

Once you have added yourself to the fuse group, you should log out and log back in again for the change to take effect.

Command-line Usage
Now, assuming that you have an SSH server running on a remote machine, simply run the SSHFS command to mount the remote directory. In this example, the remote directory is /projects on remote host far. The local mount point is ~/far_projects.

mkdir ~/far_projects
sshfs -o idmap=user $USER@far:/projects ~/far_projects

To unmount,

fusermount -u ~/far_projects

To add it to your /etc/fstab,

sshfs#$USER@far:/projects /home/$USER/far_projects fuse defaults,idmap=user 0 0

Note that you have to change $USER to your login name when editing fstab, but it is not necessary when typing commands (the shell does it for you in that case).

One thing to be aware of is that your UID (User ID, the unique number of your user on a system) is not necessarily the same on the two hosts. When you ls -l, the user name associated with each file is printed in the third column. However, in the filesystem, only UIDs are stored, and ls simply looks up the UID and finds the user name associated with it. In Unix, UIDs are what matter, not the user names. So if you’re 1000 on the local host and 1003 on the remote host, the sshfs mounted directory would show a different user name for your files. This is not a problem, though, because the ssh server on the remote machine is what is actually reading and writing files. So even though it shows up in ls -l as a different UID, any changes will be done through the ssh server on the remote host, which will use the correct UID for the remote machine. Problems may arise if you attempt to use a program that looks at UIDs of files (e.g. ls prints the wrong user name).

The idmap=user option ensures that files owned by the remote user are owned by the local user. If you don’t use idmap=user, files in the mounted directory might appear to be owned by someone else, because your computer and the remote computer have different ideas about the numeric user ID associated with each user name. idmap=user will not translate UIDs for other users.

Using the GUI

Alternatively you can mount a directory over SSHFS using the Gnome “Connect to Server” tool in the desktop Places menu. In the tool, set the service type to SSH and fill in the boxes as needed. If a password is required when connecting then you will be prompted for it. Unmounting a SSHFS connection is the same as for any other volume. Open the File Browser (Nautilus). In the Places panel on the left click the arrow next to the SSHFS mount you want to disconnect or right-click it and select “Unmount”.

Keep Alive
Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to ~/.ssh/config or to /etc/ssh/ssh_config on the client.

ServerAliveInterval 5

This will send a “keep alive” signal to the server every 5 seconds. You can usually increase this interval, and I use 120.


Tags : , , , , , | add comments

Remove a directory on Linux BASH Console

Posted by root on Monday Feb 21, 2011 Under Bash, Centos, Linux, Ubuntu, Uncategorized

To remove a directory that is full with other files or directories, use the below command.

rm -r directory

In the above example, you would replace “directory” with the name of the full directory you wish to delete. So if the directory was named files, you would type:

rm -r files

In the above example the command would prompt you as directories and files were being deleted if you wanted to force the delete with no prompts add the ‘f’ option to the command as shown below.

rm -rf directory

Additional information

When attempting to remove a directory using a command such as the rmdir command, you may receive a prompt such as “rmdir: ‘dir’: Directory not empty” and be unable to delete the directory.

Tags : | add comments