August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

AIX : Machine Type & Serial Number

AIX : Machine Type & Serial Number

uname -m for the serial number 

uname -M for the machine type and model 

Viewing file systems that 90% and more using awk & sed

This works with AIX

df -g | egrep -v “Filesystem|proc|tmp” | sed ‘s/\%//’ | awk ‘$4 >= 90 {print $4 “%\t” $7}’

df -k | sed 1d | awk ‘$4>90 {print}’

This works with Solaris and Linux

df -k | egrep -v “proc|fd|cdrom|mnttab|run|tmp|Filesystem” | sed ‘s/\%//’ | awk ‘$5 >= 90 {print $5 “%\t” $6}’

Configure ipfilter on Solaris10 as a host based firewall

1- Start by check ipfilter status if it’s running you can go ahead and configure rules

-bash-3.00$ svcs -a|grep -i ipfil
online 10:29:37 svc:/network/ipfilter:default

if it’s disabled enable it

#svcadm enable ipfilter

2- Display rules 

#bash-3.00ipfstat -io
block out all
pass out quick on lo0 all
pass out quick on eri0 proto tcp/udp from eri0/32 to any port = domain with keep state
pass out quick on eri0 proto tcp from eri0/32 to any port = http keep state
pass out quick on eri0 proto icmp from 192.168.1.0/24 to 192.168.1.0/24
block in all
pass in quick on lo0 all
pass in quick on eri0 proto icmp from 192.168.1.0/24 to 192.168.1.0/24
pass in quick on eri0 proto tcp from any to eri0/32 port = http keep state
pass in quick on eri0 proto tcp/udp from any to eri0/32 port = domain with keep state

3- Edit rules 
under 

/etc/ipf/ipf.conf

 

#vi /etc/ipf/ipf.conf

 

#
# ipf.conf
#
# IP Filter rules to be loaded during startup
#
# See ipf(4) manpage for more information on
# IP Filter rules syntax.
####
set intercept_loopback true;
block in all
block out all
### inbound traffic ###
pass in quick on lo0 all
pass in quick on eri0 proto icmp from 192.168.1.0/24 to 192.168.1.0/24
pass in quick on eri0 proto tcp from any to eri0/32 port = http keep state
pass in quick on eri0 proto tcp/udp from any to eri0/32 port = domain keep state

pass out quick on lo0 all
pass out quick on eri0 proto tcp/udp from eri0/32 to any port = 53 keep state
pass out quick on eri0 proto tcp from eri0/32 to any port = http keep state
pass out quick on eri0 proto icmp from 192.168.1.0/24 to 192.168.1.0/24

Clear DNS cache solaris

Clear DNS cache

You can clear DNS cache in Solaris by doing the following

#/etc/init.d/nscd stop
#/etc/init.d/nscd start

List PID’s for processes listening on ports solaris

List PID’s for processes listening on ports

To list PID’s for processes listening on ports

#pfiles `ptree | awk ‘{print $1}’` | egrep ‘^[0-9]|port:’

disable the inetd service

Symptoms

Repeated attempts by unprivileged users to stop the inetd server may transition the inetd service to the “maintenance” state, thereby moving all internet services managed by inetd(1M) to the “offline” state.

To determine the state of the inetd service, the following command can be run:

    $ svcs inetd
    STATE          STIME      FMRI
    maintenance    12:00:23   svc:/network/inetd:default

Workaround

To prevent this issue from occurring until the patches listed in section 5 can be applied, the Unix domain socket file “/var/run/.inetd.uds” may be deleted after the inetd server starts. If this file has been deleted, the following commands must be run (as ‘root’ user) to restart or disable the inetd service:

To restart the inetd service:

    # pkill inetd

To disable the inetd service:

    # svcadm disable inetd
    # pkill inetd

Resolution

This issue is addressed in the following releases:

install ssh client on Centos

install ssh client on Centos

To install openssh on a CentOS:

yum install openssh

 

And if you want to install the client (ssh command) you have to run:

 yum install openssh-clients

install dig, host, and nslookup – bind-utils on CentOS

if you want to use on of the linux commands:

dig, host or nslookup on a CentOS machine and you get the error message:

-bash: nslookup: command not found

you have to install the bind-utils package.

Just run the command:

yum install bind-utils

Solaris 10 – create an init script

First of all, we need to understand the procedure of the boot in Solaris. Next, follows a description of the boot sequence in Solaris.

Overview of the boot sequence in Solaris

  • When Solaris boots up, it runs “init”.
  • “init” looks in /etc/inittab to find out what runlevel it needs to boot into
    On Solaris, this is normally runlevel 3. On Linux, it is normally runlevel 5.
  • “init” reads a list of the programs it needs to start at each run-level from /etc/inittab
  • On Solaris, init runs both “/sbin/rc2? and “/sbin/rc3?. On Linux, init runs only “/etc/rc.d/rc 3?.
    Notice that on Solaris, there is a separate script for each runlevel, but on Linux there is only one script and it is passed a single argument telling it what run-level to process.
  • “/sbin/rc2? (“/etc/rc.d/rc 3? on linux) does the following:
    • reads a list of all the shell scripts matching the pattern /etc/rc2.d/K* (/etc/rc.d/rc3.d/K* on linux) and runs each of those programs with the single argument “stop”.
    • reads a list of all the shell scripts matching the pattern /etc/rc2.d/S* (/etc/rc.d/rc3.d/S* on linux) and runs each of those programs with the single argument “start”.
  • On Solaris, after “/sbin/rc2? is complete, init runs “/sbin/rc3? which does a similar thing, running the K* and S* scripts in /etc/rc3.d with the single arguments “stop” and “start” respectively.

