Monthly Archives: February 2013

Host your own document storage service with ownCloud

Cloud storage services like Dropbox have changed the way people collaborate and share files, but to get the most out of them, you need to trust your data to a third-party provider. This might not be an issue for the average desktop user, but for an enterprise it may be a deal-breaker. If you don’t want to lose control of your data, yet enjoy all the benefits of an always-available and synchronized online repository, you can turn to ownCloud, an application that lets users share and sync files within the confines of your enterprise firewall on servers you control.

ownCloud provides multiple editions, all licensed under the AGPL. The Enterprise Edition has a dual license that allows customers to implement third-party proprietary plugins and extensions, and features mobile and desktop clients. While the freely available Community Edition has all the essential features, enterprise customers get additional ones such as the ability to use the Oracle database instead of MySQL, and a logging plugin that keeps detailed records of user actions on files. Users of the commercial editions of ownCloud can also define and direct users to different storage locations based on their roles and needs.

ownCloud can integrate with your existing network infrastructure. You can, for example, tie it in with your single sign-on infrastructure and directory server, which lets you avoiding setting up new user accounts. ownCloud has extensive user account management features that let you control whether your data is accessible to all users, a particular group of users, or just a specific user. Its granular permissions let users determine who can do what with their shared data.

The software has an impressive online file manager that can handle files in a variety of formats. It lets you view and edit files in both text and Open Document Format (such as ODT, ODP, and ODS) from within a browser. In addition, it can handle images and music files in the most popular file formats, and has a built-in gallery image viewer and a music player. It also gives you the option to encrypt your files. And ownCloud lets you mount external cloud storage drives, such as Google Drive, Amazon S3, Dropbox, and OpenStack Swift, and seamlessly manage data on these services along with that in your private cloud.

Another interesting feature is file versioning, which comes in handy especially when you are sharing files with multiple users. With this feature, the ownCloud server tracks all changes to every file and lets you revert to an older version with a single click.

Along with files, ownCloud also lets you keep your calendar and address book in sync with ones on your desktop and mobile platforms. You can also share them with other ownCloud users.

In essence, ownCloud is a PHP application that runs atop the Apache web server. To manage data, it can either use SQLite(the default) or MySQL. The app also uses open protocols; for example, you can access files using the WebDAV protocol, sync calendars with CalDAV, and sync address books with CardDAV. Its web interface is built using HTML5.

Like other online cloud storage services, you can sync files on ownCloud either using the web browser or a desktop client on Windows, Mac, and Linux. Clients for Android and iOS devices let you access files on the ownCloud server from your mobile phone.

Install ownCloud

Installing ownCloud doesn’t take much effort. Its developers provide binaries for most popular operating systems, including CentOS.

If you are installing ownCloud on a fresh CentOS installation, make sure the server has a static IP address. For this tutorial we will use a server called with the IP address

Start by installing the EPEL repositories:

# rpm -ivh

Next, install the ownCloud repositories:

# cd /etc/yum.repos.d/
# wget

You can then install the ownCloud server and its dependencies with yum install owncloud.

Next, create a configuration file for ownCloud and set up a virtual host to handle requests:

# vi /etc/httpd/conf/owncloud.conf

Alias /owncloud /var/www/owncloud/
<Directory /var/www/owncloud/>
	Options None
	Order allow,deny
	Allow from all

<VirtualHost *:80>
	DocumentRoot /var/www/html/owncloud
	ErrorLog logs/owncloud.error_log
	CustomLog logs/owncloud.access_log common

Now edit Apache’s configuration file (/etc/httpd/conf/httpd.conf) and point to the ownCloud configuration file by adding the following line to the end:
Include /etc/httpd/conf/owncloud.conf.

Before you bring up the ownCloud server, you must also edit PHP’s configuration file (/etc/php.ini), because by default PHP allow users to upload only files that are less than 2MB in size. Open the file and look for the upload_max_filesizevariable and change it from 2M to something like 500M or 1G. Also increase the size of the post_max_size variable slightly.

Finally, you need to open ports in your firewall to allow other computers on the network to access ownCloud:

# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 
# service iptables save
# service iptables restart

Now start (or restart) the Apache web server with service httpd restart to bring the ownCloud server online. You can then fire up a web browser and navigate to the ownCloud instance at Since this is a new installation, you’ll be asked to create a user account for the ownCloud administrator.

By default, ownCloud keeps its data under /var/www/html/owncloud/data and uses the SQLite database. If you want to use MySQL, or want to change the data folder, click on the Advanced pull-down menu. If you choose MySQL you must specify the username and password of the MySQL admin and provide a name for the database that will house ownCloud’s data.

You’re now logged into your ownCloud server as the administrator. In the main interface, click on the gears icon in the bottom left corner to bring up the Settings menu, then click on the Admin option, which houses several configurable parameters. Here you can alter the maximum upload size for a single file and disable version control for files.

Before you can start using the ownCloud server, you need to add users and organize them into groups. You can either do this manually, or if you have a directory server already set up, you can connect to it by activating the LDAP back end.

