How to save command line activities to the log file in Linux

October 28, 2012 Leave a comment

If you have a need to record your command line session to the log file, this can be easily done with script command ( man script for details ).

Basic usage is, start terminal, type

$ script path_of_log_file

Then after that, everything you type and everything that is returned as a result of a commands is written to the log file.

To stop the recording, press crtl+d.

If you want to append more commands and results to the same file, type

$script -a path_of_log_file

Very handy command for system administration tasks.

Fedora 17 automount ntfs drives

July 13, 2012 2 comments

NTFS partitions aren’t mounted at startup in Fedora 17. If you want to mount drives at boot time, you can either modify fstab file ( /etc/fstab ) or you can do it from GUI with Disks utility.

Fstab is system configuration file that has informations about all the discs and disc partitions in one’s system, and also how they should be mounted and integrated in your system. Fstab provides information about disc or partition name, where it will be mounted, type of filesystem, and several mount options(permissions, read-write access and so on). For further information about fstab, try – man fstab in console.

So one option for automount NTFS is to edit /etc/fstab file, and add your partitions and disks.

Other is to do this with Disks program through GUI interface.

Start Disks program, click on partition that you want to mount, click more actions and then Edit Mount Options.

Turn off Automatic Mount Options. Mount on startup option should be enabled by default.

And after reboot, your partitions and drives will be automounted, and you can access them without password.

Categories: Linux Tags: , , , , ,

Fix ORA-12519: TNS:no appropriate service handler found(followed by ORA-00020)

June 12, 2012 Leave a comment

So you got ORA-12519 error when you try to connect to Oracle database. Oracle documentation for this error is

ORA-12519: TNS:no appropriate service handler found

Cause: The listener could not find any available service handlers that are appropriate for the client connection.

Action: Run “lsnrctl services” to ensure that the instance(s) have registered with the listener, and are accepting connections.

But lsnrctl services shows no errors and everything is working ok, so why can’t you get connected today when yesterday you could?

One of the reasons is that your database reached maximum of allowed connections/processes, and therefore listener is blocking incoming connections. This can be confirmed if you find this in your database logs.

ORA-00020: maximum number of processes (%s) exceeded

Solution is to increase number of processes in your database.

Connect with SYS user through SqlPlus.

Execute these 5 commands to solve the problem.

1) show parameter processes;

2) alter system set processes=150 scope=spfile;

3) shutdown immediate;

4) startup;

5) show parameter processes;

1) – to see current number of maximum processes

2) – change system settings and increase number of processes ( I will explain some other time what spfile is and what it’s used for )

3) – you must shutdown database for changes to take effect ( for some changes you don’t have to restart database, and for some you must, again this is a subject for some other post )

4) – startup database

5) – check if everything is ok now, is number increased

And now the problem is solved, but why did it happen in the first place?

There are several reasons, like a lot of idle connections, growth of users in your business system, programming bug, or all of this mixed together. 🙂

Hope this helps…

*note – 150 is just a number used for example

SqlPlus command line history in Linux OS

May 19, 2012 Leave a comment

SqlPlus is Oracle command line client tool, suitable for basic database administration, executing SQL commands and scripts. In rpm based Linux systems, like Red Hat, Oracle Linux or CentOS, you will need to install rlwrap package in order to enable history of your executed commands in SqlPlus console.

1. Download rlwrap package from http://rpm.pbone.net/ site( in search field, type rlwrap ), or some other resource.

2. Install it like root user with rpm -ivh rlwrap( here type name of the package you downloaded ).

3. Make alias in .bachrc profile of user that will be using SqlPlus.
gedit /home/your_user/.bachrc
Add this line to the file
alias sqlplus=”rlwrap sqlplus”

4. Initialize .bashrc file with command
. .bashrc

5. Login with SqlPlus to your database and you should have history of commands enabled. Arrow up or down will show history.

Categories: Oracle Tags: , , , , ,

How to fix Unity 3d in Ubuntu 12.04 from wrong Compiz settings

May 17, 2012 Leave a comment

Unity is Compiz plugin. It gives shell to the user session(panel, launcher and dash). Other plugins manage windows and other cool things in session, like cubes for example.

Rememebr, Unity depends of Compiz settings a lot.
If you make wrong choice with Compiz settings you may get what I got, a broken Unity 3D session, with only wallpaper and nothing else.
What I wanted to try, is to enable desktop cube to give it a spin.

