EzDevInfo.com

ubuntu-10.04 interview questions

Top ubuntu-10.04 frequently asked interview questions

Using ioctl communication between Kernel mode and user mode

I want to communicate with my kernel module using ioctl. I have written two c program one for kernel module and other for user mode. I am getting this error while compiling kernel module:

error: unknown field ‘ioctl’ specified in initializer

at this line :

struct file_operations Fops = {
 .read = device_read,
 .write = device_write,
 .ioctl = device_ioctl,  ------> at this point error is occuring.
 .open = device_open,
 .release = device_release,
};

any idea why this is happening.

thanks


Source: (StackOverflow)

Good diff tools under Ubuntu GNOME

Could somebody give me some recommendations on diff tools on Ubuntu? Actually what I need is not just file comparison, but also directory comparison.

I think diff tools under Windows is really most convenient, especially WinMerge.

But under Ubuntu, what I can get with high efficiency is only TkDiff, but it only support file comparison?

Hope to get some help from here.


Source: (StackOverflow)

Advertisements

How to setup SSH Access for Amazon EC2 instance?

I need SSH access to an Amazon EC2 instance running Ubuntu 10.4. All I got is the amazon username and password. Any ideas?


Source: (StackOverflow)

Illegal pattern character 'Y' on Ubuntu

I use this pattern SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); in windows and it works, but when try on Ubuntu 10.04 it show an exception play.exceptions.JavaExecutionException: Illegal pattern character 'Y'.

I search for solution for this and found the year pattern must be change to lower-case: SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); and it works.

Can anyone can tell me the reason behind this why in Windows works but in Ubuntu didn't work if I use 'Y' instead of 'y'?

Note:

  1. Play-1.2.3
  2. JRE:
    1. Windows: java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b05) Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
    2. Ubuntu: java version "1.6.0_31" Java(TM) SE Runtime Environment (build 1.6.0_31-b04) Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
  3. Windows 7
  4. Ubuntu 10.04

Update 24/05/2012

After I check again in my system, there is 3 JRE and my windows using JRE1.7 for default. But for Play I set running using JRE1.6.


Source: (StackOverflow)

Eclipse, change popup text background color when hovering the mouse on a keyword

Ubuntu 10.04.1 new theme has by default all windows background colors set to black.
I don't want to change that.

In Eclipse, the interface didn't change much due to 10.04.1 - except for one annoying thing:
when the mouse hovers over a keyword - a variable for instance - the type (...) of that keyword is displayed in a small pop-up window.
The problem since 10.04.1, is that the text is in black color while the background is also black.

Is there a way to change that background color in Eclipse?


Source: (StackOverflow)

rhino vs spidermonkey

I noticed ubuntu 10.04 removed the spidermonkey package. Rhino looks like it's still there though. What are the differences between rhino and spidermonkey (besides what language they're written in). And why did they remove spidermonkey?


Source: (StackOverflow)

Rails, rake does not work

I've been trying to use Rails and when I use rake, I get this error. Any suggestions on which run time should I use?

ngzhongqin@ngzhongqin-linux:~/RailsProjects/webuiltit$ rake db:create:all --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib/execjs/runtimes.rb:45:in `autodetect'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib/execjs.rb:5:in `<module:ExecJS>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib/execjs.rb:4:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-rails-3.1.0/lib/coffee-rails.rb:1:in `require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/coffee-rails-3.1.0/lib/coffee-rails.rb:1:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
/home/ngzhongqin/RailsProjects/webuiltit/config/application.rb:13:in `<top (required)>'
/home/ngzhongqin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/ngzhongqin/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/ngzhongqin/RailsProjects/webuiltit/Rakefile:5:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'

Source: (StackOverflow)

freeTDS not using its config

I've decided to use FreeTDS driver and unixODBC to manage the PDO connection between my LAMP-based app with a remote MsSQL database. unfortunately it appears that the driver doesn't read the freetds.conf file, nor the environmental variables set either directly via server's CLI or specified in php file by putenv() function.