Once you have added users, they can upload data to the ownCloud installation by pointing their web browsers to the ownCloud server and logging in with their credentials.



The ownCloud interface is pretty usable and easy to follow. When you log in you are at the Files tab. To upload a file, click on the green arrow, or just drag and drop files from your desktop. If you’ve uploaded a file in a format that ownCloud understands, you can click on its name to view and edit the file.

Optionally, since ownCloud uses the WebDAV protocol, you can also access it from your file manager. For example, in Nautilus you can enter in the location area a URL such as dav:// Once you’ve authenticated, the ownCloud storage will be mounted and available just like a regular folder.

Share and collaborate

To share uploaded files, go to the Files tab in the web interface and hover over the file or folder you wish to share. This displays several options, including Share, which lets you select which users or groups you want to share the item with and whether you want to give them permission to modify the files.

You can also share an item with someone who isn’t on your ownCloud server. When you click on the “Share with link” checkbox, ownCloud displays a link to the item that you can share with anybody who can reach your ownCloud server. Optionally you can also password-protect the link and set an expiration date.

To sync contacts, your first need to import them. ownCloud supports the popular vCard file format (with the .vcf file extension). Almost every popular email app, including online ones such as Gmail, can export their address books in this format.

With a .vcf file in hand, head to the Contacts tab in the ownCloud interface and click on the Import icon. Once you’ve imported your contacts you can sync the address book with that of other clients that can read CardDAV links. In the Contacts tab, click on the gears icon at the bottom, then on the More link to display all the address books. Hover over the name of the address book you just imported and click on the first icon to spit out a CardDAV link for this address book that you can feed to your desktop or mobile address book client.

Similarly, ownCloud can manage your calendar and tasks. To create an event in your calendar, head to the Calendar tab. To add an event, click anywhere on the calendar. This brings up a window that gives you several options to configure the event.

After you save an event you can use ownCloud to share it with other users. Click on the calendar icon in the top right corner. Hover over the calendar you wish to share and click on the Share Calendar icon. This brings up a pull-down menu that lets you select the users or groups you wish to share the calendar with.

ownCloud can sync your calendars with desktop and mobile apps that can read this information from CalDAV links. To get the CalDAV link for your calendar, click on the Calendars button, then click on the second icon to display a link that you can pass on to clients to keep them in sync with the ownCloud calendar.

Sync clients

To synchronize folders from any desktop to your ownCloud server, you have to install a client. To install a sync client on a CentOS 6.3 desktop, run the following commands:

# cd /etc/yum.repos.d/
# wget
# yum install owncloud-client

Once the client is installed, configure it by pointing to the server. It will connect and by default create a local sync folder such as /home/bodhi/ownCloud, as well as a remote folder named “clientsync” on the server.

Users can specify one or more directories on a local machine to sync with the ownCloud server. If a directory is shared with several users, then when anyone makes a change to a file on one computer, it automatically flows across to the others.

When collaborating with others, ownCloud’s simple version control system creates backups of files which are accessible via the History pull-down option, which also links to an “All versions…” page where you can roll back a file to a previous version.

If your users collaborate on projects by sharing files, you can enhance their workflow and improve your security by deploying ownCloud. It gives users anytime, anywhere access to their data, and lets enterprise keep control of its own data.

Set up a local Linux installation and update server with Kickstart

Setting up Linux on multiple machines can take a lot of time and effort, but it doesn’t have to. With Kickstart, you can customize automatic installation of any Fedora-based distribution, including CentOS, on new servers. Kickstart can install not only the operating system but also all the applications you expect to run. And to make everything run as quickly as possible, you can store Kickstart files and Linux packages on a local Apache web server, which then servers as your network installation and update server, saving you bandwidth every time you roll out a new machine.

The server you use as an installation server doesn’t need to have a lot of processing power, but it should have ample free space (at least 20GB) to house the CentOS installation DVDs and package updates.

To build your installation server, start by installing a barebones CentOS system. Once the hardware and operating system are set up, make sure the server has a fixed IP address, say Then install the Apache web server with the command yum install httpd.i686, or yum install httpd.x86_64 on a 64-bit installation.

Next, copy over the installation files from the CentOS DVDs to this server:

# mkdir /install
# rsync -arv /media/CentOS_6.3_Final  /install

Ideally you should set up the /install partition on a separate disk or a logical volume for more flexibilty. If you can do that, make sure you also edit the contents of /etc/fstab file to mount the partition or volume when the server boots.

If you create the install directory outside Apache’s document root directory (/var/www/html/), you must create a configuration file to point the web server to the correct directory. All Apache custom configuration files are housed under the /etc/httpd/conf.d/ directory. Switch to that directory and create a file called install.conf with the following contents:

Alias /install/ /install/
<directory /install>
	Options Indexes 
	AllowOverride None
	Order allow,deny
	Allow from all

This tells Apache where to redirect any traffic that requests the /install directory. Any time you make changes to Apache’s configuration you should check them for errors with the command apachectl configtest.

You can start the web server by running service httpd start. To ensure it starts when you reboot the server, add it to runlevels 3 and 5 with the command chkconfig --level 35 httpd on.

