Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, April 17, 2010

Mepis 8.5: ATI Driver on Dell Inspiron 4000 Laptop

I had a regular hang up problem with Mepis 8.0 on my old Dell laptop, so when the next version 8.5 got released I gave it a try. Installation went through smoothly and the previous hang up problem seemed to be resolved. The only inconvenience with the new Mepis was that the display GUI option to install an ATI driver was stripped out.

Mepis has a web-page describing how to Install ATI driver. Starting with Mepis 8.5, it's recommended to use the sgfxi script which I followed.

Just for the record here are some screen-shots from the installation:











Read more...

Saturday, November 21, 2009

Getch in Python - Read a Character without Enter

Sometimes it is more appropriate to read from keyboard without waiting for Enter to be codessed, for example, when choosing from a menu. The raw_input("Prompt String >") always waits for Enter, so a function similar to getch() in C is needed and there are some solutions for that in Python.
  1. There is getch() equivalent for Windows environment in library msvcrt:

    import msvcrt

    result = msvcrt.getch()

    Funny thing is that the code works fine from command window (cmd.exe), but does not in IDLE: in IDLE it does not wait for a key and gives out '\xff' as the result.

    In Linux the same can be done this way:

    import sys, tty, termios

    fd = sys.stdin.fileno()
    # save original terminal settings
    old_settings = termios.tcgetattr(fd)

    # change terminal settings to raw read
    tty.setraw(sys.stdin.fileno())

    ch = sys.stdin.read(1)

    # restore original terminal settings
    termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
    print '\ncodessed char is \'' + ch +'\'\n'

    Since the solution is system dependent some people propose a universal approach when program tries one implementation and if it fails - the other one, here is an example from ActiveState Code, Danny Yoo:

    class _Getch:
    """Gets a single character from standard input.
    Does not echo to the screen."""
    def __init__(self):
    try:
    self.impl = _GetchWindows()
    except ImportError:
    self.impl = _GetchUnix()

    def __call__(self): return self.impl()

    class _GetchUnix:
    def __init__(self):
    import tty, sys

    def __call__(self):
    import sys, tty, termios
    fd = sys.stdin.fileno()
    old_settings = termios.tcgetattr(fd)
    try:
    tty.setraw(sys.stdin.fileno())
    ch = sys.stdin.read(1)
    finally:
    termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
    return ch

    class _GetchWindows:
    def __init__(self):
    import msvcrt

    def __call__(self):
    import msvcrt
    return msvcrt.getch()

    getch = _Getch()

  2. Using TK library the following code works OK:

    import Tkinter as tk

    def keycodess(event):
    if event.keysym == 'Escape':
    root.destroy()
    x = event.char
    if x == "a":
    print "A done"
    elif x == "b":
    print "B done"
    elif x == "c":
    print "C done"
    elif x == "d":
    print "D done"
    else:
    print x

    root = tk.Tk()
    print "a. Menu choice A"
    print "b. Menu choice B"
    print "c. Menu choice C"
    print "d. Menu choice D"
    root.bind_all('', keycodess)
    # hiding the tk window
    root.withdraw()
    root.mainloop()

    It works OK in Windows command window (cmd.exe), but in IDLE and Linux the line root.withdraw() should be commented out - the code works OK while the root window is in focus. This kind of examples you can find here.

  3. Curses library has its own getch implementation. I did not check it, just would like to mention for the record.
If you know any other solutions - I'd love to here from you about them!
Read more...

Saturday, November 7, 2009

Zimbra - Perfect E-Mail Client for Perfect People

It is common to use a separate e-mail account for each separate activity: work, home, hobby, web subscriptions, etc.. So happened that some of accounts I have at Yahoo and others at Google.  Neither Yahoo nor Google allows simultaneous access to multiple accounts. So I've been thinking for a long time how convenient it would be to have alive connections to all my web e-mail accounts from one place at the same time. Another problem with Yahoo - no support for IMAP (they offer POP3 for $ Mail Plus, but I don't even want POP3). Now solution for both the issues is available - it is Zimbra Desktop.

