Tuesday, June 12, 2007

oracle command examples

Sometimes it takes me a while to look for the SQL command I need in Oracle. Just record something I got.
(1) displaying tables in a schema:
select * from user_tables;
(2) displaying column information for a relation:
describe wms_notif;
(3) check entries without corresponding entries in the other table:
select DG_ANALYSIS_MONITOR_ID from DG_ANALYSIS_MONITORwhere DG_ANALYSIS_MONITOR.DG_ANALYSIS_MONITOR_ID not in (select BAM_MONITOR_LAST_READING.DG_ANALYSIS_MONITOR_ID from BAM_MONITOR_LAST_READING);

Thursday, June 07, 2007

check local machine IP

I only got the loop address 127.0.0.1 when using "hostname -i".

So it's better to use "/sbin/ifconfig -eth0" with the root account.

Or "ip addr show".

Check this out: http://www.pixelbeat.org/cmdline.html

Issue related to Fedora 7 displaying mouse cursor

Sometimes with a fresh installation of Fedora, you'll not be able to see the mouse on the desktop. Here is an url invisible cursor in Fedora , which gives the information about how to solve it.

If you have just installed Fedora (or any other distro which uses xorg) you may have encounter the problem by which your cursor works, but you just can't see i: that is you have no cursor. The solution is fairly simple.
Open for editing the xorg config file as root. It is usually located at /etc/X11/xorg.conf . Locate the device section of the configuration file.
Add the following entry into the device section (on its own line):
Option "SWcursor" "True"
Restart the computer (or just xorg). Your problem should now be gone.

Friday, May 25, 2007

Checking out all the running process in Linux system

Everybody know that "ps" command can be used to find out the running processes in a Linux OS. But "top" is not so well-known as "ps". Sometimes it's a much better way to view all the processes, because it displays the information DYNAMICALLY!
I happened to find the article today: Show all running processes in Linux .

Here's the content:
ps command gives a snapshot of the current processes. If you want a repetitive update of this status, use top command.

Task: Use ps commandType the following ps command to display all running process
# ps aux less

Where,
-A: select all processes
a: select all processes on a terminal, including those of other users
x: select processes without controlling ttys

Task: see every process on the system
# ps -A
# ps -e

Task: See every process except those running as root
# ps -U root -u root -N
Task: See process run by user vivek
# ps -u vivek

Task: Use top command
The top program provides a dynamic real-time view of a running system. Type the top at command prompt:
# top
To quite press q for help press h.

Task: display a tree of processespstree shows running processes as a tree.
The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.

Task: Lookup process
Use pgrep command. pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen.
For example display firefox process id:
$ pgrep firefox
Following command will list the process called sshd which is owned by root user.
$ pgrep -u root sshd

Say hello to htop
htop is interactive process viewer just like top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs.
To install htop type command:
# apt-get install htopor
# yum install htop
Now type htop to run the command:
# htop

Monday, April 16, 2007

User Restriction on remote SSL connection

Here's the original source: OpenSSH Root user account restriction - revisited .

-- “I need something that allows me to say: allow any users except root from anywhere, and root only from localhost. (over ssh session)”.

PAM offers very powerful authentication control.
You need to use the pam_access PAM module, which is mainly for access management. It provides login access control based on Login names, Host or domain names, Internet addresses, or network IP numbers, Terminal line names etc.

Why pam_access matters?
On a production server, authorized login can come from any networked computer. Therefore, it is important to have tight control over users who are allowed to connect server via OpenSSH server.

How do I configure pam_access?
You need to edit following files:
/etc/pam.d/sshd - Linux PAM configuration file.
/etc/security/access.conf - By default rules for access management are taken from configuration this file. When someone logs in, the entry in this scanned and matched against rule. You can specify whether the login will be accepted or refused to user. General syntax is as follows:
permission : username: origins
Where,
permission : Permission field should be a “+” (access granted) or “-” (access denied)character.
username : Linux system username/login name such as root, yelei etc. You can also specify group names. You can also use special keywod ALL (to match all username).
origins : It is a list of one ore more tty names, host name, IP address, domain names that begin with . or special key words ALL or LOCAL Let us say you want to allow user root and yelei login from IP address 202.54.1.20 only.

Open file /etc/security/access.conf, and append following line:
-: ALL EXCEPT root yelei:202.54.1.20
Save the file and Open /etc/pam.d/sshd file, and append following entry:
account required pam_access.so
Save and close the file.

Thursday, April 12, 2007

Reload httpd.conf in Apache http server

Before reloading the httpd.conf file, you'd better use "apachectl configtest" to check if the conf file is valid.
According to "man apachectl":
apachectl restart - Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.
apachectl graceful - Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.
The 'graceful' would only be required if you are updating an active in-service machine and you do not want to interupt active connections.