Command to find file system details on AIX

Hi ,

Could you please tell me how to find the following on AIX?

1.Command to find file system details?
2.What are all the files exist under a specific directory along with their sizes?

In general we use,

du -sh * | grep M under a directory which returns files having size of MB,
du -sh * | grep G under a directory which returns files having size of GB in Linux. But this du -sh command in not working on AIX. Similarily I am looking for similar type of command on AIX.

I hope my request is clear.

Os version -- AIX 3 5

Regards,
Maddy

You've been working in these forums long enough to know that telling us something like:

without showing us the diagnostics produced (if there are any) of the results you are getting (if there are any) makes it hard for us to help you.

Your description of what du -sh | grep '[GM]' does on a Linux system is not correct unless the directory in which you run it contains no directories. Are there any directories in the directory where you want to run these commands? Are there any sparse files in the directory where you want to run these commands? Do you not care about Terabyte sized files?

And du does not give you file system details; it gives you filesystem hierarchy disk block allocation counts. (Where the filesystem hierarchies can be single files, single directories, or multiple nested filesystems depending on the operands you give it to process.)

Would the command ls -lSd give you the data you need and would a shell or awk arithmetic comparison on field 5 of the ls output to select the file sizes you want from the output be sufficient?

1 Like

on AIX you can say either du -sm or du -sg

1 Like

Hi Don/Agent,

Thanks. I am able to list files under directories with their sizes using commands du -sm / du -sg .

Regards,
Maddy

du/df -sh is a GNU aka coreutils convention. I doubt IBM will ever support "-h" and I know coreutils is not going to support "-g" - because I asked. The answer was: we have "-h".

Anyway, to summarize what you are seeing (I switched to root, because not all directories were directly readable - saving you that)

I just type the request - and it works!

michael@x071:[/home/michael]su
root's Password: 
michael@x071:[/home/michael]du -sh
1.7G    .

Some debugging - use full pathname for IBM AIX du

michael@x071:[/home/michael]/usr/bin/du -sh
/usr/bin/du: Not a recognized flag: h
Usage: du [-a | -s] [-rlkmgx] [ -H | -L ] [Name ...]

So, what am I using?

michael@x071:[/home/michael]which du
/opt/bin/du
michael@x071:[/home/michael]lslpp -w /opt/bin/du
  File                                        Fileset               Type
  ----------------------------------------------------------------------------
  /opt/bin/du
                                      aixtools.coreutils.rte        File

And, if you are interested in playing with coreutils on AIX (from AIX 5.3 TL7 and later) trying installing coreutils and gettext (GNU text internationalzation) from either aixtools (that I package), or from Perzl site.
The key difference is I package for installp and he packages from rpm

See coreutils - AIXTOOLS and gettext - AIXTOOLS - or AIX Open Source Packages | Main / coreutils

Playtime! - And hope this helps :slight_smile:

Hi Michael,

Your command is not helpful. I am unable to find answers I am looking for using your commands.:frowning:

$ cd /oraarch01/tivtcprd
$ du -sh
du: Not a recognized flag: h
Usage: du [-a | -s] [-rlkmgx] [ -H | -L ] [Name ...]
$ lslpp -w /oraarch01/tivtcprd

Regards,
Maddy

Sorry for the confusion then. I reply to be of assistance, not to harm.

The IBM versions of du and df do not know the option 'h' - which is the option GNU uses as a wildcard for sizes.

From the GNU man page for du:

     DU(1)           GNU coreutils 8.24 (October 2015)           DU(1)

          -h, --human-readable
               print sizes in human readable format (e.g., 1K 234M 2G)