Configuring security

Although the web server is up and running, you cannot yet access it from any other machine on the network, because by default CentOS uses SELinux Enforcing mode and allows only incoming SSH traffic through the firewall.

One easy way around the problem is to tune down SELinux to use ‘Permissive’ mode (with the command setenforce permissive), or turn SELinux off altogether along with the firewall. Don’t take the easy way out; even though you may be serving only trusted machines within the protected local network, you still shouldn’t turn off important security mechanisms.

Instead, reconfigure the firewall to allow HTTP traffic over Apache’s port 80:

# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# service iptables save
# service iptables restart

To avoid running into issues with SELinux, change the SELinux context on the custom install directory to the SELinux context on the web server’s document root directory:

# ls -Zd /var/www/html/
drwxr-xr-x.  root   root  system_u:object_r:httpd_sys_content_t:s0   /var/www/html/

The httpd_sys_content_t part in the output is the SELinux context of the directory. Now apply it to the install directory:

# chcon -R –type=httpd_sys_content_t /install

You should then be able to access the web server and the install directory from any machine on the local network. To test this, boot a machine with the CentOS minimal boot CD. When prompted, select the “URL” option to install from the local network server, and enter the install server’s URL.

Unattended installation

Now the installation server is set up, but you still need to be physically present on a client machine to complete the installation. To automate the installation process you need to use Fedora’s Kickstart installation method. This utility relies on so-called kickstart files that contain all the answers to all the questions asked during the installation process, such as the partitioning scheme, the packages to install, and so on.

You can use different kickstart files to install different types of systems, such as a web server, a mailserver, or a client desktop. When you install a CentOS machine using the normal manual process, Fedora’s Anaconda installer saves a kickstart file for that particular installation under /root/anaconda-ks.cfg. You can use this file to install another system with an identical hardware and software configuration.

You can also use a kickstart file to customize and create your own kickstart files. The most convenient way to do that is to use the graphical Kickstart Configurator tool that you can download and install with the command yum install system-config-kickstart.

Besides the package selection, you need to pay attention to two important things in the kickstart files to work with an installation server: the installation method and the network setup.

The server we created, and which we are adapting this kickstart file from, uses a static IP address. If we used it unedited, we’d have multiple machines on the network with the same IP address, which is a good way to give yourself a headache. Instead, we’ll assign IP addresses to new machines using a DHCP server on the network. Find the line that starts with the keyword “network” and change it to read:

network --device eth0 --bootproto dhcp

Also, unlike the initial setup, the clients we’ll be setting up should fetch packages from the network server instead of the CentOS Installation DVD. To change the installation medium, look for the line that reads “cdrom” and replace it with the location of the installation server:

url --url

Place your kickstart files under the web server’s document root directory, in a directory such as /var/www/html/kickstarts. YOu might have, for instance, a kickstart file called gnomedesktop.cfg that installs a GNOME-based desktop and another called kdedesktop.cfg that install a KDE-based desktop.

To install a client using the kickstart files, boot from the minimal boot CD, and at the boot screen point to the kickstart file you want to use. For example, to install a GNOME desktop, type:

linux ks=

Presto! The system will now run through all the installation steps automatically.

Set up an update server

It’s easy to take the installation server further and also use it as a local update repository. This saves bandwidth, as all clients can be set up to fetch updates from the local repository instead of the Internet.

On the installation server, create a directory structure for the update repo. To keep things simple, use the same directory structure as on the CentOS mirrors:

# mkdir -p /localrepo/centos/6.3

CentOS repos are set up such that they look only at the major release number. To make that work smoothly, create a symbolic link to the current 6.3 repo:

# ln -s /localrepo/centos/6.3/ /localrepo/centos/6

Then, once there’s a new point release, such as CentOS 6.4, all you need to do is create a new link to point to the local repository of the new release.

Now head to the list of mirrors on the CentOS website and look for one that’s close to you. Here I use the one provided by Georgia Tech and mirror it using rsync:

# rsync --progress -avH --delete --exclude 'isos' rsync:// /localrepo/centos/6.3/

This creates an exact copy of the mirror on the local disk, but skips over the directories specified with the --excludeparameter – in this case the isos directory – since we don’t really need them. If all your machines are of a particular architecture – say 64-bit – you can exclude mirroring packages for the 32-bit architecture by appending --exclude 'i386'.

You want your local repository to stay current with security patches and updates, so you should set up an automatic update via a cron job. CentOS keeps cron jobs under /var/spool/cron; there you can create a job for the root user that checks for updates at 5:30 a.m. every Sunday:

# vi /var/spool/cron/root 30 5 * * 7 /usr/bin/rsync rsync --progress -avH --delete --exclude 'isos' rsync:// /localrepo/centos/6.3/

Changing the update repos

Once you’ve created a local repo, you need to make the Apache web server aware of it, just as we did with the /install directory. Edit the repo configuration file:

# vi /etc/httpd/conf.d/repo.conf

