Monday, 16 October 2017

Shutdown Modes

Shutdown modes are progressively more accommodating of current activity in this order:

ABORT: Performs the least amount of work before shutting down. Because this
requires recovery before startup, use this only when necessary. This is typically used
when no other form of shutdown works, when there are problems when starting the
instance, or when you need to shut down immediately because of an impending
situation, such as notice of a power outage within seconds.

IMMEDIATE: Is the most typically used option. Uncommitted transactions are rolled
back.

TRANSACTIONAL: Allows transactions to finish

NORMAL: Waits for sessions to disconnect
If you consider the amount of time that it takes to perform the shutdown, you find that
ABORT is the fastest and NORMAL is the slowest.

SHUTDOWN Options

SHUTDOWN NORMAL

Normal is the default shutdown mode. A normal database shutdown proceeds with the
following conditions:
• No new connections can be made.
• The Oracle server waits for all users to disconnect before completing the shutdown.
• Database and redo buffers are written to disk.
• Background processes are terminated and the SGA is removed from memory.
• The Oracle server closes and dismounts the database before shutting down the
instance.
• The next startup does not require an instance recovery.

SHUTDOWN TRANSACTIONAL

A transactional shutdown prevents clients from losing data, including the results from their
current activity. A transactional database shutdown proceeds with the following
conditions:
• No client can start a new transaction on this particular instance.
• A client is disconnected when the client ends the transaction that is in progress.
• When all transactions have been completed, a shutdown occurs immediately.
• The next startup does not require an instance recovery.

SHUTDOWN IMMEDIATE

Immediate database shutdown proceeds with the following conditions:
• Current SQL statements being processed by the Oracle database are not completed.
• The Oracle server does not wait for the users who are currently connected to the
database to disconnect.
• The Oracle server rolls back active transactions and disconnects all connected users.
• The Oracle server closes and dismounts the database before shutting down the
instance.
• The next startup does not require an instance recovery.

oracle startup modes and functions

Starting Up an Oracle Database Instance: NOMOUNT

When starting the database instance, select the state in which it starts. The following
scenarios describe different stages of starting up an instance.
An instance is typically started only in NOMOUNT mode during database creation,
during re-creation of control files, or during certain backup and recovery scenarios.
Starting an instance includes the following tasks:

• Searching <oracle_home>/dbs for a file of a particular name in this order:
- spfile<SID>.ora
- If not found, spfile.ora
- If not found, init<SID>.ora

This is the file that contains initialization parameters for the instance.
Specifying the PFILE parameter with STARTUP overrides the default
behavior.
• Allocating the SGA
• Starting the background processes
• Opening the alert<SID>.log file and the trace files

Starting Up an Oracle Database Instance: MOUNT

Mounting a database includes the following tasks:

• Associating a database with a previously started instance
• Locating and opening the control files specified in the parameter file
• Reading the control files to obtain the names and statuses of the data files and online
redo log files. However, no checks are performed to verify the existence of the data
files and online redo log files at this time.
To perform specific maintenance operations, start an instance and mount a database, but
do not open the database.
For example, the database must be mounted but must not be opened during the following
tasks:
• Renaming data files (Data files for an offline tablespace can be renamed when the
database is open.)
• Enabling and disabling online redo log file archiving options
• Performing full database recovery
Note: A database may be left in MOUNT mode even though an OPEN request has been
made. This may be because the database needs to be recovered in some way.

Starting Up an Oracle Database Instance: OPEN

A normal database operation means that an instance is started and the database is mounted
and opened. With a normal database operation, any valid user can connect to the database
and perform typical data access operations.

Opening the database includes the following tasks:
• Opening the online data files
• Opening the online redo log files
If any of the data files or online redo log files are not present when you attempt to open the
database, then the Oracle server returns an error.

During this final stage, the Oracle server verifies that all the data files and online redo log
files can be opened and checks the consistency of the database. If necessary, the System
Monitor (SMON) background process initiates instance recovery.

You can start up a database instance in restricted mode so that it is available to users with
administrative privileges only. To start an instance in restricted mode, select the “Restrict
access to database” option on the Advanced Startup Options page.

Sunday, 15 October 2017

Oracle database physical files

The files that constitute an Oracle database are organized into the following:

Control files: Contain data about the database itself (that is, physical database structure
information). These files are critical to the database. Without them, you cannot open data
files to access the data within the database.

Data files: Contain the user or application data of the database

Online redo log files: Allow for instance recovery of the database. If the database crashes
and does not lose any data files, then the instance can recover the database with the
information in these files.

The following additional files are important to the successful running of the database:

Parameter file: Is used to define how the instance is configured when it starts up

Password file: Allows users to connect remotely to the database and perform
administrative tasks

Backup files: Are used for database recovery. You typically restore a backup file when a
media failure or user error has damaged or deleted the original file.

Archive log files: Contain an ongoing history of the data changes (redo) that are generated
by the instance. Using these files and a backup of the database, you can recover a lost data
file. That is, archive logs enable the recovery of restored data files.

Trace files: Each server and background process can write to an associated trace file.
When an internal error is detected by a process, the process dumps information about the
error to its trace file. Some of the information written to a trace file is intended for the
database administrator, whereas other information is for Oracle Support Services.

Alert log files: These are special trace files. They are also known as alert logs. The alert
log of a database is a chronological log of messages and errors. Oracle recommends that
you review these files.

oracle background process

An Oracle database server consists of an Oracle database and an Oracle instance. An Oracle
instance is made up of memory structures, known as the System Global Area (SGA), and
background processes that handle much of the behind-the-scenes work involved in running an
instance. The most common background processes are the following:

System Monitor (SMON): Performs crash recovery when the instance is started following
a failure

Process Monitor (PMON): Performs process cleanup when a user process fails

Database Writer (DBWn): Writes modified blocks from the database buffer cache to the
data files on the disk

Checkpoint (CKPT): Updates all the data files and control files of the database to indicate
the most recent checkpoint

LogWriter (LGWR): Writes redo log entries to the disk

Archiver (ARCn): Copies redo log files to the archival storage when a log switch occurs

Server Process and Database Buffer Cache

When a query is processed, the Oracle server process looks in the database buffer cache for any
blocks that it needs. If the block is not found in the database buffer cache, the server process
reads the block from the data file and places a copy in the database buffer cache. Because
subsequent requests for the same block may find the block in memory, the requests may not
require physical reads. The Oracle server uses the least recently used algorithm to age out buffers
that have not been accessed recently to make room for new blocks in the database buffer cache.
Buffers in the buffer cache can be in one of the following four states:

Pinned: Multiple sessions are kept from writing to the same block at the same time. Other
sessions wait to access the block.

Clean: The buffer is now unpinned and is a candidate for immediate aging out, if the
current contents (data block) are not referenced again. Either the contents are in sync with
the block contents stored on the disk or the buffer contains a consistent read (CR) snapshot
of a block.

Free or unused: The buffer is empty because the instance has just started. This state is
very similar to the clean state, except that the buffer has not been used.

