How to install Python3 Beautiful Soup environment on Debian Linux

Beautiful Soup is a Python package for parsing HTML and XML documents and it resides within a Debian package named python-bs4. However, python-bs4 package is a default package on Debian Linux system for Python 2 version. Therefore, if your intention is to use Python3 as a default environment you will need to also install Python3 and its corresponding version of BS4 python3-bs4. Let’s start by python3 installation:

# apt-get install -y vim python3

After a successful installation of python3 package make sure that python3 is set as default:

# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode

Confirm that python 3 is a default version:

# python --version
Python 3.4.2

All what remains is to install Beautiful Soup parsing HTML and XML package to match python version 3:

# apt-get install python3-bs4

All done. Test Beautiful Soup parsing HTML and XML with the following example script:

#!/usr/bin/env python3

from urllib.request import urlopen
from bs4 import BeautifulSoup

html = urlopen("http://www.gnu.org")
bsObj = BeautifulSoup(html.read());

print (bsObj.title)

Read more

Install Debian Linux from USB boot memory stick

There are more and more Laptops nowadays which do not have a CD/DVD-ROM facility build in but are able to boot from USB memory stick. This small guide provides all needs on how to create a bootable USB memory stick to install a Debian without a need for CD/DVD drive.

Before you continue make sure that you have backed up all your data from your USB memory stick. After completing this guide your USB memory stick will contain a new partition table and all your data will be lost.

This guide also assumes that you have a running linux system and USB memory stick with minimal size of 512MB which you will use for the process of creating Debian boot installation USB stick.

Find USB device name

Plug in your USB stick and find its device file name by:

fdisk -l

For the rest of this guide we are going to use /dev/sdb as our target.

WARNING: DO NOT COPY AND PASTE COMMANDS FROM THIS PAGE UNLESS YOUR TARGET DEVICE IS ALSO /dev/sdb !!

Create FAT16 partition

Next we need to create FAT16 partition. For this we can use cfdisk with -z option. This command will completely remove all your data from your USB stick, so backup first !:

cfdisk -z /dev/sdb

and create a first primary partition with the minimal size of 260MB and leave the rest unpartitioned or create second partition with some other filesystem for normal use of your USB stick. The size of 260 MB will fit a current Debian stable boot.img.gz and and Debian netinst ISO image.

Read more

php virtual box web interface - localhost

phpVirtualBox installation on Debian Linux and Apache2 web server

phpVirtualBox allows you to manage locally or remotely your virtual machines running under VirtualBox via web-based interface. This config will describe an installation and basic configuration of phpVirtualBox on Debian Linux.

First, we need to install apache2 and php support:

# apt-get install libapache2-mod-php5 apache2 unzip wget

Next, we need to download phpVirtualBox. Please update your download link if necessary:

$ wget http://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-4.3-2.zip

Next, we will unzip and move the phpVirtualBoxcode into root directory of our apache2 webserver directory.

# unzip phpvirtualbox-4.3-2.zip
# mv phpvirtualbox-4.3-2/ /var/www/html/vbox

Read more

How to extract files from Debian package archive DEB

Very useful tool to extract files from Debian package archive DEB (*.deb) is ar command. First, let’s download a sample debian package hello_2.10-1_amd64.deb:

$ wget http://ftp.us.debian.org/debian/pool/main/h/hello/hello_2.10-1_amd64.deb

Now, that we have downloaded our sample Debian package we can use ar command to list its content. This can be achieved by t option:

$ ar t hello_2.10-1_amd64.deb 
debian-binary
control.tar.gz
data.tar.xz

Read more

Building Linux kernels the Debian way

This short article describes the quick and easy way on how to customize, build and install Linux kernel under Debian or Ubuntu Linux. First, we will install all prerequisites then download kernel source. Next step will be customization and as a last step we will create and install a Debian package with new Customized Linux kernel.

Prerequisites

Let’s start with first step which is installation of all prerequisites:

# apt-get install bzip2  build-essential \ 
kernel-package libncurses5-dev

Kernel build and customization

Next step is to download kernel source code from kernel.org. Untar and cd inside the kernel’s directory tree:

$ tar xvjf linux-2.6.34.tar.bz2
$ cd linux-2.6.34

At this point we will do the most important part of creating new customized kernel and building a Debian package. This is all done with a single make-kpkg command.

NOTE:

Optional step is to apply kernel patches before running a following linux command:

make-kpkg --rootcmd fakeroot --config menuconfig --initrd --us --uc kernel_image
  • –us do not sign source
  • –uc do not sign changelog
  • –initrd perform any actions necessary for a kernel loaded using initrd
  • — rootcmd fakeroot command that provides a means of gaining super user access
  • –config menuconfig will use menuconfig as a configuration tool where default is oldconfig

Read more

How to list all files installed by the DEB package on Ubuntu/Debian Linux

The typical question after we install a new package on our system is that what are the actual files ware installed and what is their location. This may be even less obvious if the final executable name intended to start your program has slightly different name than the package its self. In the following example we are going to install a dummy package hello using apt-get command:

# apt-get install hello
...
(Reading database ... 7528 files and directories currently installed.)
Preparing to unpack .../hello_2.9-2+deb8u1_amd64.deb ...
Unpacking hello (2.9-2+deb8u1) ...
Setting up hello (2.9-2+deb8u1) ...

Read more

Install debian server in a linux chroot environment

Running Linux system inside a chroot environment allows a system admin to decrease an impact on a production server when the server gets compromised. Change root will change root directory to all current running processes and its children to a chroot jail. Testing of various package installations and server configuration in a chrooted environment can be another handy way how to utilize a chroot jail.

This tutorial will provide a reader with step by step guide on how to install Debian with ssh daemon inside chroot environment using debootstrap.

Install chroot environment

In the first step we will create a directory in which new chroot environment will reside. For convenience during the installation we also declare temporary bash shell variable CHROOT to hold a path to chroot environment.

# mkdir -p /mnt/chroot/squeeze
# CHROOT=/mnt/chroot/squeeze

When new chroot directory is ready we will use debootstrap to install new Debian system within chroot environment. Change the architecture and debian version according to your needs. The installation may take some time as debootstrap will use your specified mirror to download and install core packages. Choose the closest mirror as it will rapidly reduce the installation time.

# debootstrap --arch i386 squeeze \
$CHROOT <URL OF DEBIAN MIRROR>

At the end of the installation you should seed output similar to the one below:

I: Configuring debian-archive-keyring...
I: Configuring apt...
I: Configuring libept0...
I: Configuring apt-utils...
I: Configuring aptitude...
I: Configuring tasksel-data...
I: Configuring tasksel...
I: Base system installed successfully.

Read more

ImportError: No module named ‘lsb_release’ – Debian Linux – Solution

Symptoms:

Using a apt tools may result in a following error:

Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 28, in 
    import lsb_release
ImportError: No module named 'lsb_release'
Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 28, in 
    import lsb_release
ImportError: No module named 'lsb_release'

Read more

Debian apt-get wheezy sources.list

Related sources.list repositories:
Wheezy,
Jessie,
Stretch,
Buster

Security Updates

# /etc/apt/sources.list :
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free

Australia Mirror

# /etc/apt/sources.list :
deb http://ftp.au.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.au.debian.org/debian/ wheezy main contrib non-free

Read more