Monday, November 23, 2009
create pipes in Redhat
mknod fifo_file p
ls -ltr file_file
------tty 1----------
echo passing this line >> /tmp/fifo_file
------tty 2----------
cat < /tmp/fifo_file
create a new partition in Redhat
p - print the partition table
n - create new partition
[Enter] to accept the default starting cyclinder
+20M
w - update the partition table
restart or type partprobe to use the new partition
mkfs.ext3 /dev/sda7
mount /dev/sda7 /mnt
umount /mnt
Friday, November 20, 2009
open crontab -e in vi editor
export EDITOR
Now, crontab -e will open a vi editor for me. :-)
Runlevels in redhat linux
- 0 — Halt
- 1 — Single-user mode
- 2 — Not used (user-definable)
- 3 — Full multi-user mode
- 4 — Not used (user-definable)
- 5 — Full multi-user mode (with an X-based login screen)
- 6 — Reboot
How to register an ActiveX control (.ocx) manually
Regsvr32 [/u] [/s]
Note
/u means Unregister the .ocx file.
/s means Silent Mode (display no messages).
Ref http://support.microsoft.com/kb/146219
Tuesday, September 15, 2009
notepad trick #1
If you press F5 in notepad, it will insert current date and time in the file. I think most of us know about this notepad trick. It is also mentioned in the Edit menu of the notepad.
Notepad isn't really that bad. It also has a few tricks. For instance, if you want to insert the time and date, simply hit F5. Or, if you want to "log" the times you edit a particular text file, be sure to type: ".LOG" (without the quotes) as the first line of that file and save it. Now every time you open it up, the current date and time will be automatically stamped into it.
Thursday, July 30, 2009
adding users in Ubuntu
Ubuntu Server is like any Linux variety, and has full multi-user capabilities, and a common task on any server is adding users.
useradd
The useradd command will let you add a new user easily from the command line:
useradd <username>
This command adds the user, but without any extra options your user won’t have a password or a home directory.
You can use the -d option to set the home directory for the user.
The -m option will force useradd to create the home directory.
We’ll try creating a user account with those options, and then use the passwd command to set the password for the account.
You can alternatively set a password using -p on the useradd command,
but I prefer to set the password using passwd.
sudo useradd -d /home/testuser -m testuser
sudo passwd testuser
This will create the user named testuser and give them their own home directory in /home/testuser. The files in the new home directory are copied from the /etc/skel folder, which contains default home directory files. If you wanted to set default values for your users, you would do so by modifying or adding files in that directory. If we take a look at the new home directory for the user:
jerome@krymz-laptop:/etc/skel$ ls -la /home/testuser
total 20
drwxr-xr-x 2 testuser testuser 4096 2006-12-15 11:34 .
drwxr-xr-x 5 root root 4096 2006-12-15 11:37 ..
-rw-r–r– 1 testuser testuser 220 2006-12-15 11:34 .bash_logout
-rw-r–r– 1 testuser testuser 414 2006-12-15 11:34 .bash_profile
-rw-r–r– 1 testuser testuser 2227 2006-12-15 11:34 .bashrc
You’ll notice that there are bash scripts in this directory. If you wanted to set default path options for all new users, you would do so by modifying the files in /etc/skel, which would then be used to create these files by the useradd command.
adduser
The adduser
command is even easier than the useradd command,
because it prompts you for each piece of information.
I find it slightly funny that there are two virtually identically named commands that do the same thing, but that’s linux for you.
Here’s the syntax:
adduser <username>
Example:
jerome@krymz-laptop:/etc/skel$ sudo adduser zionuser:
Adding user `zionuser’…
Adding new group `zionuser’ (1004).
Adding new user `zionuser’ (1004) with group `zionuser’.
Creating home directory `/home/zionuser’.
Copying files from `/etc/skel’
Enter new UNIX password:
Retype new UNIX
password: No password supplied
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for zionuser
Enter the new value, or press ENTER for the default
Full Name []: zioner
Room Number []: 0
Work Phone []: 555-1212
Home Phone []: 555-1212
Other []:
Is the information correct? [y/N] y
Saturday, May 16, 2009
Solaris: Shell script to write output to a file
#!/bin/sh
echo "Retrieve id"
FILE="/tmp/tempid"
MAXID=0
if [ ! -f $FILE ]; then
echo "$FILE : deos not exist"
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE : can not read"
exit 2
fi
# read $FILE using the file descriptors
exec 3<&0 #save standard input
exec 0<$FILE
while read line
do
MAXID=$line
done
#
# Query
#
sh -c "sqlplus etc ................ <
spool /tmp/temp.csv
Friday, May 15, 2009
Check Oracle Version
There are several ways where you can query or retrieve the version number of installed Oracle products:
1. If you just want to check the version information of the Oracle database, simply connect and login to the Oracle database with SQL *Plus. Upon login, you will see:
SQL*Plus: Release 9.2.0.6.0 - Production on Tue Oct 18 17:58:57 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
The first italic number is the version of the SQL*Plus client and the second italic number is the version of Oracle database which you are connected to .
2. Retrieve the version information from v$version table by using SQL*Plus. In this table you can find version information on Oracle, PL/SQL, etc.
To retrieve the version information for Oracle, you execute the following SQL statement:
select * from v$version where banner like ‘Oracle%’;
It should return something like this:
Banner
————————————————————————————–
Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
3. Version information can also be checked from Installed Products from the Oracle Universal Installer. It will tells you what products is installed on the machine and also its version information too.
In Unix, the installer is located at $ORACLE_HOME/bin/runInstaller.
In Windows, access the installer by Start -> All Programs -> Oracle Installed Products -> Universal Installer.
renaming multiple files in Solaris
for i in `ls *.log`;do
mv $i $i.bak
done
That would do each one individually but loop through the 3 files so you only have to do the one command.