Can't find what you're looking for? Use of one of the search websites below …

HomeArchive by category "*nix"

Category Archives: *nix

Unix/Lunix operating system items.

Redhat Linux (Centos) Deployment Guide | Installation Guide | Books
Sun Solaris (10) System Administration Guide: Advanced Administration | System Administrator Books

awk

Awk dumps.

Count number of bytes in multiple directories

I have been busy moveing (scp-ing/reorganising) large numer of databases over the network, this little awk script makes me able to count the number of bytes and thus check if my nighlty scp’s didn’t miss a byte. (or two)

/cygdrive/c/oracle/oradata/DB01/DB01
$ find . -name "*DBF" -exec ls -l {} \;
-rwxrwx--- 1 Administrators SYSTEM 10493952 Oct  9 16:49 ./DB01/DATAFILE/O1_MF_TEST_3HSWQYNH_.DBF
-rwxrwx--- 1 Administrators SYSTEM 104865792 Oct  9 16:49 ./EXAMPLE01.DBF
-rwxrwx--- 1 Administrators SYSTEM 293412864 Oct  9 16:49 ./P1PERG001.DBF
-rwxrwx--- 1 Administrators SYSTEM 104865792 Oct  9 16:49 ./P1PERG002.DBF
-rwxrwx--- 1 Administrators SYSTEM 272637952 Oct 13 08:34 ./SYSAUX01.DBF
-rwxrwx--- 1 Administrators SYSTEM 513810432 Oct  9 16:49 ./SYSTEM01.DBF
-rwxrwx--- 1 Administrators SYSTEM 20979712 Oct 13 08:36 ./TEMP01.DBF
-rwxrwx--- 1 Administrators SYSTEM 47194112 Oct  9 16:49 ./UNDOTBS01.DBF
-rwxrwx--- 1 Administrators SYSTEM 5251072 Oct  9 16:49 ./USERS01.DBF
 
