Monthly Archives: September 2009

Ubuntu Starter Kit

You have just installed Ubuntu, logged in for the first time and don’t know what to do next? It’s understandable that the system should be configured the way that would ensure decent experience. Of course, depending on your needs you may want different software to be installed. So we would recommend you to check the following steps and list of applications in order to choose the ones which may be useful for you.

1. Enabling all the repositories

Repositories represent software archives were thousands of programs for Ubuntu are stored. Repositories make it very easy to install new software onto Ubuntu using an Internet connection. In addition to that they provide a high level of security, as each program available in the repositories is thoroughly tested and built specifically for each version of Ubuntu. Thus enabling all the repositories you ensure the access to the bigger amount of applications.

It should be mentioned that Ubuntu software repositories are organized into 4 separate components, according to the level of support offered by Ubuntu. Here is the list of those components:

• Main – Officially supported software.

• Restricted – Supported software that is not available under a completely free license.

• Universe – Community maintained software, i.e. not officially supported software.

• Multiverse – Software that is not free.

There are two ways to enable/disable repositories:

a) System > Administration > Software Sources

b) System > Administration > Synaptic >> Settings >> Repositories

Here is the window you get, which gives you the opportunity to choose the repositories you need:

01_List_of_repositories_for_blog

As soon as you’ve done which choosing enabling/disabling of repositories (we suggest you to enable all of them), click “Close” button to save your changes. A dialog box should appear, asking whether you’d like to update the list of repositories. Select “Reload” to update the list. Make sure that you click “Reload” button, because repository information will not be updated until the “Reload” is selected.

IMPORTANT: In case you use Ubuntu 9.04 (Jaunty) all the repositories are enabled by default, so you can skip this step.

The last thing to mention about repositories is that you can use command line instead of graphical interface to manage them. Here you get more info about this method.

Continue reading

All you need to view PDF documents in Linux

PDF (or Portable Document Format) is used for representing two-dimensional documents in a manner independent of the application software, hardware, and operating system.

Each PDF document contains a complete description of the document, including images, text, vector graphics, raster images, and may contain the necessary fonts to display text. To view PDF documents you need to have certain computer programs, which are free and can be found via the Internet.

PDF files can be used on most platforms, Linux is also included. The free Adobe Reader is the PDF-leader and allows Linux users to read any PDF files, but we have reviewed some alternative viewers you can use to open PDF files in Linux. Here’s the list of 5 most used:

1. Adobe Reader – freeware for Linux.
2. Evince – the default PDF viewer for GNOME.
3. Xpdf for the X Window System.
4. KPDF for the K Desktop Environment.
5. Foxit Reader by Foxit Software.

Adobe Reader

adobe reader linux

The Adobe Reader (aka Acrobat Reader) is available as a no-charge download from Adobe’s web site, and allows viewing & printing any PDF files. The new Adobe Reader 9.1.3 (for Linux) doesn’t have any critical security vulnerabilities while providing more stability. The update is available as a full Adobe Reader 9.1.3 installer and can be downloaded from the Adobe FTP server. This multilingual update is available in the following language versions: English, French, German, and Japanese.

System requirements:
-32-bit Intel Pentium processor or equivalent
-Red Hat® Linux WS 5, SUSE® Linux Enterprise Desktop (SLED) 10 SP2 or Ubuntu 7.10
-GNOME or KDE Desktop Environment
-512MB of RAM (1GB recommended)
-150MB of available hard-disk space (additional 75MB required for all supported font packs)
-GTK+ (GIMP Toolkit) user interface library, version 2.6 or later
-Firefox 2.0 or later
-OpenLDAP and CUPS libraries

This is the most popular PDF viewer, but there are some alternative viewers and you are welcome to try them too.

Evince

Evince is a document viewer for multiple document formats as pdf, postscript, djvu, tiff and dvi. The goal of evince is to replace the multiple document viewers that exist on the GNOME Desktop with a single simple application. Evince has ben included by GNOME since GNOME 2.12 was released. It is written mainly in C and C++. It has been released under the GNU General Public License, so Evince is free software. It’s not just a PDF viewer, and it’s doing the job very well.