now some data:

  1. as I ping the server - no packets are lost.
  2. as I telnet the server on 1433 port - the connection is established
  3. as I use the command

    TDSVER=7.0 tsql -H >IP< -p 1433 -U username
    

    I am prompted to enter password and connection is established.

  4. without the TDSVER preceding the command - the connection fails with such a message:

    Error 20017 (severity 9):
        Unexpected EOF from the server
        OS error 115, "Operation now in progress"
    Error 20002 (severity 9):
        Adaptive Server connection failed
    There was a problem connecting to the server
    
  5. the tsql -C commands echos such an output:

    Compile-time settings (established with the "configure" script)
                           Version: freetds v0.91
            freetds.conf directory: /usr/local/etc
    MS db-lib source compatibility: yes
       Sybase binary compatibility: no
                     Thread safety: yes
                     iconv library: yes
                       TDS version: 5.0
                             iODBC: no
                          unixodbc: yes
             SSPI "trusted" logins: no
                          Kerberos: no
    
  6. freetds.conf in the location given above has this entry:

    [MSSQL]
    host = >IP<
    port = 1433
    tds version = 7.0
    
  7. the ISQL also fails:

    isql -v MSSQL
    [S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
    [01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
    [ISQL]ERROR: Could not SQLConnect
    
  8. my odbc.ini :

    [MSSQL]
    Description = MS SQL Server
    Driver = FreeTDS
    TDS_Version = 7.0
    Server = >IP<
    UID = username
    PWD = password
    ReadOnly = No
    Port = 1433
    

I suppose the solution is really simple, but i'm just too stupid to find it...


Source: (StackOverflow)

Help installing static binary for wkhtmltopdf

I am trying to use the static binary of wkhtmltopdf on Ubuntu server 10.0.4. The reason for is that it apparently has a built in modified QT that will allow me to run wkhtmltopdf without an X Server.

Result: Once installed (see steps below), when I execute wkhtmltopdf in the terminal, it does not fire up... just returns me to the prompt - like it ran and did something, no error but no output:

:/usr/bin$ wkhtmltopdf

:/usr/bin$

Same behavior if I put args:

:/usr/bin$ wkhtmltopdf http://www.google.com test.pdf

:/usr/bin$

Am I doing something wrong --- my understanding that the static binary should just fire up. Perhaps missing some dependency? Is there a way to get some verbose output?

These are the steps I have followed:

In /usr/bin:

1) Confirmed that the existing (non-static) wkhtmltopdf resides there and that it executes. When I execute it with no args I get the help/about output from the app.

2) Moved the existing wkhtmltopdf out of the directory (renamed it)

3) Get the static binary: sudo curl -C - -O http: //wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2

4) Untar: tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2

5) Rename: mv wkhtmltopdf-i386 wkthtmltopdf

6) Get (apparently) necessary packages: sudo apt-get install openssl build-essential xorg libssl-dev


Source: (StackOverflow)

Ubuntu: change the path from OpenJDK 6 to Oracle JDK 7

After downloading the latest .tar file I ran tar zxvf jdk-7u45-linux-x64.tar.gz to extract java files.

Set the path in .bashrc file (vi ~/.bashrc) as below;

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45/bin/java
export PATH=$PATH:/usr/lib/jvm/jdk1.7.0_45/bin
export JDK_HOME=/usr/lib/jvm/jdk1.7.0_45    
export JRE_HOME=/usr/lib/jvm/jre1.7.0_45

Now, running command java -version or which java, java PATH still pointing to the older java version (java version "1.6.0_27").

I know default ubuntu takes OpenJDK path. I have to change the path as latest version as my system environment variable set in .bashrc file.

Also, sudo update-alternatives --config java

Selection    Path                                      Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-oracle/jre/bin/java    1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java    1062      manual mode
* 3            /usr/lib/jvm/jdk1.7.0_45/bin/java          1         manual mode
Press enter to keep the current choice[*], or type selection number: 3

Source: (StackOverflow)

to read line from file in python without getting "\n" appended at the end

My file is "xml.txt" with following contents:

books.xml 
news.xml
mix.xml

if I use readline() function it appends "\n" at the name of all the files which is an error because I want to open the files contained within the xml.txt. I wrote this:

fo = open("xml.tx","r")
for i in range(count.__len__()): #here count is one of may arrays that i'm using
    file = fo.readline()
    find_root(file) # here find_root is my own created function not displayed here

error encountered on running this code:

IOError: [Errno 2] No such file or directory: 'books.xml\n'


Source: (StackOverflow)

what is the meaning of restrict in the function signature?

int pthread_create(pthread_t *restrict thread,
              const pthread_attr_t *restrict attr,
              void *(*start_routine)(void*), void *restrict arg);