Alias /repo/ /localrepo/
<directory /localrepo>
	Options Indexes FollowSymLinks
	AllowOverride None
	Order allow,deny
	Allow from all

This equips Apache to redirect requests looking for the /repo directory to the /localrepo directory on the web server. The FollowSymLinks directive tells Apache to traverse the directory as directed by the filesystem. Save the file and restart the web server.

Now you must configure the clients so that they fetch packages from the local update server. CentOS keeps all the repositories under the yum.repos.d folder. Head to the folder and open a repository such as CentOS-Base.repo in a text editor. In this file, comment out all the entries that begin with mirrorlist=, then enable the lines that begin with baseurl=, and make sure the URL points to the local update repository:


When you’re done making all the changes, save the file and clear the existing Yum cache:

# yum clean all

Automate post-install updates

If you have only a couple of machines, you could go to each machine and manually change each one’s repository to update from the local mirror. But a more efficient approach is to create a custom script that replaces the existing repos with your custom repos. You can also use such a script in the kickstart files themselves so that the repos are automatically replaced straight after installation.

First, create a basic custom repo file:

# vi local.repo

[LOCAL Repo] 
name=LOCAL Repo

Place it in a directory under the web server’s document root directory – for instance, /var/www/html/post-install/. Also create a script to replace the existing repositories with this new one and place in under the same directory.

# vi

cd /etc/yum.repos.d
rm *.repo  
yum clean all
yum -y update

Now open a kickstarter file and scroll down to the %post section, which defines actions that will be performed after a system has been installed, and add the following:

cd /tmp 
chmod +x 

If you have multiple kickstart files, make sure you change all of them to run the custom script that replaces the default repositories with the custom one.

We’ve covered a lot of ground in this tutorial. It might seem a bit overwhelming to set this all up – but you don’t have to do it all at once. If you have a small network you can just set up an install server. Admins on larger networks that run lots of critical servers and applications and need the latest security updates can also set up an update server.

Once you have everything set up, rolling out new machines becomes just a matter of pointing to the correct kickstart file. You can set up new machines, reset old ones for new employees, or change a web server into a mail server with a single command. And using kickstarter with an installation and update server not only saves you time and effort, it also cut down on your company’s Internet bandwidth costs.

How to make Ubuntu Linux look like Windows 7

Are you ready to make the jump to Linux, but scared of learning a whole new interface?

PC World – Windows 8’s tile-based interface puts a bold new spin on the familiar Windows interface–so bold that many long-time Windows users are threatening to jump ship to another operating system rather than learn Microsoft’s “modern” UI. Of course, you’ll still find yourself in foreign territory even if you actually follow through and make the jump. Installing a new operating system is easy, but wrapping your head around an alien environment can be more difficult, even if you’re using a comparatively user-friendly OS like Ubuntu Linux.

Luckily, Linux is customizable–much, much more than Windows. In fact, if you’re having trouble with the transition (or plopping Ubuntu on a parent’s PC), you can tweak and tune the OS to feel pretty darned close to the Windows environment you’ve forsaken.

I’ll go through two methods here. One adapts Ubuntu’s default Unity desktop to make it feel slightly more like Windows, while the other entails a bit more work and a different desktop interface entirely to create a truly Microsoft-like experience.

Creating a Windows 7-style Ubuntu

To be completely honest, Ubuntu’s default Unity desktop may be slick and pretty, but it isn’t the most configurable Linux environment around. The taskbars running the top and left sides of its screen are locked in place and can’t be moved whatsoever. Unity is still fairly flexible, however, and some basic–for Linux–tweaks can give it some of that old Windows 7 charm.

A quick note: These tips were tested on Ubuntu 12.10, the most current version of the operating system at the time of publication.

We’re going to use some terminal commands throughout the course of this article. If you’re a new Linux user, don’t be scared–Linux’s powerful command line makes it easy to follow instructions you’ll find in articles like this one. Instead of following a list of long steps telling you to click here and click there, you can just copy and paste these commands into a terminal window and hit Enter.

To open a terminal, press the Windows key (known as the Super key in Linux), type Terminal, and press Enter. You can also click the Ubuntu logo at the top-left corner of your screen instead of pressing the Windows key.

First, we’re going to install a Windows 7 theme pack. Copy and paste the following commands into the terminal window in order, pressing Enter after each command to run it. The first command adds a personal package archive (PPA) to your system that Ubuntu can install packages from. The second command downloads information about the newly available packages, and the third command installs the Windows 7 theme–no installation wizard required. Typing sudoA before each command allows it to run with root permissions, similar to running a program as administrator in Windows.

sudo add-apt-repository ppa:upubuntu-com/gtk3

sudo apt-get update

sudo apt-get install win2-7

The Win2-7 theme is now installed. To enable the icon, window border, and widget theme, copy and paste the following commands into the terminal. As you run each command, you’ll see your desktop gradually transform and become more Windows-like.

gsettings set org.gnome.desktop.interface gtk-theme ‘Win2-7-theme’

gsettings set org.gnome.desktop.wm.preferences theme ‘Win2-7-theme’

gsettings set org.gnome.desktop.interface icon-theme ‘Win2-7-icons’