evince

Features:
-Search – Integrated search displaying the number of results found and highlights the results on the page.
-Page Thumbnails – Thumbnails of pages show quick reference for where you’d like to go in a document.
-Document Printing – Using the GNOME/GTK printing framework Evince can print any document it can open.
-Encrypted Document Viewing – Evince can open PDF documents that have been encrypted.

Xpdf

Xpdf is an open source PDF viewer for the X Window System and runs on UNIX, VMS, and OS/2. The non-X components (pdftops, pdftotext, etc.) also run on Win32 systems. Xpdf includes programs which extract images from PDF files or convert PDF to PostScript or text, so it’s not a somple PDF viewer. These programs run on DOS, Windows, Linux and Unix.

It also has been licensed under the GNU General Public License. You can see the Xpdf web page for download  links. Source code, precompiled binaries and language support packages of the current version Xpdf 3.02pl3 are available for Linux, Spartac and DOS/Win32.

KPDF

KPDF is a PDF viewer, based on xpdf for KDE (K Desktop Environment). Same as original Acrobat Reader, it provides side panel with thumbnails, allows double page mode. The TTS (text-to-speech) of PDF documents is also included.

kpdf

The latest version KPDF 0.5.10. was released on August 26, 2008 and has some interesting features like: three different ways of searching, put fonts used by the document on the properties dialog, support for images with alpha channel, Google-like search on thumbnails, cursor wrapping over screen for continous scrolling, save zoom setting on exit and many others.

Foxit Reader

Foxit Reader is a multilingual PDF reader created by Foxit Software. It is available as freeware but has also a full version with enhanced functionality. As a small and fast PDF viewer, Foxit Reader currently has over 50 million users all around the world. After keeping users waiting for almost two months, Foxit Reader 3.1 has been released and it introduces many fascinating new features including internet search and favorite toolbar settings.

foxit
Foxit Reader 3.1 supports internet keyword search. You can select the text and click the pop-up search icon or press and drag the mouse directly to search for the related information in Internet. It also supports customization of toolsappearing in the Favorite Toolbar area, so that users can choose the tools that are used most often easily and quickly. You are welcome to look at the official website for more features.

So you shouldn’t have any problems viewing PDF files in Linux; we have recently reviewed the possibility of viewing doc files in linux and there were no problems too. We are going to check some other popular file formats in the near future, so if you would like to see any specific formats, please, let us know. You are welcome to add comments to this article so we could know what are your areas of interest.

How to Count Number of Lines in a File with PHP

It is a common task to know the size of your files. If you are programming anything using PHP, you should know that there is no exact function to count the number of strings in a file without causing high server load. That’s why I have written a function that uses Linux system command, that works very fast and doesn’t cause any server load. Here it is:

function strcount($filename)
{
if (file_exists($filename))
{
$count=exec(“wc -l $filename”);
return substr($count, 0, strpos($count, ” “));
}
else return 0;
}

Everything seems to be simple, yet usable. Have fun!

IPv6 advantages and its configuration in OS Linux

Internet Protocol version 6 (IPv6) represents the next-generation protocol designed to replace IPv4, which still remains to be the most commonly used protocol in the Internet, though it’s nearly twenty years old now. The main reason for using another protocol is a growing shortage of IPv4 addresses needed by all new machines added to the Internet.

IPv6 has a vastly larger address space than IPv4. This results from the use of a 128-bit address, whereas IPv4 uses only 32 bits. The new address space thus supports 2^128 (about 3.4×10^38) addresses. Thus IPv6 eliminates the need for network address translation (NAT), which gained widespread deployment as an effort to solve the problem of IPv4 address exhaustion.

Of course, IPv4 address exhaustion is not the only problem that can be fixed by IPv6. Moreover IPv6 has other important improvements to IPv4 such as routing, network autoconfiguration, network security and etc.