So I installed Compiz Settings Manager ( notice that this package is not part of default Ubuntu installation ) and set up cube. But it didn’t work.
Suddenly, my Unity was broken. I tried to logout and login, restart Unity and nothing happened. I was only abled to login into default Gnome session.
I checked my Ati driver and it was ok. I executed

/usr/lib/nux/unity_support_test -p

to check again and everything was ok. Unity 3d supported, all settings were labeled as yes.

~$ /usr/lib/nux/unity_support_test -p
OpenGL vendor string:   ATI Technologies Inc.
OpenGL renderer string: AMD Radeon HD 6700 Series
OpenGL version string:  4.2.11627 Compatibility Profile Context

Not software rendered:    yes
Not blacklisted:          yes
GLX fbconfig:             yes
GLX texture from pixmap:  yes
GL npot or rect textures: yes
GL vertex program:        yes
GL fragment program:      yes
GL vertex buffer object:  yes
GL framebuffer object:    yes
GL version is 1.4+:       yes

Unity 3D supported:       yes

So apart from reinstalling system or graphics driver( just kidding ) what is the other solution to this problem?

 
To reset all settings to default. Both Unity and Compiz.

For Unity, type in console

unity –reset

if you can login to other session.

If not, press ctr+alt+t and start console.
This command reset Compiz to default settings, but you must logout from current session first and login again.

This can be done also if you type ccsm in console, it starts Compiz Settings Manager. Then, check all of this settings:

 

  •     Composite
  •     Gnome Compability
  •     OpenGL
  •     Desktop Wall
  •     Expo
  •     Ubuntu Unity Plugin
  •     Viewport Switcher
  •     Window Decoration
  •     Png
  •     Bailer
  •     Compiz Library Toolbox
  •     Detection
  •     Mouse position polling
  •     Regex Metching
  •     Session Menagment
  •     Workaraunds
  •     Grid
  •     Place Windows
  •     Move Window
  •     Resize Window
  •     Scale
  •     Static Application Switcher
  •     Window Rules

Logout and login again and Unity 3d should be fine.

How to move /home directory to another partition

May 14, 2012 1 comment

If you’re doing upgrade of your Linux system, or reinstalling your system after broken upgrade, having /home directory in another partition can save you a lot of time, because all of your settings and files will be saved for later use.

You can tell your distribution to keep your home directory when you do manual partitioning, by mounting your /home, but don’t format it.

In this article, I used Ubuntu 12.04 and GParted tool for partitioning.

First, with GParted, create  a new partition ( for example dev/sda/2 with ext3 format ).

Then, open terminal and edit fstab( file system table -there you will usually find all disks and partitions of your system ).

sudo gedit /etc/fstab

Add this line at the end of the file.

/dev/sda2 /home ext3 defaults 0 2

Copy all of your important files from current /home to new /home folder.

Reboot and that is it, your system is up with /home mounted on new partition.

So, what /dev/sda2 /home ext3 defaults 0 2 really mean?

/dev/sda2 -partition to be mounted

/home – mount point

ext3 – file system type of partition

defaults – default mount options ( rw, suid, dev, exec, auto, nouser, async )

0 -this column can be 0 or 1. If 1, dump utility will make backup, but most users don’t use that, so we use 0.

2 – used by fsck( file system check utility ), can be 0, 1 or 2. 0 means don’t check, /root should always be 1, and other partitions 2.

Categories: Linux Tags: , , , ,

Install SqlDeveloper and Java JDK in Oracle Linux 6

April 22, 2012 Leave a comment

To access and manipulate your data in Linux environment, you can use SqlPlus or SqlDeveloper, both tools provided by Oracle.

SqlPlus comes with database installation, it is suitable for running scripts, execute basic SQL statements or some administrative work. On some servers you don’t have GUI, so it is very important to know how to use it, but I will write about SqlPlus some other time.

Meanwhile, let’s set up SqlDeveloper for work. First, download it from Oracle web site. It requires JRE or JDK on host computer to run, but Linux bundle does not come with JDK, so download it as well.

So we must first set up Java in order to install and run SqlDeveloper.

For installing Java, make that file executable by becoming root and type

# chmod a+x jdk-6u<your_downloaded_version>rpm.bin
#./jdk-6u<your_downloaded_version>rpm.bin

Check your default Java installation

# /usr/sbin/alternatives –config java

If latest Java installation is not avaliable, you must update alternatives with

# alternatives –install “usr/bin/java” “java” “/usr/java/jkd1.6.0_<your_version>/bin/java” 2

Note that number 2 means that this Java installation will be shown as second when you run config java( if you have icedtea or open jdk for example, if not, type 1 ).
Now, check again Java with