The taskbar-like launcher at the left side of your screen will still be a different color. Never fear–like Windows 7’s taskbar, the launcher derives its colors from your desktop wallpaper. For this article, we’ll use Windows 7’s default wallpaper, which you can find all over the Internet.

If you’re using Firefox on Ubuntu, right-click the full-size wallpaper image in your browser and select Set as Desktop Background.

You’ll also want to move the window management buttons–close, minimize, and maximize– located at the top-left corner of each window by default. Use this command to put them in a Windows-style order:

gsettings set org.gnome.desktop.wm.preferences button-layout ‘menu:minimize,maximize,close’

To remove the Mac-style global menu bar and put the menu bar (containing File/Edit/View) back into each individual application window, run this command:

sudo apt-get autoremove appmenu-gtk appmenu-gtk3 appmenu-qt indicator-appmenu

You’ll have to log out and log back in for this change to take effect. Use the button at the top-right corner of your screen to log out.

Do you like what you see? This is as close to Windows 7 as we’re going to get with Ubuntu’s default Unity desktop environment. If it doesn’t quite scratch your itch, keep reading to learn how to create a more traditional Windows 7-style look using the Xfce desktop environment.

Installing and customizing Xfce

For this method, we’ll be throwing Ubuntu’s default Unity desktop out and going our own way. (Okay, we’re not actually throwing it out, just selecting a different environment on the login screen). Xfce is one of the most popular desktops that still offers a lot of configurability. Install it with this command:

sudo apt-get install xubuntu-desktop

Log out of Ubuntu using the menu at the top-right corner of the screen and click the icon next to your name on the login screen. Select Xubuntu session and log in normally. (You can install multiple desktop environments and toggle between them on the login screen like this.)

Xfce also uses a two-panel layout by default. We’ll have to do some heavy customization to get it looking more like Windows 7, but it’s all graphical–if you’re a Windows power user, you’ve done this kind of tweaking many times before.

First, get rid of the top panel. Right-click it, point to Panel, select Panel Preferences, and click the red Remove button. Use the drop-down box in the panel configuration window to select the other panel. Uncheck the ‘Automatically show and hide the panel’A option and check the ‘Automatically increase the length’ option. Now we’re getting somewhere! At this point, you should have a single taskbar-like panel across that bottom of your screen.

Use the buttons on the Items panel to remove the items you don’t want, add the items you do want, and reorder them as you see fit. For a Windows 7-style taskbar, try using these items in the following order:

Applications Menu, Separator, Launcher, Window Buttons, Separator, Notification Area, Indicator Plugin, Show Desktop.

Add as many launchers (read: shortcuts) as you like to the launcher section and think of them as your new quick launch bar. Unfortunately, Xfce can’t group applications and open windows the same way Windows 7’s taskbar can, so it’s a bit more old school.

To configure an item, select it in the list and click the Gear button. You’ll also want to disable the ‘Show button title’ option in the Applications Menu item’s settings.

Theming Xfce to look like Windows

Now we just have to make Xfce look more like Windows 7. If you didn’t run any of the commands in the Unity section above, run the commands below in a terminal. (Right-click the desktop and select ‘Open terminal here’ to open a terminal in Xfce.)

sudo add-apt-repository ppa:upubuntu-com/gtk3

sudo apt-get update

sudo apt-get install win2-7

gsettings set org.gnome.desktop.wm.preferences theme ‘Win2-7-theme’

gsettings set org.gnome.desktop.wm.preferences button-layout ‘menu:minimize,maximize,close’

Open the Settings Manager from the applications menu and click the Appearance icon. Select Win2-7-theme in the Style list and select Win2-7 in the Icons list.

Press Alt+F2 and run the following command to get Windows 7-style window borders. If you’re typing this out rather than copying and pasting, note that the command includes a double-dash, not a long em dash.

metacity –replace

Go into the Session and Startup panel in the Settings Manager, select the Application Autostarttab, and click the Add button. Enter MetacityA as the application’s name and metacity –replace as its command. Now Windows 7-style window borders will automatically start with your desktop.

To make your panel look more like Windows 7’s panel, right-click it, point to Panel, and select Panel Preferences. On the Appearance tab, select Background image and browse to the \usr\share\themes\Win2-7-theme\gtk-2.0\Panel\ directory on your computer. Select a background image like Panel_Win2-7Basic800.png. The theme pack we installed includes a variety of panel backgrounds, so feel free to experiment.

You can also change the applications menu’s graphic and make it use a Windows 7-style start orb. First, find a Windows 7 start orb image–you can find several on Google Images, but make sure you get a transparent PNG image. Once you’ve found a good image, right-click the Applications menu button, select Properties, and use the Icon button to select your start orb.

Phew, that took a lot of tweaking (and a lot of text)–but we now have a Windows 7-style desktop on Ubuntu. It lacks a Windows 7-style Start menu and taskbar, but Windows users that prefer the classic Start menu and taskbar behavior will find it immediately familiar.

Undoing your changes

