Change Display/Screen Resolution using Linux Command

Display Application in Ubuntu

Display Application in Ubuntu

To change the Screen Resolution in Ubuntu, simply type Display in the Unity Launcher and run the application. The snapshot of the Display application is taken from Ubuntu 12.10 and is also the same in previous versions also. Similar application is available in other Linux distributions.

But there is a handy command that can do the same thing even faster or can help you create a script (depends how creative and productive you plan to be). The command is simple:

xrandr

This will display all the possible resolution profiles available for the current system (more can also be added and you can find help on http://www.x.org/archive/X11R7.5/doc/man/man1/xrandr.1.html).

To change to a known resolution:

xrandr -s 1024x768

And you have it! :-)

Install LibreOffice 4.x on Ubuntu 12.04 and 12.10

LibreOffice 4.x

LibreOffice 4.x

Document Foundation, the developers behind LibreOffice released Version 4.0 on 7th February 2013. Ubuntu 12.04 however is still stuck with Version 3.5 and Ubuntu 12.10 with Version 3.6 of LibreOffice. Its always nice to be up-to-date with the latest versions. This is what is covered in this post.

The first step is to install the PPA repository and there are two choices you have.

  1. To Add 4.0 Repository (this will remain limited to 4.0 and its subversions only like 4.0.x):
    sudo add-apt-repository ppa:libreoffice/libreoffice-4-0
  2. To Add Latest Repository (also offers 4.0.x but later will automatically update to 4.x and above):
    sudo add-apt-repository ppa:libreoffice/ppa

Which ever road you take, the next steps are the same. Run the update command and upgrade the distribution (simple upgrade won’t work):

sudo apt-get update
sudo apt-get dist-upgrade

And you have the latest LibreOffice :-)

File Synchronization with rsync

Microsoft SyncToy is a very helpful tool for 1-way or 2-way file synchonization. But it hasn’t been updated since 2009 and of course its not for Linux :-)

rsync

Its a very good command based tool which can get the 1-way file synchonization done neatly (the logo does look unprofessional but this tool isn’t).

Installing rsync on Ubuntu

It is by default installed on Ubuntu (tested on both 12.04 and 12.10 distributions) but incase it isn’t, then run the following command:

sudo apt-get install rsync

Structure of rsync command

Following is the structure of the simple yet powerful rsync command:

rsync [options] [source-folder] [destination-folder]

Possible options

  • -a or –archive can be used for archive which means timestamps and ownerships will be retained.
  • -z or –compress can be used for compress mode which means bandwidth can be saved but CPU power will be consumed
  • -v or –verbose can be used to display information when rync is transfering, otherwise it does so silently.
  • -n or –dry-run can be used to display what will happen if this rync command is executed. No changes will take place
  • –progress does what the name says. It will display the %age, transfer rate etc.
  • –size-only will compare files based on their size instead of hashes. This way less CPU power is will consumed.
  • –delete will delete all the files from the destination folder that are not present in the source folder.

Source and Destination Folders

The trailing slash / at the end of the destination is important.

Install/Uninstall Applications in Ubuntu using apt-get

Ubuntu comes with the apt-get command which is all you will need to Install/Uninstall/Upgrade your system. In fact it is available in all the Debian based distributions. This is quite similar to the yum command in Fedora and brew available in MAC.

Install an Application

Run the following command, replacing the [] with the name of the application.

sudo apt-get install [app-name]

Download a Package without Installation

Can package or application can only be downloaded:

sudo apt-get download [app-name]

Uninstall an Application

Run the following command, replacing the [] with the name of the application.

sudo apt-get remove [app-name]

Completely Uninstall an Application along with the Dependencies

Run the following command, replacing the [] with the name of the application.

sudo apt-get remove [app-name]
sudo apt-get autoremove

To Update and Synchronize the List of Applications from Remote Server

This will resynchronize all the package sources mentioned in the /etc/apt/sources.lst file.

sudo apt-get update

To Upgrade all the Applications to the Latest Version

It is highly recommended that first the update command is executed.

sudo apt-get upgrade

Searching for Packages

Before installation, a package can be searched using regular expressions. The information displayed is the one which was fetched last time when update was run.

sudo apt-cache search vim*

Displaying Details for Packages

The details of any package can be displayed using the command:

sudo apt-cache show [app-name]

Delete Downloaded Packages to Clean Disk

The packages downloaded to the local repository can be deleted to save disk space:

sudo apt-get clean

Installing Ubuntu Updates on Multiple Systems

Ubuntu

Ubuntu 12.04