Dirty: The buffer is no longer pinned but the contents (data block) have changed and must
be flushed to the disk by DBWn before it can be aged out.

Oracle Memory Structures


The basic memory structures associated with an Oracle instance include the following:
System Global Area (SGA): Shared by all server and background processes.

Program Global Area (PGA): Private to each server and background process. There is
one PGA for each process.

The SGA is a memory area that contains data and control information for the instance.
The SGA includes the following data structures:

Database buffer cache: Caches blocks of data retrieved from the database

Redo log buffer: Caches redo information (used for instance recovery) until it can be
written to the physical redo log files stored on the disk

Shared pool: Caches various constructs that can be shared among users

Large pool: Is an optional area that provides large memory allocations for certain large
processes, such as Oracle backup and recovery operations, and I/O server processes

Java pool: Is used for all session-specific Java code and data within the Java Virtual
Machine (JVM)

Streams pool: Is used by Oracle Streams

When you start the instance by using Enterprise Manager or SQL*Plus, the amount of memory
allocated for the SGA is displayed.

Program Global Area (PGA) is a memory region that contains data and control information for
each server process. An Oracle server process services a client’s requests. Each server process
has its own private PGA that is created when the server process is started. Access to the PGA is
exclusive to that server process, and the PGA is read and written only by the Oracle code acting
on its behalf.

With the dynamic SGA infrastructure, the size of the database buffer cache, the shared pool, the
large pool, the Java pool, and the Streams pool changes without shutting down the instance.
The Oracle database uses initialization parameters to create and configure memory structures.
For example, the SGA_TARGET parameter specifies the total size of the SGA. If you set
SGA_TARGET to 0, Automatic Shared Memory Management is disabled.

How to drop oracle database

In this post we will see how to drop the oracle database.

1.connect sqlplus and shutdown the database.

 Shut immediate;

2.Once db down mount the database with restricted mode.

startup mount restrict;

3.Post that issue drop database command to drop the database.it will remove all db related files and clear the space for that database.

DROP DATABASE;


after drop the database remove the tns entries and listener entries in oracle home.

$ORACLE_HOME/network/admin/listener.ora
$ORACLE_HOME/network/admin/tnsnames.ora


oracle user and privilege backup before refresh.

While you  refresh dev database from prod the existing schema user password and privileges will be over write with prod data.So you will lose existing user password and privileges. In this post i will show how to take backup of those user password and privileges.

Before doing refresh run the below commands.it will give the ddl statements of user password and their privileges.

1.Take the user password ddl commands using below command.

select 'alter user'||' '|| name ||' '|| 'identified by values' ||' '|| ''''|| password ||''''|| ';' from user$
where name in ('SAMPLE','TEST'); 

2.Take the privileges ddl commands using below commands.


set pages 999;
select 'grant'||' '||PRIVILEGE||' to ' ||grantee||';' from dba_sys_privs where grantee in ('SAMPLE','TEST'); 

select 'grant'||' '||PRIVILEGE||' on ' ||owner||'.'||TABLE_NAME||' to '||grantee||';' from dba_tab_privs where grantee in ('SAMPLE','TEST');

select 'grant'||' '||GRANTED_ROLE||' to ' ||grantee||';' from dba_role_privs where grantee in ('SAMPLE','TEST');

3.Post refresh run those DDL statements to retrieve the old user passwords and privileges.

How to invoke vnc session

Vnc server software is used for invoke GUI display for linux\unix.

Once Vnc server installed on your server i will show how to connect vnc session form your windows using vnc viewer.

1.Login to the server where vnc got installed.

2.Set the vnc password using below command.

  [oracle@TEST1 ~]$ vncpasswd
  Password:
  Verify:

Once you gave vncpasswd command it will ask password.

3.Run the below command for start new vnc session.

[oracle@TEST1 ~]$ vncserver

New 'TEST1:3 (oracle)' desktop is TEST1:3

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/TEST1:3.log

4.Check the display id using below command.It will show the active seesions for vnc server.

[oracle@TEST1 ~]$ vncserver -list

TigerVNC server sessions:

X DISPLAY #     PROCESS ID
:3              46056
:2              45738

Here we can two vnc sessions are running.Now i will show how to invoke GUI on display id 2.
download vnc viewer software.Once you installed click on vnc viewer.


connection string is servername:displayid.

5.click connect icon it will ask vnc password give the vnc password before you set.

6.Once you provided password it will show your vnc session.

Thursday, 12 October 2017

ORA-27300 ORA-27301 ORA-27302 ORA-27157 Database Crash

Database instance crashed due to following errors:

ORA-27300: OS system dependent operation:semctl failed with status: 22
ORA-27301: OS failure message: Invalid argument
ORA-27302: failure occurred at: sskgpwrm1
ORA-27157: OS post/wait facility removed
ORA-27300: OS system dependent operation:semop failed with status: 36
ORA-27301: OS failure message: Identifier removed
ORA-27302: failure occurred at: sskgpwwait1

Cause:

The semaphores used by Oracle have been inadvertendly removed

The errors are signalling that something happened at the OS level with shared memory and/or semaphores. The semaphore sets could be removed manually, or they could be dying for some reason due to a hardware error.
Either when remounting the /dev/shm or You may want to check for any possibility of a user dba using the "ipcrm" command to kill the semaphores (accidentally) since the error ora-27301 (OS failure message: Identifier removed) suggests that. Also, it could have been a bad memory stick or something else at the OS level. Someone could also have removed the shared memory segments at the OS level for some specific reason, or by accident. Most likely something had removed the shared memory and semaphore sets in use by 'oracle'. This can only be done by a root-level user or 'oracle' itself who owns the resources. If someone logged in as root and removed all IPC resources, Oracle would crash when it lost the allocated shared memory/semaphores.

Solution :

In  RHEL7.2 operating system setting RemoveIPC=YES crashes the database.The default value for RemoveIPC in RHEL7.2 is YES.

1) Set RemoveIPC=no in /etc/systemd/logind.conf if it is not in that file

      2) Reboot the server or restart systemd-logind as follows:
       # systemctl daemon-reload
       # systemctl restart systemd-logind


Sunday, 12 February 2017

How to do oracle client silent installation without response file

Below are the steps for oracle client silent installation without response file.silent installation have advantages of reducing installation time and reducing the effort.When you have problem with GUI installation then silent installation best solution for you.

Unzip the client software:-

Download the software from oracle site and then unzip the software in desired location.

unzip linux.x64_11gR2_client.zip

 Once you extracted the file make sure you have oraInst.loc file.It will be on /etc folder if you don't have the file create new oraInst.loc file like below.

vi /etc/oraInst.loc
inventory_loc=/oracle/software/oraInventory
inst_group=dba

Client install:-

Run below command for client silent install.

./runInstaller -silent -debug -force \
FROM_LOCATION=/home/oracle/client/stage/products.xml \
UNIX_GROUP_NAME=oinstall \
ORACLE_HOME=/oracle/software/client/11.2.0 \
ORACLE_HOME_NAME="client11g_Home1" \
ORACLE_BASE=/oracle/software \
oracle.install.client.installType="Administrator"