Want to undo your changes? If you followed the first method, just run these commands. Remember to log out and log back in after running the commands to restore the global menu bar.

gsettings reset org.gnome.desktop.interface gtk-theme

gsettings reset org.gnome.desktop.wm.preferences theme

gsettings reset org.gnome.desktop.interface icon-theme

gsettings reset org.gnome.desktop.wm.preferences button-layout

gsettings reset org.gnome.desktop.background picture-uri

sudo apt-get install appmenu-gtk appmenu-gtk3 appmenu-qt indicator-appmenu

If you followed the second method, log out and select Ubuntu’s default desktop environment from the login screen. You can toggle between the two whenever you like. If you’d like to uninstall Xfce, use this command:

sudo apt-get autoremove xubuntu-desktop

These processes are a good demonstration of just how configurable Linux is. You can rip out software from the default desktop, use all sorts of themes, install a completely different desktop environment, or even build your own desktop environment by cobbling together pieces from different desktop environments–that’s what we did in the last section.


Build a media converter with Python, Qt and FFmpeg

Python is arguably the best programming language to build applications for Linux. This tutorial teaches Python by building a handy media converter application

In this tutorial we will build our very own application called LUD Media Converter. Along the way we will learn about the technologies that we have used in building the application. Generally speaking we will be covering Python and Python Qt bindings called PyQt and FFmpeg. At the end of the tutorial there are some tasks for you as well. As a reader, this will be an opportunity to practise what you have learnt and explore on your own. Don’t worry, we will have hints for you which will help you in completing the tasks.

Python is now the most popular language choice for building GUI (and command-line) applications on Linux. It is an official language of Ubuntu Software Centre. Many distributions use Python to provide built-in tools and applications (for example in Fedora/Ubuntu, all system configuration tools, including the installer, are written using Python). The reasons for using Python is simple: it is easy to learn. You do not have to compile it before running, yet it can be compiled when you want it. You can build GUI applications with Python which will look no different than other C/C++ applications.

As mentioned earlier, we will be building a media transcoder application called LUD Media Converter, which can be used to convert various media files to Android and iOS compatible formats.

As with any software application, we should always begin with a design. This gives a rough idea of what we are trying to achieve and then it acts as a guide as we move forward through the development process. A design could be a rough sketch of how the application will work, but since we have already completed the application we can show you the completed application itself.

Now we understand how our Media Converter will work and what it’ll look like. There are still few details that we need to look at, which we will cover as we go through the steps of building the application.

Mandatory Resources

PyQt4: PyQt4 provides Python bindings for the Qt4 library. This tutorial was written using version 4.9.3

Qt4 Designer: Qt Designer is a tool for designing and building graphical user interfaces (GUIs) from Qt components.

FFmpeg Static Build: We are using FFmpeg as the back-end of the application. FFmpeg static version N-47648-g4c554c9 is already provided in the ffmpeg folder in the tutorial folder of the disc. You will need to extract and copy it into the project folder.

Optional Resources

PySide: This tutorial can also be used with an alternative Python binding called PySide (LGPL licensed).

Python IDE: While you can use a standard text editor for all your Python programming, it is not fun. Having an IDE will help you quickly find syntax errors (tab spacing issues, anyone?) and code completion. We recommend using the Monkey Studio or Wingware Python IDE. These are the only IDEs for Python that support PyQt out of the box – Wingware Python IDE is the best when it comes to PyQt support, however it is commercial.

Step by Step

Step 01

Laying out the user interface

Laying out the user interface can be tricky. Qt Designer makes this process very easy. It allows you to graphically design user interface for Qt applications. Qt Designer stores all the information in the form of an XML file called UI file (.ui). You can either load the UI file directly at runtime or convert it to the Python code to make it part of your application. Our application uses the later approach. Open Qt Designer, click File>New… Then from the New Form dialog select ‘Main Window’. This will create a Main Window for our application. Now you will need to Drag the following from the Widget Box onto the Main Window (see image below).



Step 1

Note that we are not listing all the widgets which are there on the form, but only the ones which will be programmatically interacting. Fields which are not provided may also be added. Size and Text of the widget is given where deemed necessary; you can use your own judgment while designing the UI.
Once you are done creating the UI file, save it as mainwindow.ui. You will need to create the equivalent Python file. To do so, use the following command:

$ pyuic4 mainwindow.ui -o

Step 02

