Skip to main content

Useful commands in Unix

find command


1.- Sort the 40 largest files :

#find /apps/ora11/product -xdev -ls | sort -nrk 7 | head -40

2.-Find a file name with a specific name :

#find . -name "*.jar" -print

3.-Another variant could be without specifying the file extension :


find . -name  jar  -print

du command


du provides output in a readable format, easier to be understood. You will be able to see the information in Bytes, Kilobytes, Megabytes, Gigabytes, etc.

1.- Check all directories and files size in gigas.


#du -sh *
 1.5G   agent11g
 819M   agent12c
 120M   apex
 294M   assistants
 414M   bin
  27M   ccr
   3K   cdata
 2.4M   cfgtoollogs
  42K   clone
   1K   config
 7.8M   crs
  17K   csmig
 156K   css
 326M   ctx
 2.8M   cv

 

2.-check size for 20 biggest files ordered by size

#du -a | sort -n -r| head -20


iostat command



1.-Check disk performance usage in solaris :

#iostat
   tty        md10          md11          md12          md20           cpu
 tin tout kps tps serv  kps tps serv  kps tps serv  kps tps serv   us sy wt id
   0  153  14   2   12    9   2   10    9   2    8    0   0   11   11  2  0 86

The command display all the devices

#iostat -xn 5


             extended device statistics
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    81.0   12.5 10131.5  847.7  0.0  2.4    0.0   25.3   0  42 ssd163
    0.4    0.3   30.7    6.1  0.0  0.0    0.0   14.6   0   0 ssd164
    54.0    8.9 6738.1  532.1  0.0  0.7    0.0   11.3   0  16 ssd165
    0.9    2.5   12.6   14.4  0.0  0.0    0.0    1.9   0   0 ssd166
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.3   0   0 ssd167
    2.3    3.0  149.9   29.9  0.0  0.0    0.0    5.0   0   1 ssd168
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.3   0   0 ssd169
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.2   0   0 ssd170
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.3   0   0 ssd171
    162.6   16.3 20423.9 1181.9  0.0  1.8    0.0   10.3   0  29 ssd172
    133.9   15.8 16853.3 1128.4  0.0  1.2    0.0    8.0   0  22 ssd173
    162.6   16.3 20423.9 1181.9  0.0  1.8    0.0   10.3   0  29 ssd172
    133.9   15.8 16853.3 1128.4  0.0  1.2    0.0    8.0   0  22 ssd173
    85.8    8.5 10808.2  510.2  0.0  1.0    0.0   11.0   0  19 ssd198
    44.9    8.1 5599.1  467.6  0.0  0.6    0.0   11.5   0  14 ssd199
    44.6    8.1 5558.4  467.7  0.0  0.6    0.0   12.0   0  15 ssd200
    126.5   22.9 15817.3 1806.7  0.0  1.2    0.0    7.9   0  21 ssd201



Important Pay special attention to the %w  %b devicecolumns.
%w : Is the wait is the expected rate and should not exceed
%b : Is the disk busy percentage. The most important is that if to a high percentaje, it get free quickly.
device : Is the device disk name.



#iostat -n
   tty        md10          md11          md12          md20           cpu
 tin tout kps tps serv  kps tps serv  kps tps serv  kps tps serv   us sy wt id
   0  153  14   2   12    9   2   10    9   2    8    0   0   11   11  2  0 86

Print logical disk names

#iostat -en

 ---- errors ---
  s/w h/w trn tot device
    0   0   0   0 md10
    0   0   0   0 md11
    0   0   0   0 md12
    0   0   0   0 md20
    0   0   0   0 md21
    0   0   0   0 md22
    0   0   0   0 md50
    0   0   0   0 md51
    0   0   0   0 md52
    0   0   0   0 sd0
    0   0   0   0 sd1
    0   0   0   0 sd2
    0   0   0   0 ssd72
    0   0   0   0 ssd194
    0   0   0   0 ssd195
    0   0   0   0 ssd196
    0   0   0   0 ssd197
    0   0   0   0 ssd198
    0   0   0   0 ssd199
    0   0   0   0 ssd200
    0   0   0   0 ssd201


Soft error      : A disk sector fails the CRC check and needs to be re-read
Hard error      : Re-read fails several times for CRC check
Transport error : Errors reported by I/O bus
Total errors    : Soft error + Hard error + Transport errors



#iostat -E

sd0       Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: HITACHI  Product: H106030SDSUN300G Revision: A2B0 Serial No: 1219NV1M6B
Size: 300.00GB <300000000000 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0
sd1       Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: TEAC     Product: DV-W28SS-V       Revision: 1.0B Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 2 Predictive Failure Analysis: 0
sd2       Soft Errors: 0 Hard Errors: 0 Transport Errors: 0


The errors details can be displayed with -e option.


prstat command