In addition to the above mentioned improvements here the significant advantages of IPv6 which can be very important for the end users:

  1. Static IP-addresses for your computers

  2. Nowadays, in case you don’t have direct IPv6, the best way to connect to IPv6 is to register an account at a tunnel broker’s site. A tunnel broker is a company that offers service (for free) of transferring your traffic from IPv4 to IPv6 and backwards.

    Using this method user gets his/her own IPv6 subnet, which is tied not to the current IPv4 address, but to his/her account (login and password). Thus you have the opportunity not just to get the range of IPv6 addresses, but to use them even if you change your IPv4 provider.

    Moreover, every user gets a subnet /64, which is enough to connect to the network 2^64 devices and assign them static Internet addresses. This means that you can access any computer of your network directly (via its address) without the necessity to use NAT.

    Some users may think that security problems will appear in this case, isn’t it? In fact there is no reason to worry. The only thing you should do is to configure your firewall, so it doesn’t pass connections from the Internet to the local network, except the ones that were allowed.

  3. Higher speed for torrents downloading

  4. BitTorrent Protocol is designed in such a way that users who do not have the opportunity to receive incoming connection (provider’s NAT is used) can “torrent” the files just from the users who have own IP address (NAT is not used). That’s why the growing shortage of IPv4 addresses will cause the decrease in amount of torrent peers and seeds.

    If you use IPv6 there is no need to worry about this problem, because IPv6 users can get own IP addresses even in case their IPv4 provider uses NAT for them. Of course, you should check if your favorite tracker supports IPv6.

  5. Long-lived connections that remain even after IPv4 address changing

    Internet access control systems of some providers work in such a way that maximum duration of an Internet connection is equal to 24 hours, after which a forced disconnection takes place. During the repeated connection new IP-address is given. This can happen while you are chatting, playing online games, use different online services and etc.
    If you connect using IPv6, there won’t be a disconnection while IPv4 address is changing, because IPv6 remains the same. The only thing that will happen is discontinuance of data transfer for 15 seconds – the time needed for a tunnel broker to get the info about new IPv4.

However despite all the improvements and advantages the worldwide penetration of IPv6 protocol is still less than one percent of Internet-enabled hosts in any country; though IPv6 has been implemented on all major operating systems in commercial, business, and home consumer environments.

Continue reading

Setting Up Network Interfaces in Linux

Nowadays computer provides us a great deal of opportunities (of course, the majority of users can easily go without many of them), but with no exaggerations “surfing the net” represents one of the most important and essential ones. People who use Linux OS argue that given operating system is perfect for Web. In fact it’s hardly possible to disagree with them; however before you can start surfing the web the first thing you need to do is to configure network interfaces.

What are the network interfaces? They represent devices that are used to transmit and receive packages of data. The examples of network interface devices are: Ethernet card, ISDN adapter, modem and etc. You can imagine that a network interface is a mailbox or an end of pipe, where you can send information and receive an answer. The integral attribute of network interface is address.

Generally users encounter with IP (Internet Protocol) networks. In the given review we are going to consider IPv4 (4th version of IP addresses), which are still very popular among the end users. After that we will discuss how to setup a network connection in Linux, taking as an example Ethernet card (which presents an interface allowing to connect a PC to the net with the help of copper twisted pair cable with the data transfer speed of up to 1GB/s). You can setup other interfaces in a similar way. To setup the interface in Linux the following steps should be completed:

  • Physical installation of the card in the system (we suppose you’ve already done this step or the interface is in the motherboard of your computer; moreover don’t forget to plug in the cable as well)
  • Installation of the proper drivers, so Linux can work with your card
  • Specifying IP address and some other parameters, which are needed for IP network

In Linux OS network interfaces (as the majority of other devices) are set up with the help of text files, which can vary depending on distributions, for example:

Distribution Interface and routing setting
Debian /etc/init.d/network
Ubuntu /etc/network/interfaces
Slackware /etc/rc.d/rc.inet1
RedHat /etc/sysconfig/network-scripts/ifup-<ifname>

We are going to review it by Ubuntu example.

Continue reading

vi Command list for Command Line Editing

As you already know, Linux has some things that require command line even for user tasks. Most of them are connected with file modification. There are some ways to alter files from command line, and one of the most effective seems to be vi. It is a powerful editor that comes with lots of functions and if you know its hotkeys, it will save you lots of time. Some people say that it cannot be compared even with Windows text editors. So let me show you several things that will make your interaction with vi more pleasant.