Creating main module (

The file acts as the primary file for your application. In a typical Python application, is the file which gets loaded first during the execution. In our case, our whole application is written in for
the sake of simplicity.

Note 1: Make sure you place all the source files inside the same project directory otherwise Python may not be able to import them.

Note 2: Python is tab sensitive; publishing restrictions may not always reflect the proper tab spacing for the code.

For accuracy, a Python IDE is highly recommended as most of the syntax errors related to tab spacing would be automatically handled by the IDE itself. Also, remember that to accommodate longer lines in print, single lines of code may appear on multiple lines. Unless the code line is split with ‘+ \’, you do not need a carriage return while typing the lines of the code.
Create file in your project directory with the following code:

#!/usr/bin/env python3
from PyQt4 import QtCore, QtGui
from os.path import expanduser
import os
import shlex
__author__ = ‘Kunal Deo’
#import Converted Python UI File
from mainwindow import Ui_MainWindow
class Main(QtGui.QMainWindow):
    def __init__(self):
        self.ui = Ui_MainWindow()
def main():
    app = QtGui.QApplication(sys.argv)
    window = Main()
if __name__ == “__main__”:

This is mostly boilerplate code necessary to import the necessary PyQt libraries and set up the UI. The first line indicates that we are interested in using Python 3 for this script. In the next line we are importing the QtCore and QtGui modules from PyQt4. QtCore provides essential non-GUI classes which are the building blocks of any Qt application. QtGui provides all the UI-related classes.

In the next line we are importing the Ui_MainWindow class from – the Python-converted UI file that we created earlier in step 1.

Following that, we’re initialising the Main class.

Step 03

Programming the buttons

Buttons and most of the event-driven code are done using a mechanism called ‘signals and slots’. The signal and slots provide a way of communicating between the objects. A signal is emitted when a particular event is triggered. For example, clicking the ‘Select Media File Button’ should call a function (slot) that will open the file browser. Most of Qt’s widgets have predefined signals, but you can subclass them to add custom signals as well. A slot is a function that is called when a particular signal is emitted.

You should keep in mind that signals and slots are pretty flexible; for example, a signal may be connected to many slots, a signal may also be connected to another signal, or a slot may be connected to many signals.

We can connect a Qt object as signal QtSig() to a slot pyFunction using the following syntax:

QtCore.QObject.connect(a, QtCore. SIGNAL(‘QtSig()’), pyFunction)

There is also a new style of connecting signals and slots which was introduced in PyQt 4.5. The syntax for the new style connection is:

connect(slot[, type=PyQt4.QtCore.Qt.AutoConnection])

We are using the old-style signal-slots mechanism because it is well documented and can be looked up in Qt’s C++ documentation as well. Besides that, pyuic4 generates old-style signal and slots.

The following code defines the connection of selectFileButton and convertButton.


The above code button’s clicked() signal goes to the following Python functions.

    def selectFile(self):
        fileName =
getOpenFileName(self,’Open Media
File’,expanduser(“~”),’Media Files
(*.mov *.avi *.mkv *.mpg)’)
    def convert(self):

The selectFile function opens a QFileDailog in the home directory. It also filters the file list for .mov, .avi, .mkv and .mpg.

Step 04

Programming the radio buttons

We are using radio buttons to give users an option to select the desired output format. As with normal buttons, for radio buttons we can use the signal “toggled(bool)” to capture the signals emitted by the radio button.

       QtCore.QObject.connect(self.ui.appleFullHDRadioButton,QtCore.SIGNAL(“toggled(bool)”),self. appleFullHDSelected)

Based on the selected checkbox, we will set the text of outputFormat:

    def androidHDSelected(self):
        self.ui.outputFormat.setText(“Android HD”)
    def androidqHDSelected(self):
        self.ui.outputFormat.setText(“Android qHD”)
    def appleHDSelected(self):
        self.ui.outputFormat.setText(“Apple HD”)
    def appleFullHDSelected(self):
        self.ui.outputFormat.setText(“Apple Full HD”)

Step 05

Displaying images

Our application shows WebM and H.264 logos in the application window. To hold these images, we have created two labels on the form called imageLabel1 and imageLabel2. We will use QPixmap. QPixmap is an off-screen image representation that can be used as the paint device.

The following code snippet builds a QPixmap from a PNG file, then we set it to the labels that we have.

@code snippet: Loading images using QPixmap
        pixmap = QtGui.QPixmap(“images/webmlogo.png”)
        pixmap = QtGui.QPixmap(“images/h264logo.jpg”)
@note: If you want to load images
from Qt resources file you need to
use the following:

Step 06

convertFile function

We have now come to heart of our application. We are using FFmpeg as the back- end for the application. It does all the heavy lifting for media conversion.

FFmpeg is a cross-platform open source utility for recording, converting and streaming audio and video. We are interested in its conversion capability. Following is an example of converting a file into another type:

ffmpeg -i “
” -codec:v libvpx -quality good -cpu-used 0 -b:v 2000k -qmin 10 -qmax 42 -maxrate 2000k -y -bufsize 2000k -vf scale=-1:720 -threads 2 ‘ + \
‘-codec:a libvorbis -b:a 128k “.webm"
We need to construct and run the same command and capture its output. Our application supports four options (see image below), laid out in the form of radio buttons.


Before we call FFmpeg we also need to manage the execution of it. Since FFmpeg is a separate process, we need to find a way to execute it from our Python application. Python already provides a module for doing this: it is called subprocess. While it is good for running external programs, it does not provide an optimum way to read the output of the program it is running. Instead we will use a Qt module called QProcess. QProcess is a class used to start external programs and to communicate with them.

QProcess supports the signal and slots mechanism. We are interested in two signals: readyReadStandardError() and finished(). ‘readyReadStandardError()’ is emitted when the process has made new data available via its standard error channel (stderr) – in this case, the command-line output of FFmpeg.

‘finished(int exitCode, QProcess::ExitStatus exitStatus)signal’ is emitted when the process inishes. exitCode is the exit code of the process, and exitStatus is the exit status.

This enables us to deliver a more fluid user experience to our users. They can be notified when FFmpeg has completed the conversion, and also see the progress of FFmpeg as it is converting the media file.

self.process = QtCore.QProcess(self) QtCore.QObject.connect(self.process,QtCore.SIGNAL(“finished(int)”),self.processCompleted)

The above code should be entered at __init__ of the Main class, just where all other signal and slots are set up.

Let’s take a look at our convertfile() function. This function is called when the user clicks the Convert button.

def convertFile(self):

     inputFile = str(self.ui.fileName.text())
     outputFormat = str(self.ui.outputFormat.text())

     if outputFormat == (‘Android HD’):
           cmd = ‘-i “%s” -codec:v libvpx -quality good -cpu-used 0 -b:v 2000k -qmin 10 -qmax 42 -maxrate 2000k -y -bufsize 2000k -vf scale=-1:720 -threads 2 ‘ + \
                 ‘-codec:a libvorbis -b:a 128k “%s.webm”’
           elif outputFormat == (‘Android qHD’):
           . . .. . .. . . . .
           . . . . . . . . .. .

           elif outputFormat == (‘Output Format’):
                 QtGui.QMessageBox.warning(self,”Input Format Not Selected”,”Please select an appropriate Output Format”)
                 return (‘Selection Not Proper’)
           if inputFile == (‘File Name’):
                 QtGui.QMessageBox.warning(self,”Media Not Selected”,”Please select a file to convert”)
                 return (‘Selection Not Proper’)
           argument = shlex.split(cmd % (inputFile,inputFile[:-4]))
           command = os.path.join(os.getcwd(),”ffmpeg”)

           self.ui.statusText.setText(“Please Wait....”)

We are reading the input file and output format from the labels. If these labels are not set, it alerts the user about the respective fields using QMessageBox. If it has all the data required, it checks the output format selected and the filename and builds a command string. This command string is then split into shell-like syntax – eg (‘param1’,’param2’,’param2’) – and is stored in the argument variable. Note that we are formatting the string with the value of inputFile. ,inputFile[:-4] indicates that we are removing the last four characters (ie the extension .xyz) so that it can be replaced with
the one that is provided in the cmd string.

For storing the command, we are using os.path.join(os.getcwd(),”ffmpeg”). Instead of using the absolute path, this gives us immense flexibility when we are running this program on other platforms as well. os.path.join(os. getcwd(),”ffmpeg”) always returns the path of the ffmpeg in the current directory formatted according to the platform it is running on.

On Linux it returns: /home/kunal/Desktop/lud/ffmpeg

On Windows 8 it returns: C:\Users\Kunal\Desktop\lud\ffmpeg

Towards the end we are setting the status text to “Please Wait…”. Then we have disabled the convertButton so that it cannot be pressed while the FFmpeg processing is going on.

As set by the finished() signal, upon the completion of execution of FFmpeg the following function gets called:

    def processCompleted(self):
setText(“Conversion Complete”)
append(‘Conversion Complete’)

This sets the status text as conversion complete and re-enables the Convert button.

To provide the real-time status of FFmpeg we have added a TextBrowser widget to our UI, which we can set now to provide the output of the ffmpeg command.

def readStdError(self):

After completing the application, you can run it by using the following command:

$ python3

The output file will be written to the same directory where the original is located.

Step 07


You’ve seen how easy and fun it is to build a complete application using Python and Qt. If you have taken the time to finish this tutorial, we would highly recommend you to complete some tasks as well (see boxout above), as they will enable you to learn even more as you explore on your own. We will continue to bring you more features and tutorials that’ll help you build on everything that you have learnt here.

LUD Media Converter is also an open source application hosted on GitHub. You are welcome to contribute on the project page.


Gadgeturi gratuite pentru Linux

In articolul de astazi o sa va prezint un soft pentru Linux, numit Screenlets care ne permite sa instalam diverse gadgeturi. Interfata acestui soft este una foarte simpla si usor de folosit. Pentru a instala acest soft ne vom folosi de Terminal, unde vom pasta comenzile de mai jos:

sudo apt-add-repository ppa:screenlets/ppa

sudo apt-get update

sudo apt-get install screenlets

Dupa ce instalarea din terminal se va finaliza, Screenlets este localizat in Meniu ->

Accesorii. Interfata softului este cea din imaginea de mai jos.


Nu trebuie decat sa selectam gadgetul dorit, iar in panoul din stanga sa bifam casutelePorneste/Opreste si Porneste automat pe autentificare. Restul optiunilor sunt simple, nu avem nimic complicat, mai ales ca interfata softului este in limba romana.


Daca dorim putem adauga mai multe gadgeturi, apasand butonul Obtine mai multe Screenleturi.Se va deschide o pagina web unde vom primi instructiuni cu privire la obtinerea de noi gadgeturi.