# /usr/sbin/alternatives –config java

And select new JDK as default.
After that you shouldn’t have any problems in launching SqlDeveloper.

From the console run

# rpm -Uvh sqldeveloper_<your_downloaded_version>.rpm

SqlDeveloper will be installed in /opt/ directory, and you will have a new menu, Programming from where you can start it.

And this is it, now you have virtual machine with Oracle Linux 6, 11g XE, Java and SqlDeveloper installed an running.

Install Oracle 11g XE release 2 in Oracle Linux 6

April 22, 2012 Leave a comment

After installation of Oracle Linux 6, next step is to install Oracle 11gXE release 2.
So go to the Oracle web site and download database.
Before installing, unzip downloaded archive.
In console, type unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip ( or other, based on your system architecture ).
Become root ( type su in console and provide root password ), and type

#rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm

Then, in console, installation will display its progress.
Also as root, run the command when first step is done.

# /etc/init.d/oracle-xe configure

You will be asked to provide http port for Aplication Express ( default is 8080 ), port for database listener ( default is 1521 ), password for SYS and SYSTEM user and answer if you want database to be started on boot.
If you don’t want that, you can start database manually with command

# /etc/init.d/oracle-xe start

Or you can stop it with

# /etc/init.d/oracle-xe stop

This is the end of the configuration of your database.
You can login with sqlPlus from the console, or you can login from your web browser.

Notice that you’ll get new menu – Oracle Database 11g Express Edition in your application menu.

Before you can login from the console(gnome console, not console from the Oracle menu), you must set environment variables by editing your .bash_profile or .bashrc file.
Otherwise, you’ll get error – sqlplus:command not found.

You can add path to Oracle script ( add . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh ) or you can add path for the ORACLE_HOME, ORACLE_SID, NLS_LANG and PATH.
Add this to your profile

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export PATH=$ORACLE_HOME.bin:$PATH

Now, login from the console like SYS or SYSTEM and explore your database.
Remember, SYS and SYSTEM users are for database administration.
You don’t want to test scripts, drop tables and execute test queries with these users.
For that purpose, Oracle provided HR user for example.
This user is by default locked, so before using it, you must unlock this user and provide password.
Since we don’t have GUI tool installed ( SqlDeveloper for example), you can do it easy from the console.
Type

# sqlplus

When prompted for username type – system, and provide password you set up.
You should be connected to your database.
Type

# select username, account_status, password from dba_users where username=’HR’;

User is locked, so type

# alter user HR account unlock;

To unlock him, and type

# alter user HR identified by hr;

To set hr as password for user HR( or type something else if you wish ).
So now you can connect with hr user and explore it’s tables and data.

# select table_name from user_tables;

And you’ll see 7 database tables that you can play with( Regions, Locations and so on ).
Of course, you can create some other user if you wish, the rest is all on you. 🙂

Categories: Oracle Tags: , ,

Oracle Linux 6 on VirtualBox

April 21, 2012 Leave a comment

In this article and a few that will follow, i’m going to write about setting up an Oracle development and learning test machine.

OS, Oracle database and development tools i will install in a Oracle’s Virtual Box.
In a case when you don’t have several computers, virtual machines are the way to explore, learn and test new things, without fear of breaking your main system.

 
OS will be Oracle Linux 6, database is Oracle 11g XE release2, and there will be SqlDeveloper.

So here we go, first open Virtual Box and create new virtual machine.
You enter name for the machine, OS type and version and click next.

Now, it is time to select amount of RAM for virtual machine. It depends of your base RAM size, i will select 4GB od RAM(there are system requirements for database and OS, i will explain it fully later in a another post).

In this step hard disk for machine will be created. You can use existing or create new. I will create new hard disk in this step, an VDI image.
Hard disk can be dynamically allocated or it can be fixed size. I will choose fixed size and go to the next step.
In this step we choose size for hard disk. 20 GB should be enough for testing and development purpose.Next step is summary of your virtual machine, click on create button will create it.
It is time to download from Oracle website Oracle Linux6, and after that, select your virtual machine and click settings.
In Storage menu, add Linux iso to your cd/dvd drive.

Start virtual machine. OS is booting from cd/dvd drive, and you will see Oracle Linux boot menu.
Select install or upgrade an existing system to install OS to virtual hard drive.

We will not test the media, so we’ll choose skip at this part.

On next screen, choose next.

In this screen, choose language that you would like to use during the installation process. I will choose English.