We’ll start with cursor control, as it’s the first need when you open a file.

h Left
j Down
k Up
l (or spacebar)    Right

Of course, you’re welcome to use keyboard arrows if you like them so much. There are some more complicated manipulations, so let me show them. These commands will help you to navigate between your file text in a smart way.

w Forward one word
b Back one word
e End of word
( Beginning of current sentence
) Beginning of next sentence
{ Beginning of current paragraph
} Beginning of next paragraph
[[ Beginning of current section
]] Beginning of next section
0 Start of current line
$ End of current line
^ First non-white character of current line
+ or Return (Enter)    First character of next line
First character of previous line
n | character n of current line

If your file takes some screens, there are some commands for screen movements.

H Top line of current screen
M Middle line of current screen
L Last line of current screen
nH n lines after top line of current screen
nL n lines before last line of current screen
Ctrl-F Forward one screen
Ctrl-B Back one screen
Ctrl-D Down half a screen
Ctrl-U Up half a screen
Ctrl-E Display another line at bottom of screen
Ctrl-Y Display another line at top of screen
z Return (Enter)  Redraw screen with cursor at top
z . Redraw screen with cursor in middle
z – Redraw screen with cursor at bottom
Ctrl-L Redraw screen without re-positioning
Ctrl-R Redraw screen without re-positioning

Of course, there are some commands related to search and moving between line numbers.
/text Search for text (forwards)
/    Repeat forward search (Just like F3 in Microsoft Windows)
?text Search for text (backwards)
? Repeat previous search backwards
n Repeat previous search
N Repeat previous search, but it opposite direction
/text/+n    Go to line n after text
?text?-n Go to line n before text
% Find match of current parenthesis, brace, or bracket (very useful for programmers).
Ctrl-G Display line number of cursor
nG Move cursor to line number n
:n Move cursor to line number n
G Move to last line in file

As you can see, there are lots of ways to navigate within a file. Let’s start with wile editing commands, they aren’t less interesting.

A Append to end of current line
i Insert before cursor
I Insert at beginning of line
o Open line above cursor
O Open line below cursor
ESC End of insert mode
Ctrl-I Insert a tab
Ctrl-T Move to next tab position
Backspace Move back one character
Ctrl-U Delete current line
Ctrl-V Quote next character
Ctrl-W Move back one word
cw Change word
cc Change line
C Change from current position to end of line
dd Delete current line
ndd Delete n lines
D Delete remainer of line
dw Delete word
d} Delete rest of paragraph
d^ Delete back to start of line
c/pat Delete up to first occurance of pattern
dn Delete up to next occurance of pattern
dfa Delete up to and including a on current line
dta Delete up to, but not including, a on current line
dL Delete up to last line on screen
dG Delete to end of file
J Join two lines
p Insert buffer after cursor
P Insert buffer before cursor
rx Replace character with x
Rtext Replace text beginning at cursor
s Substitute character
ns Substitute n characters
S Substitute entire line
u Undo last change

And we finally come to file manipulation commands as we will need to save (or not) our changes.

:w Write file
:w! Write file (ignoring warnings, force writing)
:w! file Overwrite file (ignoring warnings)
:wq Write file and quit
:q Quit
:q! Quit (even if changes not saved)
:w file Write file as file, leaving original untouched
ZZ Quit, only writing file if changed
:x Quit, only writing file if changed
:n1,n2w file Write lines n1 to n2 to file
:n1,n2w >> file Append lines n1 to n2 to file
:e file2    Edit file2 (current file becomes alternate file)
:e! Reload file from disk (revert to previous saved version)
:e# Edit alternate file
% Display current filename
# Display alternate filename
:n Edit next file
:n! Edit next file (ignoring warnings)
:n files Specify new list of files
:r file Insert file after cursor
:r !command Run command, and insert output after current line

As you can see, the number of vi commands is really huge. If you get acquainted to this editor, you won’t even try anything else, the professional programmers say. If you need vi to edit files (e.g. crontab modification), you will find all the necessary commands above.

Have a good time with vi! :-)