I would like to know what the meaning of restrict is?


Source: (StackOverflow)

zlib module missing

I have compiled and installed python 2.7 on my ubuntu lucid.
But I am unable to install setuptools for python 2.7 because the data decompression module zlib is not present. This is the exact error:

 Traceback (most recent call last):
  File "setup.py", line 94, in <module>
    scripts = scripts,
  File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/rohan/setuptools-0.6c11/setuptools/command/install.py", line 76, in run
    self.do_egg_install()
  File "/home/rohan/setuptools-0.6c11/setuptools/command/install.py", line 96, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/rohan/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 236, in run
    dry_run=self.dry_run, mode=self.gen_header())
  File "/home/rohan/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 527, in make_zipfile
    z = zipfile.ZipFile(zip_filename, mode, compression=compression)
  File "/usr/local/lib/python2.7/zipfile.py", line 651, in __init__
    "Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module

Also when i try to use setuptools 2.7 .egg, it gives this error:

Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available

Source: (StackOverflow)

Facing some issues regarding tomcat startup and shutdown on ubuntu 10.04

I am facing some issues regarding tomcat startup and shutdown.

I am using

  1. Tomcat v.6.0.32 (using the extracted the bundle downloaded from Apache website and not the one distributed by Ubuntu 10.04)
  2. Ubuntu v.10.04

I start the tomcat using command:

$./catalina.sh jpda start

Then I try to stop it using command:

$./catalina.sh stop

and get the following message:

SEVERE: Catalina.stop: 
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:189)
    at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:422)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)

I also tried stopping it using command :

$./catalina.sh stop -force

but I got the message:

Kill failed: $CATALINA_PID not set

Then I again tried starting tomcat using command:

$./catalina.sh jpda start

In the /logs folder only catalina.out is generated with following error message:

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

As it is indicated in the error "Address already in use" I verified no other application is configured to run on port 8080. Everytime when I kill the process id and restart it, the startup works fine.This requires me to kill the process manually using "KILL" command, when I need to stop the tomcat server. This same behavior I am encountering on other machines too where same environment as mentioned above is set up.

Can anybody please let me know what is causing this and how to resolve this?

Thanks,
Jignesh


Source: (StackOverflow)

Ruby on Rails MySQL #08S01Bad handshake - downgrade MySQL?

We recently upgraded from MySQL 5.1.41 to 5.1.61 on our Ubuntu 10.04LTS server. We have an ancient RoR web app that's now giving a bad handshake error:

Mysql::Error in MainController#index

#08S01Bad handshake

/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/vendor/mysql.rb:523:in `read'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/vendor/mysql.rb:153:in `real_connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389:in `connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:152:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:82:in `mysql_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:262:in `connection_without_query_cache='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/query_cache.rb:54:in `connection='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:230:in `retrieve_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:763:in `columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:2060:in `attributes_from_column_definition_without_lock'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/locking/optimistic.rb:45:in `attributes_from_column_definition'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1502:in `initialize_without_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:225:in `initialize'
#{RAILS_ROOT}/app/controllers/application.rb:48:in `new'
#{RAILS_ROOT}/app/controllers/application.rb:48:in `log_info'
/usr/local/bin/mongrel_rails:19:in `load'
/usr/local/bin/mongrel_rails:19

I googled around and stumbled onto http://bugs.ruby-lang.org/issues/5017 which tells me it's a Ruby MySQL extension bug. We aren't using the MySQL gem. Our web app is incredibly old and fragile (Ruby v1.8.7, Rails v1.2.3, Mongrel 1.1.5). We're in the process of replacing it with a Django rewrite, so we just need to get this functional for the next few weeks until we will replace it with the new site.

How can we get past this error? I'm thinking that downgrading to MySQL 5.1.41 is the best way to handle this, and then when we begin using the new site in a few weeks, we can re-upgrade to 5.1.61. However, I'm having an issue downgrading mysql. This is the command I'm using:

sudo aptitude install mysql-server-5.1=5.1.41-3ubuntu12.10

However, this tells me Unable to find a version "5.1.41-3ubuntu12.10" for the package "mysql-server-5.1". I've tried sudo aptitude install mysql-server-5.1=5.1.41 also, but that didn't work either. How can I have aptitude install the correct version of MySQL?


Source: (StackOverflow)