The -w option for lslpp is to show where a command comes from (or which fileset it comes from. So, my example was to show where the commands du come from - and should have been like this - to prevent confusion!

root@x065:[/home/root]lslpp -w /usr/bin/du /opt/bin/du
  File                                        Fileset               Type
  ----------------------------------------------------------------------------
  /usr/bin/du                                 bos.rte.commands      File
  /opt/bin/du
                                      aixtools.coreutils.rte        File

Hoping this - well - helps :smiley:

If you need/want support for the -h option you will need to get GNU coreutils for AIX.

Michale,

I think my question is not that much clear for you. Sorry for that.I will explain it again.

What OS command is used to display files under the directory along with their sizes as shown example below.

/tmp
file1 5 MB
file2 10 MB
file3 8 MB
file4 10 GB .......

Regards,
Maddy

In fact, it is the other way round: it was perfectly clear to Michael what you want to do, why you failed in doing so and what you could do to rectify that.

To use Michaels own words:

Along with that he told you how to find out if you have these versions already installed, where you can get them if you are interested in installing them and where on your system they will be located once you indeed install them at all. Plus he gave some background information nobody else could have provided, because - to my knowledge - he is the only one with direct and personal access to the labs of the OS' manufacturer.

In my book that is not only not "confusing" at all, but rather "utterly helpful" and "accomodating to the utmost". What - save for having them installed for you - do you think he should have done for you??

I suggest you change your attitude a bit: from entitlement towards cooperation. It might not only help you here but also with properly working your systems.

bakunin

/PS:

There is no such command because the output of du is the other way round, with the size in front:

# du -sm *
0.00    file1
0.00    file2
0.06    file3
2 Likes

I use du -sk * | sort -n
Should work on any unix.

For fancy MB/GB display you can always do a little math in awk piped or a shell variable.

It should be a good practice for you to write such portable awk program using forums and search engines.

Hope that helps
Regards
Peasant.

@ bakunin: I share exactly this feeling.

Hi,

Thanks everyone for sharing commands.

With help of your commands I was able to find the files and it's corresponding sizes under the directory.But couldn't able to determine each file sizes as shown below.

$ du -sm *
0.00    Housekeep_test
200.01  orcl_archive.dbf
105900.18       orcladmdata.dbf
25000.01        orcladmindex.dbf
4000.01 orclconvert.dbf
3000.01 orclconvert2.dbf
3000.01 orclconvert3.dbf
3000.01 orclconvert4.dbf
11264.05        orclprd_audit_data_01.dbf
400.00  orclprd_redo_01a.rdo
400.00  orclprd_redo_01b.rdo
400.00  orclprd_redo_02a.rdo
400.00  orclprd_redo_02b.rdo
400.06  orclprd_redo_03a.rdo
400.07  orclprd_redo_03b.rdo
28.49   control01.ctl
28.49   control02.ctl
28.49   control03.ctl
20000.05        undotbs03.dbf
20000.06        undotbs04.dbf
20000.18        undotbs05.dbf
20000.15        undotbs06.dbf
20000.13        undotbs07.dbf
$ pwd
/oradata01/orclprd
$ du -sk * | sort -n

0       Housekeep_test
0       flash_recovery_area
0       lost+found
0       nohup.out
8       spacecheck.txt
29172   control01.ctl
29172   control02.ctl
29172   control03.ctl
204808  orcl_archive.dbf
307208  gelco_index.dbf
409604  orclprd_redo_01a.rdo
409604  orclprd_redo_01b.rdo
409604  orclprd_redo_02a.rdo
409604  orclprd_redo_02b.rdo
512012  users01.dbf
614408  system01.dbf
1043208 gelco_data.dbf
1536008 target_data01.dbf
2047256 temp07.dbf
2047284 temp06.cbf
2096580 temp05.dbf
10240016        temp04.dbf
11534388        orclprd_audit_data_01.dbf
15360232        undotbs25.dbf
15728696        undotbs08
16383376        temp01.dbf
20480008        dbadm_partd_orclprd.dbf
20480008        undotbs01.dbf
20480008        undotbs13.dbf
20480008        undotbs14.dbf
25600008        orcladmindex.dbf
51200008        dbadmdata.dbf
59187224        dbadmindex.dbf
108441784       orcladmdata.dbf

Regards,
Maddy

Really!?!

Ref:

# man du
-k 	Calculates the block count in 1024-byte units rather than the default 512-byte units.
-m 	Calculates the block count in MB units rather than the default 512-byte units. The output values for the disk usage would be in floating point numbers as value of each unit in bytes is significantly high.

HTH

Hi,

Thanks. How to calculate these file sizes into KB/MB/GB on AIX?

Regards,
Maddy

I thought we covered that...

$ du -sm * | grep orcl_archive.dbf
200.01  orcl_archive.dbf

So in (-sm = megabytes) it's about 200.01MB

$ du -sk * | grep orcl_archive.dbf
204808  orcl_archive.dbf

So in (-sk = kilobytes) it's about 204,808KB = about 200MB

HTH

Hi Bakunin (looks funny with a cap :)),

Although I am getting close to 20 years professionally with AIX (and nearly 10+ more while it was not my favorite) - I have never had access to the labs.