prstat -a :  The prstat commands show statistics and projects that currently are running on your system. With -a option shows the sum the total for each column for each user group by number of processes.
#prstat -a
 NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU
  1016 ora11      62G   38G    30% 171:39:20  17%
    13 remedyad 3517M 3104M   2.4%  62:36:47 0.6%
    30 root      819M  509M   0.4%  16:47:34 0.0%
     7 xymon    4608K 6696K   0.0%   0:01:32 0.0%
     1 nagios    536K 3616K   0.0%   0:08:11 0.0%
     1 noaccess   86M   98M   0.1%   1:01:23 0.0%
     1 smmsp    2264K 7400K   0.0%   0:00:24 0.0%
     6 daemon   8608K 8976K   0.0%   0:01:27 0.0%



Total: 1075 processes, 12238 lwps, load averages: 7.16, 6.77, 6.56

At the end, you will be able to see the load averages, That is an average for 5, 10 and 15 minutes respectively.


#prstat -J : Same above but group by project :

PROJID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT
   100     1011   62G   38G    30% 171:52:09  17% group.dba
     3       20 3522M 3109M   2.4%  62:39:44 0.8% default
     0       39  916M  613M   0.5%  17:59:02 0.0% system


#prstat -T :  Group by task id :

 TASKID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT
   225      941   61G   38G    29% 148:11:16  16% group.dba
 59726       13 3517M 3104M   2.4%  62:38:24 0.7% default
222224        3 5256K   13M   0.0%   0:00:06 0.6% group.dba
 10542       37   14G 7049M   5.4%  12:42:34 0.0% group.dba
   216        2  148M  106M   0.1%   4:44:04 0.0% system
   162        5  556M  294M   0.2%   9:42:22 0.0% system
   855       32   16G   11G   8.5%  11:02:48 0.0% group.dba
   177        1 9264K 9264K   0.0%   0:50:29 0.0% system
   201        1 8808K   11M   0.0%   0:00:52 0.0% system
   206        2 1872K 4568K   0.0%   0:00:16 0.0% system
   194        1  816K 2352K   0.0%   0:00:00 0.0% system

Total: 1072 processes, 12209 lwps, load averages: 7.31, 6.75, 6.57


id Command


The id command display the OS current username and group and with -p option prints the current project ID in addition to the user and group IDs

#id -p
uid=1000(ora11) gid=1000(dba) projid=100(group.dba)


Comments

Last Week Topics

HOW TO SHARE SAMBA SHARE FROM WINDOWS TO SOLARIS 11

SHARE WINDOWS FOLDER WITH SAMBA IN SOLARIS 11 OPEN THOSE PORT IF YOU HAVE A FIREWALL BETWEEN SERVERS PORT    STATE SERVICE 135/tcp open  msrpc 139/tcp open  netbios-ssn 445/tcp open  microsoft-ds 137 UDP 138 UDP INSTALL SAMBA PACKAGES #pkg install samba ENABLE EACH SERVICES AFTER INSTALLING SAMBA AND CONFIGURE THE SMB.CONF #svcadm enable idmap #svcadm enable smb/client #svcadm enable samba root@:/# vi /etc/samba/smb.conf [ftps]   path = //april.domaintest/FTPS   realm = april.domaintest.com   netbios name = april   passdb backend = YourSharingPassword   guest account = SAMBAUX   log file = /var/samba/log/%m.log   load printers = No   wins server = YourWinServer    winbind trusted domains only = No   workgroup = domaintest.com   hosts allow = 192.168.1.10    TEST THE CONNECTION WITH WINDOWS SAMBA SERVER SHARE     root@:/#  smbclient -L //april/FTPS/ -s /etc/samba/smb.conf -N Anonymous login successful         Sharename       Ty

How to add swap space to Solaris Zone without reboot

How to add swap space to Solaris zone without reboot root@sin:/ # zoneadm list -civ   ID NAME             STATUS     PATH                           BRAND    IP    0 global           running    /                               native   shared    1 lab01             running    /zones/lab01                    native   shared root@sin:/ # If you see the following error root@sin:/# zlogin lab01 Last login: Tue Feb 18 09:44:33 on pts/20 Oracle Corporation      SunOS 5.10      Generic Patch   January 2005 Sourcing //.profile-EIS..... -bash: fork: Not enough space You can can add swap space without reboot the zone lab01, always verify that you have the enough space to add it root@sin:/ # prctl -n zone.max-swap -r -v 30gb -i zone lab01 root@sin:/# zlogin lab01 [Connected to zone 'lab01' pts/7] Last login: Mon Feb 24 08:08:50 on pts/7 Oracle Corporation      SunOS 5.10      Generic Patch   January 2005 Sourcing //.profile-EIS..... DISPLAY=zone:global:0.0 lab

How to break a bonded network interface red hat

