7 February 2018

APACHE - If application path differs from DocumentRoot

If you are given a requirement where the application path does not reside in the default DocumentRoot defined in the apache config, then do this.

Define your Alias in httpd.conf. This is done in Apache on Windows server which is similar
if you are on Linux server - need to define your path accordingly.

    Alias "/{app-name}" "C:\{app-path}"
    <Directory "C:\{app-path}">
    Require all granted
    </Directory>

Save it and restart apache services. 




APACHE - Redirect URL containing an IP address to domain name

[On]
Red Hat Enterprise Linux Server release 7.4 (Maipo)

Please insert the Rewrite conditions as follows in the .htaccess file located in your DocumentRoot directory.

--- Change the IPs accordingly. ---

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^10\.24\.19\.85$ [OR]
    RewriteCond %{HTTP_HOST} ^10\.24\.19\.109$
    RewriteRule ^(.*)$ https://{DOMAIN_NAME}/$1 [L,R=301]
</IfModule>

6 February 2018

AIX - To clear print queue and restart qdaemon

# enq -sAW

# ps -eaf | grep {queue name}
# kill -9 {queue name}

# cd /var/spool/lpd/qdir
# remove all queues

# cd /var/spool/lpd/stat
# remove the specified queue entry

# stopsrc -s qdaemon
# startsrc -s qdaemon

ORACLE - Kill session

You plan to work on a schema or to drop a schema and Oracle throws you a warning saying Schema is in use. What do you do?

SQL> select sid, serial# from v$session where username='{your-schema}';

Please observe the sid, serial# from the output, then proceed to kill the session with 

SQL> alter system kill session 'sid,serial#';

You can rerun the select statement again to verify the specific schema has been removed. 

21 March 2013

ORACLE - Show errors

To identify compilation errors in triggers and procedures

SQL>show errors trigger UT_AUTONUMUPD;

LINE/COL ERROR
-------- ---------------------------------------------------------------
1/14     PL/SQL: Statement ignored
1/14     PLS-00905: object MY_GPAUTONUMLOG is invalid

* MY_GPAUTONUMLOG is a procedure


SQL>show errors procedure MY_GPAUTONUMLOG;
Errors for PROCEDURE MY_GPAUTONUMLOG:

LINE/COL ERROR
-------- -----------------------------------------------------------------
1/1507   PL/SQL: SQL Statement ignored
1/1519   PL/SQL: ORA-00942: table or view does not exist


Check the procedure MY_GPAUTONUMLOG procedure.

18 March 2013

LINUX - Booting Procedure


How Linux Boot?
1. BIOS
2. MBR
3. GRUB
4. Kernel
5. Init
6. Runlevel

System Startup 


How computer startup?

  • Booting is a bootstrapping process that starts operating systems when the user turns on a computer system.
  • A boot sequence is the set of operations the computer performs when it is switched on that load on operating system.
Booting sequence
1. Power on
2. CPU jump to address of BIOS (0xFFFF0)
3. BIOS runs POST (Power on Self Test)
4. Find bootable devices
5. Loads and execute boot sector from MBR
6. Loads OS

BIOS
  • BIOS refers to the software code run by a computer when first powered on.
  • The primary function of BIOS is a code program embedded on a chip that recognises and controls various devices that make up the computer.
Boot Loader

MBR (Master Boot Record)
  • OS is booted from a hard disk, where the Master Boot Record (MBR) contains the primary boot loader.
  • The MBR is a 512-byte sector, located in the first sector on the disk (sector 1 of cylinder0, head 0)
  • After the MBR is loaded into RAM, the BIOS yields control to it
  • The first 446 bytes are the primary boot loader, which contains both executable code and error message text
  • The next sixty-four bytes are the partition table, which contains a record for each of four partitions.
  • The MBR ends with two bytes that are defined as the magic number (0xAA55). The magic number serves as a validation check on the MBR.
Extracting the MBR
  • To see the contents of MBR, use this command:
    • dd if=/dev/hda of=/mbr.bin bs=512 count=1
    • od -xa mbr.bin
** The dd command, which needs to be run from root, reads the first 512 bytes from /dev/hda (IDE) /dev/sda (SCSI) and writes them to the mbr.bin file
** The od command prints the binary file in hex and ASCII formats

Boot loader could be more aptly called the kernel loader. The task at this stage is to load the Linux kernel. GRUB and LILO are the most popular Linux boot loader.

GRUB: Grand Unified Bootloader
  • GRUB is an operating system independent boot loader
  • A multiboot software packet from GNU
  • Flexible command line interface
  • File system access 
  • Support multiple executable format
  • Support diskless system
  • Download OS from network,  etc...
GRUB boot process
1. This BIOS finds a bootable device (hard disk) and transfers control to the master boot record
2. The MBR contains GRUB stage 1. Given the small size of the MBR, Stage 1 just load the next stage of GRUB
3. GRUB Stage 1.5 is located in the first 30 kb of hard disk immediately following the MBR. Stage 1.5 loads Stage 2
4. GRUB Stage 2 receives control and displays to the user the GRUB boot menu (where the user can manually specify the boot parameters)
5. GRUB loads the user-selected (or default) kernel into memory and passes control on to the kernel

Kernel

Kernel Image
  • The kernel is the central part in most computer operating systems because of it's task, which is the management of the system's resources and the communication between hardware and software components
  • Kernel is always store on memory until computer is turn off
  • Kernel image is not an executable kernel, but a compress kernel image
  • zImage size less than 512 kb
  • bzImage size greater than 512 kb
Task of Kernel
  • Process management
  • Memory management
  • Device management
  • System call
Init process
  • The first thing the kernel does is to execute init program
  • Init is the root/parent of all processes executing on Linux
  • The first process that init starts is a script /etc/rc.d/rc.sysinit
  • Based on the appropriate run-level, scripts are executed to start various processes to run the system and make it functional
The Linux Init Processes
  • The init process is identified by process id "1"
  • Init is responsible for starting system processes as defined in the /etc/inittab file
  • Init typically will start multiple instances of "getty" which waits for console logins which spawn one's user shell process
  • Upon shutdown, init controls the sequence and processes for shutdown
System Processes
Process ID 0 - The scheduler
Process ID 1 - The init process
Process ID 2 - kflushd
Process ID 3 - kupdate
Process ID 4 - kpiod
Process ID 5 - kswapd

3 November 2011

LINUX - How can I get my external router IP?

curl -s http://checkip.dyndns.org/ | cut -d ' ' -f 6 | sed s/"body\|html\|<\|>\|\/"//g

or just visit http://www.whatismyip.com/

Wordpress - Local installation in Vmware

If you're interested in exploring website design with WordPress, this guide will help you set up a WordPress instance on your local mach...