Change the path as your desired location.once client got installed you will asked to run root.sh script.you have to run the script with root privilege.

The following configuration scripts need to be executed as the "root" user.
 #!/bin/sh
 #Root scripts to run

/oracle/software/client/11.2.0/root.sh
To execute the configuration scripts:
         1. Open a terminal window
         2. Log in as "root"
         3. Run the scripts
         4. Return to this window and hit "Enter" key to continue

Successfully Setup Software.

Thursday, 9 February 2017

How shutdown standalone asm instance in oracle


In this post we going to see how to bring down the standalone asm instance normally.Below are the sequences for the same.

First we need to bring down the databases.

[oracle@oracle ~]$ ps -ef|grep pmon
grid       3135      1  0 20:03 ?        00:00:00 asm_pmon_+ASM
oracle     3254      1  0 20:04 ?        00:00:00 ora_pmon_orcl
oracle     3696   3203  0 20:10 pts/0    00:00:00 grep --color=auto pmon
[oracle@oracle ~]$ sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 9 20:10:36 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit;
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
[oracle@oracle ~]$ ps -ef|grep pmon
grid       3135      1  0 20:03 ?        00:00:00 asm_pmon_+ASM
oracle     3714   3203  0 20:11 pts/0    00:00:00 grep --color=auto pmon


Now db has been down next switch to grid user and bring down the ASM instance with sysasm privilege.

[oracle@oracle ~]$ su - grid
Password:
Last login: Thu Feb  9 20:02:32 PST 2017 on pts/0
[grid@oracle ~]$ sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 9 20:13:24 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name: / as sysasm

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Automatic Storage Management option

SQL> shut immediate;
ASM diskgroups dismounted
ASM instance shutdown
SQL> exit;
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Automatic Storage Management option


Now check the status of cluster resources then bring down the all cluster resources.