A common technique for system administrators is to use a common location for application and services startup scripts. This location is  “/etc/init.d” (/etc/rc.d/init.d on Linux).

Each script is capable of taking a single argument, which can be either “start” or “stop”.
Based on the argument passed, the script “does the right thing” to stop or start an application or service.

I have made a template for startup scripts, and I use it whenever I need to make a startup script

——————– Template of startup script ——————————————-

#!/bin/sh
case $1 in 
'start') 
# put startup command(s) here 
;; 
'stop') 
# put shutdown command(s) here 
;; 
*) 
echo "Usage: $0 start|stop" >&2 
exit 1 
;; 
esac 
exit 0

——————–End of Template —————————————

I copy this template to the directory /etc/init.d/ with a name which defines the application. For example I used a name dnssvc for a startup script for multiple dns services.

Now, we need this shell script to be executed each time the system boots. We can choose to have the “init” program run this command in run-level 2 or run-level 3. I arbitrarily chose run-level 3, which means that I need to link the program from /etc/init.d into /etc/rc3.d.

Here is the command that I used:
# ln -s /etc/init.d/dnssvc /etc/rc3.d/S93dnssvc

The letter S defines that is a startup Script. If we wanted to write a Stop Script we should have named the link starting with the letter K. The number after the S letter gives the priority of the execution. A lower number means earlier execution at boot time. Two scripts can have the same number, and there is a deterministic way of execution but there is no way to explain it.

Solaris run levels

Solaris system state or init states refer to the level of services provided by the system on that specific run-level.Normally SVR4 systems has 7 run levels and Solaris too has that.

(S)tart files, (K)ill files:

In unix ,runlevel will define what are the process need to start in OS startup according to which run level defined in the /etc/inittab file.For example, in initab if the run-level mentioned as 3 then the system will start all the start scrips under rc1.d,rc2.d,rc3.d during the system boot.The files which are staring with “S” will start the process .When system is going down it will execute “K” scripts according to which init command you have used it.

Run Levels-Solaris

table.tableizer-table { border: 1px solid #CCC; font-family: ; font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

Run Level Init State Type Purpose
0 Power-down state Power-down To shut down the operating system so that it is safe to turn off power to the system.
s or S Single-user state Single-user To run as a single user with some file systems mounted and accessible.
1 Administrative state Single-user To access all available file systems. User logins are disabled.
2 Multiuser state Multiuser For normal operations. Multiple users can access the system and all file system. All daemons are running except for the NFS server daemons.
3 Multiuser level with NFS resources shared Multiuser For normal operations with NFS resources shared. This is the default run level.
4 Alternative multiuser state Not configured by default, but available for customer use.
5 Power-down state Power-down To shut down the operating system so that it is safe to turn off power to the system. If possible, automatically turns off power on systems that support this feature.
6 Reboot state Reboot To shut down the system to run level 0, and then reboot to multiuser level with NFS resources shared (or whatever level is the default in theinittab file).

Thanks to http://docs.oracle.com

To check current run level in Solaris type the below command.

bash-3.00# who -r

.       run-level 3  Jul 16 01:44     3      0  S

run-level 3 –  Identifies the current run level
Jul 16 01:44 – Identifies the date of last run level change
3 – Also identifies the current run level
0  – Identifies the number of times the system has been at this run level since the last reboot
S –  Identifies the previous run level

 

Like everything else in a Solaris system, run levels are defined by files in the filesystem. All the run level files are found in the /etc  directory according to the following table:
table.tableizer-table { border: 1px solid #CCC; font-family: ; font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

Directoy and runlevels
/etc/rc0.d Run level 0
/etc/rc1.d Run level 1
/etc/rc2.d Run level 2
/etc/rc3.d Run level 3
/etc/rc4.d Run level 4
/etc/rc5.d Run level 5
/etc/rc6.d Run level 6

From Solaris 10 onwards,
The /etc/inittab file controls the configuration of init; for more information refer to init and inittab.  It is no longer necessary to edit inittab directly; administrators should use the
Solaris Service Management Facility (SMF) to define services instead. Refer to smf and the System Administration Guide for more information on SMF.

In addition, the svcadm command can be used to change the run level of a system, by selecting a milestone at which to run. The following table shows which run level corresponds to each milestone.

Run Levels and SMF Milestones

 

Run Level SMF Milestone FMRI
S milestone/single-user:default
2 milestone/multi-user:default
3 milestone/multi-user-server:default