/cygdrive/c/oracle/oradata/DB01/DB01
$ find . -name "*DBF" -exec ls -l {} \; | awk '
> BEGIN { BYTES

ls

man: NAME: ls, ls – list directory contents

Display only directories in current directory
/cygdrive/c/temp $ ls -ld */
drwxr-xr-x+ 2 rz4tlj mkgroup-l-d 0 Sep 18 07:50 _backup_18-SEP-2007/
 
/cygdrive/c/temp $ 

mailx

man: NAME: mailx, mail – interactive message processing system

send file as attachment

Use uuencode to encode a file and pipe it to mailx to be send as attachment (when you quickly need a file on your desktop it’s faster then ftp…)

uuencode file to mailx
$ uuencode file.txt file.txt | mailx -s file.txt <your-email-address>
$ 

In my environment the -r flag (return address) is needed since my mailserver is blocking mail without a known email address reply header.

uuencode file to mailx with -r flag
$ uuencode file.txt file.txt | mailx -s file.txt -r <your-email-address> <your-email-address>
$ 

Download and Install of Java (JRE) on Centos

Here’s how I installed JDK on Centos (thanks to http://www.trading-shim.org/faq/?java)

Download

Go to http://java.sun.com/javase/downloads/index.jsp and download the desired file.

Extract the .bin file

[root@localhost tmp]# chmod 755 j2re-1_4_2_15-linux-i586-rpm.bin
[root@localhost tmp]# ./j2re-1_4_2_15-linux-i586-rpm.bin

Install the .rpm file

[root@localhost tmp]# rpm -Uvh j2re-1_4_2_15-linux-i586.rpm
Preparing...                ########################################### [100%]
   1:j2re                   ########################################### [100%]
 

Adjust environment

Finally add the path to the java executable in the /etc/profile file.

Test

$ java -version
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)

View symbolic links

In my environment a symbolic link is created in /usr/bin/java which points to /usr/java/default/bin/java.

$ which java
/usr/bin/java
$ ls -la /usr/bin/java
lrwxrwxrwx 1 root root 26 Jul 31 14:38 /usr/bin/java -> /usr/java/default/bin/java
$ ls -la /usr/java/
total 40
drwxr-xr-x  4 root root 4096

nohup

man: NAME: nohup – run a command immune to hangups

nohup and SQL*Plus

Nohup and SQL*Plus can be easily used together:

$ nohup sqlplus -s remi/remivisser @update.sql &
[4]     14433
$ Sending output to nohup.out
 
$
$
Prevent password from being displayed in the ps list
$ export password=remivisser
$ nohup sqlplus -s remi/${password} @update.sql &
[8]     16768
$ Sending output to nohup.out
$
$
 

  • / *nix
  • # 1258
  • AUG, 10 2007

yum

‘Everythin’ about yum – Yellowdog Updater Modified. Yum is an interactive, automated update program which can be used for maintaining systems using rpm.

Enable YUM behind a Proxy Server

To enable yum behind a proxy server add the http_proxy environment variable to you shell:

$ export http_proxy='http://<username>:<password>@<proxyserver>:<port>'
 

yum update

Below is the logging of a ‘yum update’ session.

[root@localhost ~]# yum update
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
base                      100% |=========================| 1.1 kB    00:00
updates                   100% |=========================|  951 B    00:00
addons                    100% |=========================|  951 B  

Centos 5.0 install fails, kernel panic

The following configuration is at place, VMWare Server (1.0.3) on Windows XP (host operating system). Installation of Centos 5.0 fails with kernel panic.

I can not get Centos 5.0 installed, I choose, Red Hat Enterprise Linux 4 as the ‘Guest Operating System’ the boot starts fine, but after a while the kernel panic errors appear and the install freezes.

Solution (workaround)

As I did not have the time to sort this one out, I downloaded a preconfigured VM Machine CentOS 5.0 server install from thoughtpolice.co.uk, http://www.thoughtpolice.co.uk/vmware/#centos5.0 (ziparchive is 399M, extracted it is 8G). This one is running stable now, thank you thought police! Saved my day.

Screen Captures

pipe

man: NAME: pipe – create an interprocess channel

import from compressed export file

Example below demonstrates how to import ‘directly’ from a compressed file. Handy when you have not enough space on your mountpoint to unpack the file.

mknod pipe_db01 p
 
zcat exp.dmp.Z > pipe_db01 &
 
sleep 3
 
imp / file=pipe_db01 ... 
 

Same as above but now for the other compression utilities.

(win)zip
unzip -p exp.dmp.zip > pipe_db01 &
gzip
gunzip < exp.dmp.gz > pipe_db01 &
 
gzip -cNf < pipe_db01 > exp.dmp.Z &
gunzip -c exp.dmp.Z > pipe_db01 &
cpio
cpio -icvdu < exp.dmp.cpio > pipe_db01 &

The other way around

Export to pipe and compress.

$ mknod c.pipe p
$ nohup compress < c.pipe > exp_DB01_2007-10-31.dmp.Z & 
$ nohup exp system/$(cat .pwd) file=c.pipe owner=inotime log=exp_DB01_2007-10-31.log & 
 

  • / *nix
  • # 1043
  • FEB, 7 2007

Configure telnet

Install and configure telnet on fresh Debian install

Install (download) telnet

Install telnet with the apt-get utility as shown below:

$ apt-get install telnetd

Configure telnet

Upon install the telnet server is enabled

$ cat /etc/inetd.conf

To start telnet server issue command below.

$ /usr/sbin/in.telnetd
$
$ netstat -a | grep telnet

find

man: NAME: find – find files

Find/Remove old files

Find files modified more then 365 days ago;

find . -mtime +365 -exec ls -l {} \;

Use touch to test

$ touch -t 197801130300 oldfile
$ find . -mtime +365 -exec rm {} \;
$ ls oldfile
ls: oldfile: No such file or directory