[grid@oracle ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               OFFLINE OFFLINE      oracle                   STABLE
ora.DATA.dg
               OFFLINE OFFLINE      oracle                   STABLE
ora.FRA.dg
               OFFLINE OFFLINE      oracle                   STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle                   STABLE
ora.ORA_LISTENER.lsnr
               ONLINE  OFFLINE      oracle                   STABLE
ora.asm
               OFFLINE OFFLINE      oracle                   STABLE
ora.ons
               OFFLINE OFFLINE      oracle                   STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       oracle                   STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       oracle                   STABLE
ora.orcl.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.orcl1.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------
[grid@oracle ~]$ crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'oracle'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'oracle'
CRS-2673: Attempting to stop 'ora.evmd' on 'oracle'
CRS-2677: Stop of 'ora.evmd' on 'oracle' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'oracle'
CRS-2677: Stop of 'ora.cssd' on 'oracle' succeeded
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'oracle' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'oracle' has completed
CRS-4133: Oracle High Availability Services has been stopped.



How to enable the archivelog in oracle


                                                   Enabling archive log


Below are the steps for enabling the archive log.


Verify the log mode


[oracle@oracle dbs]$ sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 9 09:49:48 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     14
Current log sequence           16
Here archive log mode disabled for this database.


By default archive destination will be db recovery dest only.Now we need to bring down the database and then mount the same.


SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  754974720 bytes
Fixed Size                  2928968 bytes
Variable Size             578817720 bytes
Database Buffers          167772160 bytes
Redo Buffers                5455872 bytes
Database mounted.

 Now we enabling the archive log.


SQL> alter database archivelog;

Database altered.


after disable the archive open the database.


SQL> alter database open;

Database altered.


 Now check the log mode.it will be enabled mode.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     14
Next log sequence to archive   16
Current log sequence           16

How to disable archive log in oracle

                                                 Disabling archive log

Below are the steps for disabling the archive log.

Verify the log mode

[oracle@oracle dbs]$ sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Thu Feb 9 09:49:48 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     14
Next log sequence to archive   16
Current log sequence           16
 

Here  archive log mode is enabled for this database.

By default archive destination will be db recovery dest only.Now we need to bring down the database and then mount the same.

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  754974720 bytes
Fixed Size                  2928968 bytes
Variable Size             578817720 bytes
Database Buffers          167772160 bytes
Redo Buffers                5455872 bytes
Database mounted.


 Now we disabling the archive log.

SQL> alter database noarchivelog;

Database altered.


after disable the archive open the database.

SQL> alter database open;

Database altered.


 Now check the log mode.it will be disabled mode.

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     14
Current log sequence           16
























 

Wednesday, 8 February 2017

LVM(linux) -Logical volume manger for DBA with examples

                                  LVM(linux) -Logical volume manger for DBA 

In this post we going to see how below things.

  1. partition the new hard disk
  2. physical volume creation
  3. volume group creation
  4. logical volume creation
  5. filesystem creation
Partition the new hard disk:-

fdisk utility is used to partition the hard disks in linux.

run fdisk in root user.you can see something like /dev/sda /dev/sdb


[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Once new hard disk added means you can able to see new device in fdisk.I have added 20GB hard disk in server so you can see new hard disk with 20gb.


[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Here /dev/sdb is the newly added hard disk.we going to partition /dev/sdb.

[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

we are going to create new partition.so we need to give n option in command.linux alows only 4 partitions for one hard disk.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +19G
Partition 1 of type Linux and of size 19 GB is set

atlast give w command for write table to disk and exit.

Command (m for help): w
The partition table has been altered!


Now i have created new partition of hard disk to 19gb.

[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e73f232

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    39847935    19922944   83  Linux

Physical volume creation:-

To use disks in volume group label them as physical volume.

[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               oravg
  PV Size               19.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              4863
  Free PE               4863
  Allocated PE          0
  PV UUID               v4AYDI-gubj-5NXp-u9Cs-b6Fh-CU2r-k7Ta1z

Volume group creation:-

Create the a volume group that consists of the LVM physical volumes you have created.

[root@localhost ~]# vgcreate oravg /dev/sdb1
  Volume group "oravg" successfully created

Here i created volume group name as oravg

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               oravg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               19.00 GiB
  PE Size               4.00 MiB
  Total PE              4863
  Alloc PE / Size       0 / 0
  Free  PE / Size       4863 / 19.00 GiB
  VG UUID               UhJoJC-8Z3M-6gOj-e0zm-ZCuv-XWWP-2EHAoW

Physical volume creation:-

create the logical volume from volume group created.

[root@localhost ~]# lvcreate -L 15G -n orasoft oravg
  Logical volume "orasoft" created.


Here i created new physical volume with 15gb and named as orasoft

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/oravg/orasoft
  LV Name                orasoft
  VG Name                oravg
  LV UUID                GDqmKj-qdlR-4doR-ywvJ-Q6DN-u6pA-2JxaSA
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2017-02-08 09:07:49 -0800
  LV Status              available
  # open                 1
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

Filesystem creation:-

Create file system on logical volume

[root@localhost ~]# mkfs.xfs /dev/oravg/orasoft
meta-data=/dev/oravg/orasoft     isize=256    agcount=4, agsize=983040 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=3932160, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Mounting file system:- 

[root@localhost ~]# mkdir /orasoft
[root@localhost ~]# mount /dev/oravg/orasoft /orasoft
[root@localhost ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                  8.7G  1.7G  7.1G  19% /
devtmpfs                   480M     0  480M   0% /dev
tmpfs                      489M     0  489M   0% /dev/shm
tmpfs                      489M  6.7M  483M   2% /run
tmpfs                      489M     0  489M   0% /sys/fs/cgroup
/dev/sda1                  297M  113M  185M  38% /boot
tmpfs                       98M     0   98M   0% /run/user/0
/dev/mapper/oravg-orasoft   15G   33M   15G   1% /orasoft

 Comment me if you find this post is useful also let me know if you need any new topics.













How to do partition in linux\centos

                                  How to do partition in linux\centos

fdisk utility is used to partition the hard disks in linux.

run fdisk in root user.you can see something like /dev/sda /dev/sdb.


[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Once new hard disk added means you can able to see new device in fdisk.I have added 20GB hard disk in server so you can see new hard disk with 20gb.


[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Here /dev/sdb is the newly added hard disk.we going to partition /dev/sdb.

[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

we are going to create new partition.so we need to give n option in command.linux allows only 4 partitions for one hard disk.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +19G
Partition 1 of type Linux and of size 19 GB is set

atlast give w command for write table to disk and exit.

Command (m for help): w
The partition table has been altered!


Now i have created new partition of hard disk to 19gb.

[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bbb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     2713599     1048576   82  Linux swap / Solaris
/dev/sda3         2713600    20971519     9128960   83  Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e73f232

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    39847935    19922944   83  Linux

Comment me if you find this post is useful also let me know if you need any new topics.

Friday, 3 February 2017

AIX COMMAND GUIDE for DBA

                                                      


ls
- list files in directory; use with options
·         -l (long format)
·         -a (list . files too)
·         -r (reverse order)
·         -t (newest appears first)
·         -d (do not go beyond current directory)
·         -i (show inodes)
For a more detailed description of ls see ls -l
- used to control input by pages - like the dos /p argument with dir. e.g.
$ more /etc/motd *******************************************************************************
* *
* *
* Welcome to AIX Version 4.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
motd: END

Useful keys for use with more:
·         b (back a page)
·         ' (go to top)
·         v (vi the file)
·         / (Search)
·         q (quit)
·         ' ' (down a page)
·         Control-G (View current line number
·         <CR> (down a line)
See also pg which is extremely similar
pg
- used to control input by pages - like the dos /p argument. pg performs the same function as the more command but has different control, as it is based on ex
Helpful keys for pg:
·         1 (go to top)
·         $ (go to bottom)
·         h (help)
·         / (Search)
·         ? (Search back)
·         q (quit)
·         -1 (back a page)
pwd
- show present working directory. e.g.
$ pwd
/usr/live/data/epx/vss2

To change the current working directory use
cd
cd
- change directory (without arguments, this is the same as $ cd $HOME or $ cd ~)
cp
<source> <destination> - copies a file from one location to another. e.g.
$ cp /etc/hosts /etc/hosts.backup # make a backup of the hosts file
$ cp /etc/motd /tmp/jon/ # Copy file /etc/motd to directory /tmp/jon/

Options
·         -f (to force the copy to occur)
·         -r (to recursively copy a directory)
·         -p (to attempt to preserve permissions when copying)
synonym: copy
mv
<source> <destination> - move a file from one location to another. e.g.
$ mv /tmp/jon/handycommands.txt . # move handycommands in /tmp/jon to current directory
$ mv -f vihelp vihelp.txt # Move file vihelp to vihelp.txt (forced)

Options
·         -f (to force the move to occur)
·         -r (to recursively move a directory)
·         -p (to attempt to preserve permissions when moving)
synonym: move
.
rm
<filename> - removes a file. e.g.
$ rm /tmp/jon/*.unl # remove all *.unl files in /tmp/jon
$ rm -r /tmp/jon/usr # remove all files recursively
Options
·         -f (to force the removal of the file)
·         -r (to recursively remove a directory)
du
Recursively lists directories and their sizes. e.g.
$ du /etc # list recursively all directories off /etc
712 /etc/objrepos
64 /etc/security/audit
536 /etc/security
104 /etc/uucp
8 /etc/vg
232 /etc/lpp/diagnostics/data
240 /etc/lpp/diagnostics
248 /etc/lpp
16 /etc/aliasesDB
16 /etc/acct
8 /etc/ncs
8 /etc/sm
8 /etc/sm.bak
4384 /etc
The sizes displayed are in 512K blocks. To view this in 1024K blocks use the option -k
lp -d<Printername> <Filename>
send file to printer. e.g. $ lp -dhplas14 /etc/motd # send file /etc/motd to printer hplas14
$ lp /etc/motd # send file /etc/motd to default printer
cat
- print a file to stdout (screen). e.g.
$ cat /etc/motd # display file /etc/motd to screen
*******************************************************************************
* *
* *
* Welcome to AIX Version 4.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
cat is also useful for concatenating several files. e.g.
$ cat fontfile IN* > newfile # appends fontfile and all files beginning with IN to newfile
Though this might seem an essentially useless command, because most unix commands always take a filename argument, it does in fact come in extremely useful at more advanced levels.
Awards are given out occasionally for the most useless usage of cat. If an option of '-' is specified, cat will take its input from stdin.

Unix commands generally get their information from the screen, and output to it. There are three main 'streams' which unix uses to get/place it's information on. These streams are called:
·         stdin (Standard Input) - normally, what you type into the screen
·         stdout (Standard Output) - normally, what is output to the screen
·         stderr (Standard Error) - normally, error messages which go to the screen

any of these may be redirected by the following symbols:
·         < <filename> take input from <filename> rather than the screen. e.g.
$ ksh < x # will read all commands from the file x and execute them using the Korn shell.
·         > <filename> take output from the command and place it in <filename>. e.g.
$ ls > x will place the output of the command 'ls' in the file x
·         >> <filename> take output from the command and append it to <filename>. e.g.
$ ls /tmp >> x will place the output of the command 'ls' and append it to the file x
·         2> <filename> take any error messages from the command and put it in <filename>. e.g.
$ ls /tmp 2>/dev/null would throw away any error messages that are produced by ls (sorry, /dev/null is a file that, if written to, the information disappears never to be seen again).
·         command1 | command2 Pipe - Takes the standard output of the first command, and turns it into the standard input of the second command. The output of the second command will then be put on the standard output (which, again, may be a pipe) e.g.
$ ls | more will send the output of 'ls' into the command 'more', thus producing a directory listing which stops after every page. This method is called piping.

command1 & - the ampersand (&) forces command1 to run in the background. so that you may continue to type other commands in the shell, while command1 executes. It is not advisable to run a command in the background if it outputs to the screen, or takes it's input from the screen

See also
tee which allows splitting of the input stream and output to several different places at once.
B Bib Baby Fox Fib

There are various wildcards which you may use. One is '*' which means 0 or more characters. e.g. 'B*' will match 'B,Bib and Baby' from the list above, another wildcard is '?' which matches 1 character, e.g. '?ib' will match 'Bib and Fib'. Wildcards differ depending on the program in use:
awk derivatives (awk,sed,grep,ex,vi,expr and others) have the following special characters:
·         ^ beginning of the line
·         $ end of the line
·         . any character
·         * one or more of the preceding character
·         .* any number of characters
·         \n Carriage return
·         \t Tab character
·         \<char> Treat <char> as is (so, \$ would try to match a '$')
Given the following four lines:

Chargeable calls in bundle: $47.50
Chargeable calls out of bundle: $20.50
Other bundle charges: $0.00
Total Charge: $20.50

$ grep "^Charg.*bundle.*\$.*"
would match the first two lines.
In english - match all lines which start with 'Charg', then have any number of characters and then the word 'bundle', then have any number of characters, and then a dollar symbol, and then have any number of characters following to the end of the line

type <command>
- show where the source of a command is: e.g.
$ type sendmail
sendmail is /usr/sbin/sendmail

This command is merely an alias for '
whence -v'
whence <command>
- show where the source of a command is: shell builtin command. See type
Use option: -v for verbose mode
which <command>
- show where the source of a command is held. Almost the same as type and whence
chmod <Octal Permissions> <file(s)>
- change file permissions. e.g.
$ chmod 666 handycommands
changes the permissions (seen by
ls -l) of the file handycommands to -rw-rw-rw-
r = 4, w = 2, x = 1. In the above example if we wanted read and write permission for a particular file then we would use r + w = 6. If we then wanted to have the file have read-write permissions for User, Group and All, then we would have permissions of 666. Therefore the command to change is that above.
$ chmod 711 a.out
Changes permissions to: -rwx--x--x
Additional explanation of file permissions and user/group/all meaning are given in the description of
ls -l
You may specify chmod differently - by expressing it in terms of + and - variables. For example
$ chmod u+s /usr/bin/su
will modify the "sticky bit" on su, which allows it to gain the same access on the file as the owner of it. What it means is "add s permission to user". So a file that started off with permissions of "-rwxr-xr-x" will change to "rwsr-xr-x" when the above command is executed. You may use "u" for owner permissions, "g" for group permissions and "a" for all.
chown <Login Name> <file(s)>
- Change ownership of a file. Must be done as root. e.g.
chown informix *.dat # change all files ending .dat to be owned by informix
chgrp <Group Name> <file(s)>
- Change group ownership of a file. Must be done as root. e.g.
chgrp sys /.netrc # change file /.netrc to be owned by the group sys
mvdir <Source Directory> <Destination Directory>
- move a directory - can only be done within a volume group. To move a directory between volume groups you need to use mv -r
or
find <dirname> -print | cpio -pdumv <dirname2>; rm -r <dirname>
cpdir <Source Directory> <Destination Directory>
- copy a directory. See mvdir
rmdir <Directory>
- this is crap - use rm -r instead
mkdir <Directory>
- Creates a directory. e.g.
$ mkdir /tmp/jon/ # create directory called /tmp/jon/
find <pathname> -name "searchkey" -print
- search for files - e.g.
$ find . -name "system.log" -print # will find all files (with full path names) called system.log - Wildcards are allowed, e.g.
$ find /tmp -name "sl.*" -atime +0 -print # will print out all files in /tmp/ that start sl. and which haven't been accessed for a day. Helpful for finding lost files, or finding stuff in enormous directories. Other useful options include:
·         -atime +<days> - finds files that haven't been accessed for 1+days also, ctime (creation time) and mtime (modify time)
·         -prune - stay in current directory - don't look in dirs off the directory specified in path names - e.g.
$ find /tmp -user "compgnc" -prune -print # will find all files in /tmp which user compgnc owns and will not search lower directories (e.g. /tmp/usr)
·         -size +<blocks> - finds files that are bigger than <blocks>
·         -exec rm {} \; - remove all files found...dangerous command - e.g.
$ find /tmp -name "sl.*" -atime +0 -prune -print -exec rm {} \; # will remove all files in /tmp starting 'sl.' that haven't been accessed for a day. Spacing of this command is important! Most exec commands are possible:
$ find /usr2/calltest -name "*.4gl" -print -exec
grep "CHECK" {} \; | pg
·         -ok - like exec only it prompts for confirmation after each occurence. e.g.
$ find /tmp/disk7 -name "*" -print -ok
doswrite -a {} {} \; # Please note that you MUST end any exec or ok option with an escaped semicolon (\;).
·         -user <username> - finds all files owned by <username>
·         -group <groupname> - finds all files with a group of <groupname>
ln -s <Directory> <symbolic link>
- create a symbolic link to a different directory from current directory: e.g.
$ ln -s /usr/uniplex/compgnc /u/compgnc/uni # would create a link called 'uni' in the directory /u/compgnc. From then on, typing cd uni would cd to /usr/uniplex/compgnc. You can also give two files the same name. e.g.
$ ln make.e_enquiry makefile # would link the two files so that they are identical, and when you change one, you change the other. You may also create a symbolic link to a host(!). Instead of typing 'rlogin hpserver' every time, by typing
$ ln -s /usr/bin/rsh hpserver # will create a link so that whenever you type 'hpserver' it will execute a remote shell on the machine.
Option -f forces the link to occur
head -<Number> <FileName>
- prints out the first few line of a file to screen. Specify number to indicate how many lines (default is 10). e.g. If you sent something to a labels printer and it wasn't lined up, then you could print the first few labels again using:
$ head -45 label1.out |
lp -dlocal1
tail -<Number> <FileName>
- prints out the end of a file. Very similar to head but with a very useful option '-f' which allows you to follow the end of a file as it is being created.e.g.
$ tail -f vlink.log # follow end of vlink.log file as it is created.
wc -<options> <FileName>
- Word Count (wc) program. Counts the number of chars, words, and lines in a file or in a pipe. Options:
·         -l (lines)
·         -c (chars)
·         -w (words)
To find out how many files there are in a directory do ls | wc -l
split -<split> <FileName>
- Splits a file into several files.e.g.
$ split -5000 CALLS1 # will split file CALLS1 into smaller files of 5000 lines each called xaa, xab, xac, etc.
tr <character> <other character>
- translates characters. e.g.
$
cat handycommands | tr "\t" " " # will take the file handycommands and translate all tabs into spaces. Useful when messing about with awk or you need to convert some input (e.g. that from tty) to a unique filename that does not contain special characters. e.g.
$
tty | tr "/" "." # produces for example .dev.pts.7
od <options> <filename>
- od converts nasty (binary save) files into character representations. Useful when back-compiling, examining raw .dat files,etc. Use with option '-c' for character display (recommended).
- starts recording everything in the shell to a file by default 'typescript'. Press ^D to finish the script. Provides a log of everything used. Has almost the same effect as $ ksh | tee typescript
Used for debugging shells, seeing error messages which flash off the screen too quickly, etc.
cut
- cut's the file or pipe into various fields. e.g.
$ cut -d "|" -f1,2,3 active.unl # will take the file active.unl which is delimited by pipe symbols and print the first 3 fields options:
·         -d <delimiter>
·         -f <fields>
Not too useful as you can't specify the delimiter as merely white space (defaults to tab) Alternatively, you can 'cut' up files by character positioning (useful with a fixed width file). e.g.
$ cut -c8-28 "barcode.txt" # would cut columns 8 to 28 out of the barcode.txt file.
- paste will join two files together horizontally rather than just tacking one on to the end of the other. e.g. If you had one file with two lines:
Name:
Employee Number:
and another file with the lines:
Fred Bloggs
E666
then by doing:
$ paste file1 file2 > file3 # this would then produce (in file3).
Name: Fred Bloggs
Employee Number: E666
Note that paste puts horizontal tabs between the files, so you may need a
sed 's/   //g' command to get rid of these.
sort <filename>
- sorts the information from the file and displays the result on standard output (stdout). e.g.
$ sort /tmp/list_of_names # will sort the file into alphabetical order, and display it to the screen. Useful with option '-u' to filter out duplicates.
uniq <filename>
- filters out all duplicate lines from a file or input stream (file or stream must be sorted!). Useful with option -c which merely produces a count of unique lines.
ex <filename>
- ex is an old line editor, and almost never used now (similar to DOS edlin if you remember that - me, I've repressed it). You are most likely to come across ex within the vi editor - all commands beginning with a colon (:) are ex commands
- lists files in a directory in long format. You cannot do without this. Here's a more detailed explanation. e.g.
$ ls -l
Part 1
Part 2
Part 3
Part 4
Part 5
Part 6
Part 7
-rw-rw-rw-
1
root
staff
28
Jan 16 09:52
README
-rw-------
1
compjmd
staff
4304
Jun 24 12:21
tabledict
drwxrwxrwx
2
compjmd
staff
512
Jul 1 16:30
testdir
-rwxrwx---
1
compjmd
system
0
Jul 1 16:30
a.out

... is a sample listing.
·         Part 1: Permissions - see chmod for explanation of these. If the first field is set, then the file in question is not really a file at all, but something else, key:
o    -: normal file
o    d: directory
o    l: symbolic link created by 'ln'
o    c or b: device of some sort
You may sometimes see an 's' where the 'x' should be in the permissions - this is normally on executable files which change other files. e.g. Permissions of 'sqlexec' the file that executes all informix queries should be '-rwsr-sr-x' - this then accesses tables with permissions of '-rw-rw----'. where the table files are owned by informix (group informix). the 's' flags allows changing of the database tables on a program level, but not on a unix level. (can change contents via sqlexec but not use 'rm' command on db file).
·         Part 2: Number of links to this file (directories always have 2+).
·         Part 3: The owner of the file - e.g. If the owner is 'compjmd' and permissions are set to -rw------- then only the user 'compjmd' may read or write to that file. Again, if owner is "compjmd" and permissions are -r-x------ then only the user compjmd may read or execute that file. Only the owner of a file or root may chmod it.
·         Part 4: The group ownership of the file - (bloody hell, this is getting complicated). On a unix system there are certain 'groups' which users can belong to, held in the file '/etc/group'. You will notice that in this file there will be a main group, e.g. 'staff' which contains every user. Which means that any user listed under staff is in that group.....right...every file has a group attached to it. Which means that if a file had permissions ----rw---- and a group reference of 'system', then only users who were part of the group system could modify that file. To see which groups the current user belongs to do id. Sorry if this wasn't comprehensible but you should never need to use this anyway(!).
·         Part 5: Size of the file in bytes
·         Part 6: Time of last modification
·         Part 7: The name of the file
Useful options (and there are loads more). All may be combined except where specified:
·         ls -a show files starting with '.' too
·         ls -A show files starting with '.' but not '.' or '..'
·         ls -c must be used with either option l and/or t - displays/sorts by modification time
·         ls -d do not show subdirectory listings
·         ls -i display the i-node number of each file
·         ls -t Put the listing in time order (see options u and c)
·         ls -r Put the listing in reverse order - usually used with a -t
·         ls -u must be used with either options l and/or t - displays/sorts by last-access time
vi <filename>
- love it or loathe it - the standard operating system text-file editor. See Related help file. Vi You can also use 'view' which forces Read only (-R opt). vi +<number> enters the file at the specified line no. Also, vi +/<Search pattern> will enter the file and move to the first occurrence of <Search pattern>. e.g.
$ vi +/"love it or loathe it" handycommands
Users new to vi hate it. I personally managed to get through University without using it ever (I used Joe's own editor instead). If I accidentally went into vi, I had to ^Z and kill the job. Sigh. Five years of using vi means that I'm getting a little better at it now... (I'm actually typing this now in a vi-clone for Windows).
grep <pattern> <file(s)>
- a phenomenally useful command which matches strings within files - e.g.
$ grep D7523 mcall_reps.out # will find all the lines in mcall_reps.out that have the string "D7523" in it. Also incredibly useful for things like pipes,e.g.
$
du | grep cred # (in /home directory will show all users that have 'cred' in their title). You may use regular expression matching - e.g.
$ grep "main.*{" x.c # would match any line containing 'main' and an open curly brackets at any point in the line afterwards. There are two variations to grep - fgrep and egrep which do virtually the same things as grep, but are either faster (having less options) or more complex (but slower). See also section on
Wildcards
Options:
·         -v : show all lines that do not contain pattern.
·         -y : don't bother matching case
·         -i : don't bother matching case
·         -c : show count of matching lines rather than the lines themselves
·         -l : show filename's instead of matching lines.
ksh -o vi
- The Korn Shell - pros might notice that I don't mention using the C-Shell at all - I've never used it, so that's why it doesn't appear. A Shell is a program that you run your commands in. Typing exit will end the current shell. The -o vi option of the korn shell allows vi commands to work at the shell prompt after pressing escape. For example, pressing escape and then 'k' will bring up the last command used in the shell.
awk
- this would be a damn useful command if I knew how to use it properly. see alternative page awkhelp
man <command>
- look at the manual, e.g.
$ man ps # will list the manual page for the command ps
- monitor's system usage - F5 shows processes which are hogging the machine. Not available on AIX 4.1 and above sadly.
- shows how long the system has been up and how hard it is being hammered. The load average fields show how many jobs on average are waiting. <1 or less is very good, around 5 is pretty bad (though not unusual), >10 the machine is being seriously hammered.
who
- list users who are currently logged on (useful with option 'am i' - i.e. 'who am i' or 'whoami')
w
- list users and what they are doing, including idle time. The first line is the output from uptime
id
- similar to whoami except that it does a direct check to see who you are - who only checks /etc/utmp so any su commands will be ignored.
ps
- list processes currently running, by default on the current shell. Useful with options:
·         -t <tty> - show all processes running on a terminal
·         -ef - show all processes
·         -u <loginname> - show all processes owned by a user
·         -flp <processid> - show as much information as you can about a process number
·         -aux - show processes in order of usage of the processors. Useful to see what processes are hogging system resources.
fuser -u <filename>
- show who is using a file.(system hogging command). Useful when trying to work out who has locked a row or table in an informix database for example.
lpstat -p <printer>
- show the current status of a printer and any jobs in the queue. lpstat without arguments prints all of them.
enable <printer>
- enable a printer queue. You must be root or a member of the printq group to run this command.
disable <printer>
- disable a printer queue. You must be root or a member of the printq group to run this command.
enq <various parameters>
- examine spool queue for printers.
uname -a
- will show you what machine you're currently on.
- list semaphores and shared memory.
ipcrm -s <semaphorenumber>
- remove semaphore or shared memory.
- use -l to list all regular scheduled jobs. To alter them, use option -e
at <now + ?? seconds/minutes/hours/days/years>
- perform a job at a specified time. (Useful for running something at a later date). at retains the current environment. e.g.
$ at now + 5 minutes
echo "Phone Julie McNally" > /dev/tty616
^D
job compjmd.389748732 will be run at ???
Will echo to tty616 the message "Phone Julie McNally" in 5 minutes. e.g.2
$ at 0331235930
echo "April fools day!" > /dev/console
^D
will echo "April fools day!" to the console at 11:59 and 30 seconds, on the 31st of march. Format for this is: [YYYY]MMDDhhmmss. at jobs are sometimes used in the place of crontab's because if the machine is off when the crontab is meant to take place, the job never happens. at jobs automatically start when the machine is switched on if the machine was down at the time. typing at -l will show you all the at jobs you have queued, at -r <atjob> will remove an at job (only the owner or root is allowed to do this).
- show current date and time. This command may also be used to set the system clock (ONLY WHEN EVERYONE IS LOGGED OFF) with a root user id. A date change is never simple, even when adjusting things by an hour. The safest way to do it is to change the date then reboot the machine because otherwise the crontab daemon may start doing jobs at odd times. I believe there might be a 'go slow/fast' option to set the clock, and the clock will then run 'slower/quicker' until it catches up with the required time.
last <username>
- shows a list of recent logins. It looks at /var/adm/wtmp so it only shows initial logins, and not whether those users have been su'd to.
fileplace -pv <filename>
- show the physical (as in disk location) location of a file. Useful for tracing informix files, and perhaps for working out whether defragmentation copying is required.
kill -<Signal> <process>
- sends a signal (normally a kill) to a process. kill -9 terminates the job no questions asked, kill -15 tries to clear up as much as possible - e.g. remove semaphores and such-like. Other signals may be sent as well, see manual and /usr/include/sys/signal.h to see what signals you can send to a process.
renice <priority> <process>
- make a process not hog the system so much by setting its nice value.
- system admin program for AIX
df
- list volume groups + usage. see also lsvg. Usually used with the -k flag so the number of blocks is displayed in 1024-blocks.
cu -l <device>
- log on to device such as a pad or a modem. See related files /etc/uucp/* and /etc/locks and /etc/services
- Changes terminal settings back to normal. If a tetra module for example crashes your screen so that no keys function except ^C which doesn't even do very much then typing ^Jstty sane^J should cure the problem. To fully cure the problem you also need to type stty tab3 (and stty -ixon if you're feeling a little overzealous)
- allows you to change terminal settings such as the interrupt key, quit key, etc. e.g.
$ stty intr ^A # would change the interrupt key to being control-A
$ stty quit ^L #would set the quit key (normally ^\) to control-L. other key changes are:
·         erase (normally ^H)
·         xon (normally ^Q)
·         xoff (normally ^S)
·         eof (normally ^D)
To really annoy a systems administrator, change interrupt to 't' and quit to '^D' . hehehehehehe
- show all connected devices
- list volume groups (see related file diskhelp)
- list physical disks (and see related file diskhelp)
lspv without arguments will produce a list of all the hard-disks used. lspv <hard-disk-name> will produce a list of information about the hard disk. lspv -l <hard-disk-name> will show any logical volumes which are mapped on to that drive.
- list devices. Options:
·         -C list Configured devices
·         -P list Possible devices
produces different output when you are root.
- make devices. e.g. To make a tty:
# Script to add a tty. Options that need amending are:
# -l name of tty to be created - e.g '-l tty600' wil create
# a tty called 'tty600'
# -p RAN name
# -w Port number on RAN
# -a Attributes (e.g. to set up auto login, etc.)
mkdev -c tty -t 'tty' -s 'rs232' -l tty433 -p sa2 -w 2 -a term='wyse50' -a forcedcd='enable' -a login='enable' -a speed='19200'
e.g. To create a printer (raw device):
mkdev -c printer -t 'osp' -s 'rs232' -p 'sa3' -w '10' -l label2 -a xon='yes' -a dtr='no' -a col=500
It is highly recommended that you make and change devices using
smit
- change devices. See mkdev
cc
- c compiler, use with
·         -o <object> to specify a target instead of a.out
·         -O optimise
·         -w or -W all warning flags.
- shutdown the system so that it may be switched off. Rather obviously, this may only be run by root. Options:
·         -f shuts the system down immediately (rather than waiting for a minute)
·         -R reboot the system immediately after halt
- show the current revision of the operating system.
- end current shell process. If you log in, then type this command, it will return you to login. ^D (control-D) and logout (in some shells) does the same.
- login to a remote machine, e.g.
$ rlogin hollandrs # log in to machine called hollandrs
Useful with -l option to specify username - e.g.
$ rlogin cityrs -l ismsdev # log in to machine cityrs as user ismsdev For further info about trust network see .rhosts file and /etc/resolv.conf (I think).
- very similar to rlogin except that it is more flexible (just type telnet with no arguments and then '?' to see the options). Useful because you can specify a telnet to a different port.
ftp
- File Transfer Protocol - a quick and easy method for transferring files between machines. The .netrc file in your $HOME directory holds initial commands. type ftp without arguments and then '?' to see options)
rcp
- Remote copy. Copies a file from one unix box to another, as long as they trust each other (see .rhosts file or /etc/resolv.conf I think). Options
·         -f (to force the copy to occur)
·         -r (to recursively copy a directory)
·         -p (to attempt to preserve permissions when copying)
su - <loginname>
- switch user, option '-' means that the users .profile is run, without option you merely assume the id and permissions of the user, without (for example) changing PATH and DBPATH, e.g.
$ su - root # become root
$ su root # gain permissions of root but don't change the current environment variables
$ su - vlink # switch to user vlink
If you are root, you may su to any other user without being prompted for a password. su without arguments is the same as 'su root'. Note that the 'su' option is not available on all UNIX machines as it can crash some of them.
ping <hostname>
- check that <hostname> is alive and well (do not expect an immediate response from a machine that is linked over an ISDN line). Firewalls often block ping packets after the Ping of Death so quite often you'll find you can't ping internet sites either. Options include:
·         -q ping quietly
·         -i<no> wait no of seconds between each packet sending. The default is 1 second. If you are using ping to keep an ISDN line up then using something like $ ping -i 5 -q hollandrs is ideal.
·         -f Never use this! Sends as many packets as it possibly can as fast as possible, used for network debugging and is likely to slow networks horribly when used. Known as 'flood' pinging.
·         -c <no> send no of packets before giving up
To check that your machine can ping, try pinging 127.0.0.1 - this acts as a feedback loop, checking the network card's ability to ping.
rsh <hostname> <commands>
- remote shell - e.g.
$ rsh altos more /tmp/chk # will run the command more the file /tmp/chk on the machine called altos. Useful in pipes for example. rsh on its own will execute a login. Use option '-l' to specify logon name. You can also use rcmd and remsh on other flavours of unix.
host <ip address>
- lookup the ip address in the /etc/hosts file and give its name
Please see this page for more information on disks in AIX
dd if=<filename or device> of=<filename or device> bs=<Block Size> conv=sync
- direct (and I mean DIRECT) copy, normally to tape. Archaic syntax and very rarely used. flags:
·         if - input filename or device
·         of - output filename
·         bs - block size
·         conv - ??
e.g. To write a file to tape use
$ dd if=/etc/hosts of=/dev/rmt0 bs=1024 conv=sync # write hosts file to tape using dd
stands for copy in-out, and is extremely powerful if you can cope with the innumerable flags that you have to use(!)
$ cpio -iBcvumd "etc/hosts" </dev/rmt0 # Grab /etc/hosts file from tape
$
find /etc -print | cpio -oBcv >/dev/rmt0 # Write the contents of the /etc directory to tape
$
find /etc -print | cpio -pdumv /usr2/etcbackup/ # copy directory /etc to /usr2/etcbackup and retain all permissions.
meaning of the flags:
·         i - input
·         o - output
·         B - Block size of 5120 bytes
·         c - read/write header info
·         v - list file names
·         u - unconditional copy - overwrites existing file.
·         m - keep modification dates
·         d - creates directories as needed.
·         t - generate listing of what is on the tape.
·         p - preserve permissions.
tapeutil -f <devicename> <commands>
- A program which came with the tape library to control it's working. Called without arguments gives a menu. Is useful for doing things like moving tapes from the slot to the drive. e.g.
$ tapeutil -f /dev/smc0 move -s 10 -d 23 # which moves the tape in slot 10 to the drive (obviously, this will depend on your own individual tape library, may I suggest the manual?).
doswrite -a <unix file> <dos file>
- copy unixfile to rs6000's floppy disk drive in DOS format. -a option expands certain characters, for certain ascii conversions.
dosdir <directory>
- show list of files on a dos floppy disk. Useful with option -l (long format). Like dos command 'dir'
dosread -a <DOS file> <unix file>
- copy dos file in floppy disk drive to unix - if UNIXFILE is omitted, it outputs to the screen.
dosdel <DOS file>
- delete dos file on floppy disk.
- format dos floppy disk (High Density)
tar
- Read/Write stuff to archive.
tar cvf /dev/rmt0 <filenames> # will write files to tape
tar xvf /dev/rmt0 will read files from tape
tar tvf /dev/rmt0 will give a listing of what's on the tape. If you're using an archive file then replace /dev/rmt0 in the examples above with the name of the archive file.
- a command mainly used in shell scripts. Examples:
$ echo "Hello" # will print Hello on your screen
$ echo "Hello" > /dev/tty616 # will print Hello on someone elses screen (warning - can crash their screen!)
$ echo $DESTF10 # will print the value of the environment variable DESTF10
$ echo "\033Fdemo demo" # will echo demo to the status bar at the top of a wyse terminal
See also file shellscripts
- will read text from standard input and place it in the variable name specified. See file shellscripts
- waits until the user presses return before carrying on (writes what is typed to standard output). If used in a crontab/at job this instruction is ignored. See file shellscripts
talk <user>
- set up an interactive communication dialogue box between two users. Looks good but isn't really that useful.
write <user>
- writes a message to someone elses screen. Try typing 'write root' and then type a message, finishing with control-D.
banner <message>
- writes <message> in huge letters across your screen! (max: 10 chars per word)
wall <message>
- send a message to all people on a system. Can only be executed by root (I think).
tput <argument>
- tty type independent attribute setting (requires TERM variable and TERMCAP to be set). I only know these few bits:
·         tput cnorm - turns the screen cursor on
·         tput civis - turns the screen cursor off
·         tput clear - clears the screen
·         tput smso - turns all new text to bold
·         tput rmso - turns all bold text off
tee (-a) <filename>
- command used in pipes to take a copy of the standard output. e.g.
$
ls | tee /tmp/x # would output ls normally and put a copy in /tmp/x. The option '-a' is used to append rather than replace files.
SCCS Overview
The source code control system allows versions of a program to be stored in a special file, so that any version may be retrieved. There are a few commands involved (not all of them listed here). All source code files start with 's.'
get -r<revision> <source code file>
- get a program out of source code to read only. Missing out the -r flag gets the most recent version. e.g.
$ get $SCUK/s.parser.c # extracts file parser.c from source code file $SCUK/s.parser.c as read only. See
get -e for editing.
get -e <source code file>
- get a piece of code out for edit, so that the code may be modified and a new version created using 'delta'. e.g.
$ get -e $SCUK/s.parser.c # extracts file parser.c from source code file $SCUK/s.parser.c for editing. See
get for read-only.
delta <source code file>
- you must be in the directory with the modified piece of code when you execute this command. This adds the latest version to the source code file. e.g.
$ delta $SCUK/s.parser.c # writes file parser.c to the source code file $SCUK/s.parser.c . See
get -e for information on how to extract the file from source code.
prs <source code file>
- show comments/details on source code file.
admin -r <revision no> -i <program> <source code file>
- create a new source code file with progam. -r specifies the initial revision of the program and may be missed out (default is 1.1 I think). Must be spaced correctly! admin is also used for sccs administration, but it gets to fear and loathing time pretty fast. e.g.
admin -iparser.c $SCUK/s.parser.c # creates a new source code file called $SCUK/s.parser.c from the file parser.c
unget <source code file>
- cancels a get -e
strip <binary compiled file>
- Removes all linking information within a compiled program - basically a way of cutting down the size of an executable.
yes <word>
- yes outputs the word 'yes' as fast as its' little legs can go. Never called on it's own. Always used in pipes. For example:
$ yes |
rm *.o # would confirm 'yes' whenever rm prompts for confirmation. You can also use it to output a different word e.g.
$ yes please # would output 'please' to the screen until you kill it (prob. immediately).
Are all held on a separate page now. Commands covered are export,if,for, shift, test, while, case, and a few others.

sed '<pattern>'
- used by myself for quick substitutions when tr doesn't seem to be doing its job properly. The syntax of the pattern is similar to vi ex command line. E.g. To substitute all spaces with colon symbols the command is
sed 's/ /:/g' file1 # substitute all occurrences of spaces with colons in file1 and output to stdout.

Comment me if you find this post is useful also let me know if you need any new topics.