1.- Bonding device called bond0 which aggregated by eth0 and eth1 # ifconfig bond0     Link encap:Ethernet  HWaddr 44:a8:42:5d:6d:5d           inet addr:192.168.1.51  Bcast:192.168.1.255  Mask:255.255.255.0           inet6 addr: fe80::5054:ff:fe4d:9004/64 Scope:Link           UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1 eth0      Link encap:Ethernet  HWaddr 44:a8:42:5d:6d:5d           UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1 eth2      Link encap:Ethernet  HWaddr 44:a8:42:5d:76:29           UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1           RX packets:6 errors:0 dropped:0 overruns:0 frame:0 # cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: fault-tolerance (active-backup) Primary Slave: em1 (primary_reselect always) Currently Active Slave: em1 MII Status: up MII Polling Interval (ms): 50 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 10000

FAN Fully Automated Nagios monitoring tool

If you need install an application to monitor, with a simple installation and no many configuration or compilation, you can use FAN versiĆ³n 2.1 We have a tool that is integrated with Nagios, Centreon, Nagvis and DocuWiki OS Centos 5.9 Centreon 2.4.1 Nagvis 1.7 Nagios and DocuWiki You can download the ISO and Documentation from the following link, it is a very easy software to install in order to monitor the servers. http://www.fullyautomatednagios.org/

How to check quickly the most expensive event status on database order by hundredths of a second

set linesize 300 set pagesize 80 select event, total_waits,time_waited  from V$system_event where event NOT IN ('pmon timer', 'smon timer', 'rdbms ipc reply', 'parallel deque wait', 'virtual circuit', '%SQL*Net%', 'client message', 'NULL event') order by time_waited desc; EVENT                                                            TOTAL_WAITS TIME_WAITED ---------------------------------------------------------------- ----------- ----------- SQL*Net message from client                                       2544593029  9.5738E+10 rdbms ipc message                                                   59890948  9356298126 EMON slave idle wait                                                 4176203  2088107168 Space Manager: slave idle wait                                       5305448  1054797785 DIAG idle wait                                                       8318686   831907680 Streams AQ: emn c

HOW TO SET KERNEL VALUES TO IMPROVE PERFORMANCE IN SOLARIS SERVERS

  (A) set maxphys  To improve basic disk performance  maxphys is the maximum size of physical I/O requests. If a driver sees a request larger than this size, the driver breaks the request into maxphys size chunks. File systems can and do impose their own limit. This value should be higher than all other settings (vol_maxio, vol_maxspecialio etc) such as in Filesystems/Volume Manager etc. maxphys is set in bytes.  Maximum number of page I/O requests that can be queued by the paging system. This number is divided by 4 to get the actual maximum used by the paging system. It is used to throttle the number of requests as well as to control process swapping. maxpgio is in I/O's.  C)Set FastScan  (Is Calculated by Multipliying 32678 for Physical Memory D)Set Handspreadpages(Is Calculated by Multipliying 32678 for Physical Memory  The Solaris environment uses a two-handed clock algorithm to look for pages that are candidates for reclaiming when memory is low. The first hand o

HOW TO ADD A LINE WITH ANSIBLE WITH TAB SPACE IN A FILE

-bash-4.2# vi add_line_syslog.yml --- - name: script in order to add in the server list below with TAB spaces a Line in the SYSLOG CONF   hosts: oraking   tasks:     - name: Add a Line  in /etc/syslog.conf in order to delivery that information to another server       lineinfile:         path: /etc/syslog.conf         line: " *.err;auth.notice;auth.info;local0.info \t\t @10.10.10.200 "         insertbefore: ' \*.alert;kern.err;daemon.err '     - name: Restart system-log       command: /usr/sbin/svcadm restart svc:/system/system-log:default

HOW TO INSTALL APACHE 2.4 on Red Hat 6

1.- We will need to enable the following Repository rhel-server-rhscl-6-rpms   server1# subscription-manager repos --enable rhel-server-rhscl-6-rpms     If you do not have internet Access and you are using a proxy you will need to  set the proxy,before activate the repository.       server1# subscription-manager repos --enable=rhel-server-rhscl-6-rpms --proxy=192.1.1.3 --proxyuser=user1 --proxypass=password365   2.-Proceed to install the package   server1# yum install httpd24-httpd           After finishing we have installed Apache 2.4 with all the dependencies.   3.- Finally you can install the other packages  that you need separately as :   httpd24-mod-auth httpd24-mod-ldap httpd24-mod-sesiĆ³n httpd24-mod-ssl   Depending of the application you will need to install openssl (n order to have security socket layer)   4.- Now you can start the apache 2.4   # service httpd24-httpd start     Validate errors in the log

How to install multilibs Red Hat i686 and x86_x64

HOW TO INSTALL MULTILIBS RED HAT  1.- After installing the OS you will need to have access to Internet if you do not have a internal repository. You will need to add the following line in red  on the /etc/yum.conf (Edit) # cat /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 proxy=http://191.128.1.110:8080 proxy_username=spoon proxy_password=spooner #MULTILIBS multilib_policy=all On other hand if you have a proxy in order to have connection to internet, you can add the lines in Blue in the file above. proxy=http://191.128.1.110:8080 proxy_username=spoon proxy_password=spooner Finally you can add the packages that you need in i686 and x64_x86 #yum search openmotif Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock [Errn