Choose keybord for the system. I’ll choose U.S. English.
Next step is to choose the type of devices for your installation. For this purpose, it will be Basic Storage Devices, so leave it default and go ahead.

Since this is a fresh install, we will choose Yes discard any data and go to the next step.

This is a section where we’ll configure network settings. Host name can be your specific or default. After that click on configure network.

Next, configure your time zone.
This is a part where you provide root password for your system.
If it is a weak password, you’ll get warning, but since this is a test machine, it can be weak.

In this section, you choose type of installation and partitions of hard disk.

You can use all space of virtual hard drive, replace existing Linux system, shrink current system, use free space or you can manually partition hard disk by choosing Create Custom Layout.
I will choose manual partitioning.
We’ll create boot and swap partition in this step. Oracle’s system requirements for 11g XE can be seen on this page http://docs.oracle.com/cd/E17781_01/install.112/e18802/toc.htm
RAM, minimum is 256MB, disk space 1.5GB minimum and swap’s minimum is 2GB, of twice the size of RAM. So i’ll choose 4GB for swap partition, and 16GB for boot and home partitions.

All that we have done so far is setting up the basic server installation.

It means we don’t have GUI interface, and we have only a minimum of other tools, but enough to keep our OS and database running. In this step we can choose what other packages we want to install.

We can choose between basic server ( this will be our server setting ), database server, web server and so on.

In this step we can add additional software repositories, and we can choose to customize selection of our software installation, by clicking Customize now radio button. If you aren’t familiar with console work, i’ll suggest that you install Gnome desktop and other useful administration and development tools.

In this step check out all additional software that you want on your server. I will add Gnome desktop, Ecmas and a few other useful tools.

And now, your Oracle Linux 6 installation begins.
Reboot and login to Oracle Linux.

After you accept license information, you can choose to connect to ULN ( Unbreakable Linux Network ) or you can choose to connect later, which is what i did.

It is time to create user for everyday work.

Adjust date and time settings, accept default setting for Kdump and login to your Oracle Linux 6.

Next step, disable the firewall, by clicking to System->Administration->Firewall.
Click Close button, provide root password, click Close and Apply button.
Status of the Firewall will be disabled.

Next, disable SeLinux.
Edit /etc/selinux/config file, and set SeLinux flag like SELINUX=disabled.
You must do this as root user.
alt+f2, type gnome-terminal and start console.
Type “su”, provide root password and type “/etc/selinux/config”.
In Gedit editor change SeLinux flag and save file.
Type “reboot” in console.

 

You can add Oracle Linux 6 repository to install new packages if you want and if you need them.
Type “su” in console, and then
# cd /etc/yum.repos.d
# wget http://public-yum.oracle.com/public-yum-ol6.repo

 
You can enable repository that you need, by editing yum configuration file as root(/etc/yum.repos.d/public-yum-ol6.repo), and change flags enabled=0 to enabled=1.

 
And this is pretty much all to do in this step.
Next is to install Oracle 11g XE release 2.

 

Hope this will help somebody someday. 🙂

Ubuntu 11.10 and Realtek RTL8111/8168B network problems

April 15, 2012 Leave a comment

I was big fan of Ubuntu distro, since 8x versions, but since 11.04 and Unity interface, I had to remove it from my home pc because my graphic card was old and I couldn’t run Unity or Gnome 3. So, in the meanwhile, I got brand new pc, and I installed Ubuntu 11.10 a few days ago.

First thing that i noticed was that  i got disconnected from the Internet every few minutes. Also, connection was really really slow. It is really annoying of course. So whats’ the solution for this problem?

First, check the model number of your ethernet controller, run from the console

lspci | grep Realtek
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

Check the driver your kernel is loading(actually this is the problem, it loads 8169 instead of 8168).

lsmod | grep r816*
r8169                  52788  0

I downloaded the driver with the command

wget http://r8168.googlecode.com/files/r8168-8.026.00.tar.bz2

Next, run these commands

cd ~/Downloads
tar vjxf r8168-8.026.00.tar.gz cd r8168-8.026.00
sudo ./autorun.sh

And if you are using kernel 3.0.x, you should pay attention that /src/Makefile has a bug, so file r8168.o is installed instead of r8168.ko. When autorun.sh finishes, run command

sudo cp src/r8168.ko   /lib/modules/3.x(your current kernel path)/kernel/drivers/net/

sudo depmod

sudo modprobe r8168

And that’s it, after this tweak, my network is flying, without breaking every few minutes. I really don’t get it how this bug has been around so long?

 

Categories: Linux