Today I was installing Ubuntu in my Olives School lab. There are 20 systems in total. After installing it in the first PC, I ran the Update and there were 443 of them which amounted for 337MB approx. As it can be imagined it took some time to get the first PC updated. This was clearly not what I was going to do with the rest and I had to come up with a solution.

When Ubuntu downloads these updates, it places them in /var/cache/apt/archives/ folder. In fact even after installing updates, they are not removed from the system. So a solution was simple:

  • Copy all the downloaded packages to a USB
  • On the next PC, run the command:
    sudo cp [path-to-usb]/* /var/cache/apt/archives
  • Once all the files have been pasted, run the Update Manager tool and it will tell you that updates have been downloaded but not yet installed.
  • Click on Install :-)

Introduction to Git

Git SCM

Source Code Management with Git

Git is a Version Control System (VCS) and sometimes referred to as Source Code Management (SCM). A software that tracks the changes that have been made to files. Over time when different versions of a file exists, Git will:

  • Compare them and display the lines that are different.
  • Keep track of all the changes that have been made from one version to the other.
  • Merge different versions and changes together.

Git is however not just specific to source code, it can be used for managing versions of this files. For example you are working on a project proposal and you have named the files as proposal_v1.docx, proposal_v2.docx etc. Microsoft Word offers a form of version control through its feature Track Changes. Similarly Adobe Photoshop offer a feature called History. Wikis also offers the same thing.

Source Code Management before Git

Before Git, different other tools have been used to provide version control such as:

Source Code Control System (SCCS)
Released in 1972 by AT&T as a closed source product but was free with UNIX. It was used in Universities by students and later found its way in companies. Instead of saving three different versions of the same file it just saved a snapshot of the changes in each version.
Revision Control System (RCS)
Released in 1982 as an open source and cross-platform. Instead of keeping the original file as a whole and then keeping snapshots of all the changes made in every version, it did the opposite. Saved the complete file in the latest version and saved snapshot of changes for the older ones.
Concurrent Versions System (CVS)
Introduced in 1990, it added features such as able to add version control on multiple files. Additionally now multiple users were able to work concurrently.
Apache Subversion (SVN)
CVS was further improved in SVN introduced in 2000. It was faster and allowed saving of non-text files like images also. SVN was not just looking at changes made to certain file but was looking for all the changes happening in a directory. It was the most popular VCS before Git.
BitKeeper SCM
Released in 2000 as a proprietary solution but also had a Community Version which was free but had less features. Distributed Version Control was added to it. This free edition was used by the Linux Community for the Linux Kernel from 2002-2005. In April 2005, the Community Version was no more free and so Linux Foundation thought of coming up with their own solution.
Linus Torvalds

Linus Torvalds

Birth of Git

Git was created by Linus Torvalds in April 2005 as an open source product. Like BitKeeper it is also a Distributed Version Control System and is cross-platform. One other advantage is that it is many times faster than other SCMs. It has better safeguards built into it for data corruptions.

How Git Works

In centralized version control systems a copy of the code is placed centrally and users work on their end, when they commit the changes it will placed in the central repository. It is up to the user to keep track of what is happening in the central repository.

In Distributed Version Control Systems however, like Git, different users (or teams of users) maintain their own repositories, instead of working from a central repository. Git is very flexible and different workflows can be implemented with Git.

The changes are stored as “change sets” or “patches”. In other words, Git tracks changes not versions. These “change sets” or “patches” can be exchanged between repositories, merge with other “change sets” or “apply patches”. There are no single master repository instead there are many working copies each with their own combination of change sets.

Rotate & Flip Video Files in Ubuntu (Linux)

Rotate Video Files

Rotate Video Files

The first thing that might pop-up in the reader’s mind is that why would anyone ever want to rotate a video? Well this need arose when I recorded videos using iPad (which always auto rotate the screen according to the user orientation). But when I transferred those to my PC, I realized that some needed to be rotated 90 degrees and some 180 or vertically flipped.

Ubuntu always has the answers to my questions. In a previous post in which I shared the commands on how to record screencasts in Ubuntu, I mentioned about avconv tool and how to install it with codecs. The same nice tool can be used to flip and rotate videos also.

To vertically flip a video:

avconv -i input_video.mov -c:v libx264 -c:a copy -vf "vflip" output_video.mov

To horizontally flip a video:

avconv -i input_video.mov -c:v libx264 -c:a copy -vf "hflip" output_video.mov

To rotate it 90 degree clock-wise:

avconv -i input_video.mov -c:v libx264 -c:a copy -vf "transpose=1" output_video.mov

The copy parameter means to keep the same audio encoding.

For further reading visit the official documentation: http://libav.org/libavfilter.html