An attempt to install zdesktop_1_0_3_build_1691_win32.exe failed with a strange error, so I installed previous zdesktop_1_0_build_1537_win32.exe then allowed it upgrading to version 1.0 build 1593 - flawless.

I registered all my Yahoo and Google accounts in Zimbra Desktop and tested them - result is remarkable:
  • All accounts are in simultaneous access as expected.
  • Working from Zimbra Desktop is the same as if it would be from the web-account - all changes applied in the Desktop are properly reflected on the web-account and vice-versa.
  • Somehow Zimbra has true IMAP access to Yahoo free accounts - it's probably become possible because Zimbra is actually Yahoo Zimbra.
  • Zimbra enables IMAP access to Google e-mail accounts and it works fine too.
  • Zimbra provides an access not only to inbox but to all existing folders in the account.
  •  It can work with many other types of accounts as Hotmail, AOL, POP3, IMAP, etc.:

  • Zimbra has many other features which I don't need yet but I'm considering them interesting for the future.
  • Available for Linux and Windows.
I tested it on Yahoo and Google accounts - Zimbra gives a transparent control over e-mails as if you would be really logged in the web-account. Amazing!



The only inconvenience I faced with Zimbra Desktop is that it relies on computer account security, but the issue is related not to the program itself but to a user perfection and I am apparently not such one. So if you have not established a separate password protected account for every member of your crew, your parrot and your wooden leg, then Zimbra Desktop can be started by someone with access to the computer and all your e-mail accounts will be exposed whether you like it or not. I personally didn't want to change the sin way what got settled on my desktop PC - that's why I simply installed Zimbra on a virtual machine with all passwords and I run it only for myself.

Potentially, in order to satisfy imperfect people as myself, the issue could be easily fixed by adding a "user logon to Zimbra" with loading a corresponding account profile... but probably that would be too much to expect from Zimbra developers: Zimbra Desktop is already a great useful program.

It should be said that Desktop is just one application among many what Zimbra offers. The main product is Zimbra Collaboration Suit. It comes with different flavors and prices from the free Open Source Edition to the Professional Edition - check out their web-site for details.
Read more...

Thursday, October 29, 2009

List of PCI and USB Devices - Linux and Windows

Sometimes it's necessary to check devices installed on a PC. In Linux it is quite simple - command

$ lspci -h

gives out available options for listing PCI devices.
For example,

$ lspci -nn

shows up both textual and numeric ID's.

There is a similar command for USB devices:

$ lsusb -h

For the same purposes in Windows there is a nice program devcon.exe - it can be downloaded from http://support.microsoft.com/kb/311272.
For instance, command

> devcon findall PCI*

lists all PCI devices. The following command shows up all PCI devices with assigned system resources:

> devcon resources PCI*

Read more...

Saturday, October 10, 2009

Mixed Windows & Linux Network - Free Remote Desktop

Having some computers with Windows and others with Linux makes remote desktop access from one computer to another slightly more complicated. Here is what I found as a working solution.

  • From Windows to Windows connection - UltraVNC. It has viewer and server, 32 and 64-bit XP and Vista compatible. It works fine with hardware and virtual Windows machines and any edition (Microsoft remote desktop is not available for the cheapest versions as Home, Basic, Premium).

  • From Windows and Linux to Linux - NoMachine NX. They offer Windows and Linux viewers for free, Linux server is free as well. I used NX viewers and servers on hardware and virtual Linux boxes with KDE, on Debian and Ubuntu all work very good.

  • From Linux to Windows - I found Remote Desktop Connection (krdc) already installed on Mepis 8.0 and used UltraVNC server on Windows side. In krdc connection request: vnc:/IPAddress:0

VNC and SSH protocols should be enabled in firewalls on both server and client/viewer sides.
Read more...

Sunday, October 4, 2009

C and C++ Compiling in Linux - Get It Ready

Not all Linux distributions are ready for C and C++ compilation right after installation. Some of them are missing compilers, others - some basic libraries. I decided to write the note how to make it working.

Create a new directory for the tests and save a file HelloWorld.c in it. The file has the following content:

#include <stdio.h>

main ()
{
printf ( "Hello World!\n");
}

On Mepis 7.0 machine cc and gcc C compilers were installed:

$ whereis cc gcc
cc: /usr/bin/cc
gcc: /usr/bin/gcc /usr/lib/gcc

but attempt to compile the C code ended up with an error :

$ cc HelloWorld.c -o HelloWorld_cc
HelloWorld.c:1:19: error: stdio.h: No such file or directory
HelloWorld.c: In function 'main':
HelloWorld.c:5: warning: incompatible implicit declaration
of built-in function 'printf'

The missing "stdio.h" library comes with the "build-essential" package. Mepis has Synaptic package manager - start it and install the package. After that compilation passes through without an error:

$ cc HelloWorld.c -o HelloWorld_cc
$ ./HelloWorld_cc
Hello World!

$ gcc HelloWorld.c -o HelloWorld_gcc
$ ./HelloWorld_gcc
Hello World!

Mepis 8.0 did not have a problem with C program, but neither c++ nor g++ compiler was installed:

$ whereis c++ g++

gave out nothing. With a package manager (again Synaptic in my case) install the compiler(s). After that "whereis" can find them:

$ whereis c++ g++
c++: /usr/bin/c++ /usr/include/c++
g++: /usr/bin/g++

Create HelloWorld.cpp C++ file:

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!\n";
return 0;
}

Compilation is successful with the both compilers:

$ g++ HelloWorld.cpp -o HelloWorld_g++
$ ./HelloWorld_g++
Hello World!

$ c++ HelloWorld.cpp -o HelloWorld_c++
$ ./HelloWorld_c++
Hello World!

Read more...

Saturday, October 3, 2009

Finding in Linux (bash shell)

I'd like to put in the list some useful commands for finding things in Linux environment.




  1. apropos keywords - searches through manual descriptions for the keywords. Say, we are interested in commands to find anything:

    $ apropos find search look locate match

    what gives out a list of related commands with short helpful description. On my Mepis 8.0 virtual machine it shows the following lines among others:

    ...
    apropos (1) - search the manual page names and descr...
    look (1) - display lines beginning with a given string
    find (1) - search for files in a directory hierarchy
    grep (1) - print lines matching a pattern
    kfind (1) - KDE find tool
    locate (1) - list files in databases that match a pat...
    rgrep (1) - print lines matching a pattern
    whereis (1) - locate the binary, source, and manual pa...
    which (1) - locate a command
    ...

    apropos will work only if manuals are installed - usually they are, but sometimes for the sake of resource saving manuals can be omitted.

  2. find is a very powerful command for searching files in directories:

    $ find startdir -name filename

    Different options allow to search for files by name, size, type, permission, owner, etc. - check manual and help:

    $ man find
    $ find --help

  3. grep searches for a pattern inside text file:

    grep "pattern" filename

    Example of finding files and then find a pattern inside the files:

    $ find /home/svn -name "test*txt"|xargs grep "first" -i
    The first line of the test file.


    There are some variations of grep as fgrep, rgrep, egrep, bzgrep, etc. - check it with "apropos grep".

  4. kfind is a GUI version of find with grep - it can search for files and pattern inside files.

  5. look prints out strings beginning with a pattern from a file:
    $ look pattern filename

  6. strings prints out all strings from a text or binary file:
    $ strings filename

  7. whereis locates different type of files. For instance:
    $ whereis find
    find: /usr/bin/find /usr/share/man/man1/find.1.gz

  8. locate searches for files in databases (it gives out all files with names containing given keyword):
    $ locate find

  9. which search for executables and shows up the whole path to directories where the files are found:
    $ which find
    /usr/bin/find

Read more...

Tuesday, June 23, 2009

Recovering from Lost Linux Root Password

Root password can be changed without entering the old forgotten one. Just reboot the computer from LiveCD, then in command prompt mount the root partition on /mnt and make it the current root:


$ mount /dev/hda1 /mnt
$ chroot /mnt /bin/sh

Then

$ passwd

and enter a new password you think you will not forget :)
Read more...