Back in 1978 - is when I started with UNIX v6 and v7 on PDP, and "college access to the kernel". The deep stuff I learned back then.

As to things like the meaning of -h - like anyone (or perhaps I am alone) not starting in GNU/Linux, I fell over it. From AIX I was used to df -g , and when coreutils are first in my PATH that does not work. I requested it (support for -g) as a feature - and got turned down "because we have -h". That was the day I learned about "-h" and how it relates to du and ds . Looking at Maddy's question - it seems he is looking for a specific layout - with the letters K, M or G behind the number, rather than as a counter.

Maddy,

Working the way it has been in UNIX for years and years (du -sk goes back to 1978 and earlier perhaps) - is not going to work for you.

If I understand you correctly - what you are asking is not standard in UNIX aka POSIX systems. It is not even standard in Linux, because it is GNU - not Linux - who makes these choices. And GNU stands for GNU Not Unix - which they take seriously. If they feel they have a better idea, then they do it that way. They are "not UNIX/POSIX" and are free to make any change they wish. Fortunately, they also try to be compatible with POSIX behavior most of the time.

POSIX does not have -h - so GNU can define that anyway they wish. And so the following outputs show - if you need/want file system stats as you describe - either you will need to write an awk script (or something compareable) to convert the first number that AIX/POSIX du behavior is providing - OR - install coreutils.

Happy hunting!

Both AIX and COREUTILS versions give the same output for the arguments -k, (-sk to sum directories), -m or -sm.

Note the full path of the command:
AIX

michael@x071:[/home/michael]/usr/bin/du -sk /tmp/* | sort -n | tail
3520    /tmp/openssh_xxx
4704    /tmp/waitUploaderTmp_7078008.0
4704    /tmp/waitUploaderTmp_7078008.0.tmp
8452    /tmp/ibm.bff
17656   /tmp/891c0bbd
27888   /tmp/93b06705msd
40008   /tmp/aixtools.perl.5.14.4.0.I
41152   /tmp/named.tcpdump
56900   /tmp/rootvg.20140814.bff.bz2
60332   /tmp/forums.bff.bz2

COREUTILS

michael@x071:[/home/michael]/opt/bin/du -sk /tmp/* | sort -n | tail
3520    /tmp/openssh_xxx
4704    /tmp/waitUploaderTmp_7078008.0
4704    /tmp/waitUploaderTmp_7078008.0.tmp
8452    /tmp/ibm.bff
17656   /tmp/891c0bbd
27888   /tmp/93b06705msd
40008   /tmp/aixtools.perl.5.14.4.0.I
41152   /tmp/named.tcpdump
56900   /tmp/rootvg.20140814.bff.bz2
60332   /tmp/forums.bff.bz2

COREUTILS using -h
I think this is what you seem to be looking for - with the letters behind the size. However, note the very very different results when using sort!

michael@x071:[/home/michael]/opt/bin/du -sh /tmp/* | sort -n | tail
440K    /tmp/jpzcd8-alqe
440K    /tmp/jpzcdV-alqg
440K    /tmp/jpzcdYDalyc
500K    /tmp/jpzcd-4al7d
500K    /tmp/jpzcd6-alqf
500K    /tmp/jpzcdKDalyb
500K    /tmp/jpzcd_4al7c
500K    /tmp/jpzcd_6al7a

Now my largest file is not showing up at the end - because numerically " sort " 500K is larger than 59M. So, just be careful when using sort!

michael@x071:[/home/michael]/opt/bin/du -h /tmp/forums.bff.bz2        
59M     /tmp/forums.bff.bz2

Hi Duke/Michael,

Thanks for explaining things.

Michael,

Could you please explain above line with few examples as I feel difficult to understand it correctly.

Regards,
Maddy

Should read:

HTH

When you use du -sm or du -sk or du -sg you will get all numbers in the same unit: kilobytes, megabytes, gigabytes or whatever. You can sort this output numerically and get valid results (that is, the files sorted by their size).

When you use the GNUism du -sh instead it will display the numbers in differing units and because "50M" (megabytes) is bigger than "500k" (kilobytes) but numerically smaller ("50" is smaller than "500" and sort doesn't know about units) you will get invalid results.

So, if you plan to use sort on your results you should stick to the AIX-variant of du anyways and not even think about using the GNU-variant du -h .

I hope this helps.

bakunin