You are on page 1of 8

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

Development Concepts Usability Metatags Anti-Virus Anti-Spam Business Accounting Backup EDGE Digital Signage Linux Scalix Shop OnLine Document Management Applications Business Info Hardware Info Microsoft Info Linux 101 AIX 101 OnLine Help Help Desk Blog Backup EDGE Eudora mySQL PowerTerm uniBasic Business Pro & Yes I Can Analyze Your Needs Software Ownership Password Creation Effective Presentations Buses Cables Chips DVD Memory Monitors Networks Power Protection RAID SCSI Versions & LIcenses About Office Windows XP Access Excel Word Contact Us What's New Horizon Newsletter Our Customers Employment

Set-up & Status General Commands Shell Commands Other Tips File Info Networking Printing Backup

File Commands
Understanding the AIX File System | Maximums | Path Definitions/Usage File System crfs - create new mkfs - create chlv - expand beyond max LV's chfs - change attributes fsck - check or fix rmfs - remove mount - mount umount - unmount sync - flushes system buffers to disk Disk Status df - display status of mounted file systems du - display disk usage istat - display dates of access for a file ls - display contents of a directory fuser - display users using a file system

More...
File Commands DOS Files

Directories & Files ln - link files or directories unlink - unlink a file or directory mv - rename files or directories mvdir - rename directories dircmp - compare files in different directories cat - display contents of text or ascii file cp - copy files or directories del - delete file rm - remove files or directories

Understanding the AIX File System


The AIX file system contains 3 major elements: Physical Volumes (PV) Volume Groups (VG) Logical Volumes (LV) IBM likes to use abbreviations, so get used to calling Physical Volumes PV's, etc. Definition Physical Volumes What is it Examples

A system with 2 drives, could contain A Physical Volume is an actual physical device, i.e. disk drive. Physical Volume's hdisk0 and hdisk1. Each disk drive contains a Physical Volume. Physical Volume's are broken into Physical Partitions (PP's) where each Physical Partition is 4MB in size. Volume Group's are a set of one or more Physical Volume's. Each Volume Group can contain one or more Logical Volumes

Volume Groups

Physical Volume hdisk0 could contain Volume Group rootvg and Physical Volume hdisk1 could contain Volume Group datavg.

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 1 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

Logical Volumes

Logical Volume's are used to define groups of files, i.e. File Systems. Each Logical Volume contains Logical Partitions (LP's)

Volume Group rootvg could contain Logical Volume's hd1, hd2, hd3. Where the mounting points for hd1 = '/' (root), hd2 = /usr, hd3 = /tmp

Here's a table to help make this clearer, I hope. Physical Volume drive 1 = hdisk0 drive 2 = hdisk1 Volume Group rootvg datavg Logical Volume hd1 mounted as / hd2 mounted as /var hd3 mounted as /tmp

You can use smit to display or configure your file systems. Here are some commands that smit uses that you can use at the command line to provide the necessary information. The following commands only display information. Physical Volume Information Examples lspv lspv <physicalvolume> lspv -l <physicalvolume> lspv -p <physicalvolume> lspv -s <physicalvolume> lsvg -n <physicalvolume> Examples lsvg lsvg -p <volumegroup> lsvg -l <volumegroup> Examples lslv -l <logicalvolume> top of page Displays all Volume Groups Displays Physical Volume, State and Physical Partition information Displays Logical Volume name, Type, Logical Partitions, Physical Partitions, Physical Volumes, Logical Volume State and Mounting Point What it does Displays Physical Volume, Copies, Distribution info What it does Displays a list of all Physical Volume's with the drive name and associated Volume Group's Displays a specific Physical Volume. Stale partitions refers to mirroring. If the Physical Volume has no mirrored Logical Partitions, then the value for this field is zero Displays what Logical Volumes reside on the named Physical Volume along with Logical Partition's Physical Partition's and Mounting Point. Displays distribution of Physical Partitions for each Logical Volume that reside on the named Physical Volume along with State, Region, Type and Mounting Point. Displays Physical Volume, total, free and used Physical Partitions. Displays total, free and used Physical Partitions and other information.

Volume Group Information What it does

lsvg <volumegroup> Displays all Volume Groups, total, free and used Physical Partitions

Logical Volume Information lslv <logicalvolume> Displays Volume Group, Mirror State, Mount Point and more...

Maximums
The smallest file extension is 4Kb. If a user creates or extends a file anywhere from 0-4096 bytes, a 4K block will be allocated from the free list to accommodate that request. When a file system is extended by 1 Physical Partition (4 MB), 1024 inodes are allocated to that file system. Maximums length of a filename : 255 characters number of open files per process : 2,000 number of open files system-wide : 200,000 number of record locks per process: 200,000 number of record locks system-wide: 200,000 bytes per pipe : 32,768 number of pipes per process : 2,000 number of semaphore IDs : 4,096 number of semaphores per ID : 100 K number of operations per semop call : 1,024 semaphore value : 32,767 adjust on exit : 16,384 number of message queue IDs : 4,096

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 2 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

bytes per message : 8,192 bytes per message queue : 65,536 messages per message queue : 8,192 number of segments system-wide : 16 MB number of shared memory segments : 4,096 number of segments per process : 10 bytes per segment 256 MB top of page

Path Definitions/Usage
Directory /bin /sbin /dev /etc /home /lib /tmp /usr /usr/adm /usr/bin /usr/lib /usr/spool/mail /usr/sbin /usr/share /usr/share/man /usr/share/dict /usr/share/info /usr/share/lib /usr/share/lpp /var/adm /var/preserve /var/spool /var/tmp top of page utilities files needed to boot the machine and mount the /usr file system special files (I/O devices) miscellaneous administrative utilities user directories and files libraries temporary files. Needs to be at least 12 MB common executables that are shared across the same architecture administrative commands and files utilities (overflow for /bin) archive libraries, text processing macros Email files utilities used in system administration, including smit architecture-independent, shareable text files manual pages spelling dictionary and its indexes InfoExplorer database files architecture-independent data files, including terminfo data about optional program products (OPP) system logging and accounting files preserved data from interrupted edit sessions spool iles for printing temporary files What's in it

cat
Concatenates or displays one or more files. Examples cat -v textfile tput clear | cat -v top of page What it does The -v option will display non-printing characters. Displays the control codes generated to your terminal to clear the screen.

chlv
Used to expand beyond the maximum Logical Volume limit. chlv -x 256 <lv_name> (Where logical volume name is entered without the /dev) top of page

chfs
Changes attributes of a file system. Block size for this command is 512 byte blocks, where the command df, returns disk info in 1024 byte blocks. The simplest method of extending a file system is to

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 3 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

Take the target size of the file system in MB's and multiple by 2000. If the file system size is to be extended to 12MB in size, then 12 * 2000 = 24000. Remember, when you extend a file system, you extend the logical volume that resides under it. Most systems have a default Physical Partition size of 4MB (review output of lsvg rootvg command) and therefore when the file system increases in size, it will increase by a multiple of 4MBs. chfs -a size=24000 /usr (Increase the /usr file system to 12 MBs.) top of page

cp Copies one or more files.


Examples cp /u/roger/test.c /tmp cp -ipr . /tmp/temp What it does Copies the file test.c in the directory /u/roger to the /tmp directory Copies all the files and subdirectories from the current directory to the directory named /tmp/temp. -i If a filename already exists in the destination directory, the system will prompt you to overwrite this file with the one being copied from the source directory. -p Preserves file permissions, owner, group, and modification attributes of the file beingcopied to it's new destination. -r Copies all files and subdirectories. cp -r /usr/data /home/data top of page Copies all files and directories from /usr to /home

crfs
Adds a new file system. Block size for this command is 512 byte blocks, where the command df, returns disk info in 1024 byte blocks. crfs -v jfs -g rootvg -m /mydata -p rw -a size=100000 -v file systems type, jfs=journalized file system -g volume group name where filesystem will reside, rootvg -m mount point for new filesystem, /mydata -p access permissions, rw=read/write -a file system attribute, size=100000 The above command creates a 50MB journeled file system named /mydata with read/write permissions, created under the volume group, rootvg top of page

del
Delete files where system will prompt you to delete the file(s). del /u/roger/* If 'y' is entered for yes, all files will be removed. top of page

df
Displays summary of disk usage for mounted file systems. df -v top of page

dircmp
Compares two directories and the contents of all files found in both directories. dircmp /tmp/COMPANY /u/COMPANY | grep different Displays only those files that are found in both directories but have differences

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 4 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

top of page

du
Display a summary of disk usage for directories (output in 512 byte blocks). Without an argument, du lists the current directory. Examples du /tmp du -s /tmp du -a /u/roger /doc.txt top of page What it does Displays total number of 512 byte blocks used by /tmp filesystem and all directories underneath it Summarizes disk allocation for /tmp filesystem (including ALL files and subdirectories) in 512 byte blocks Summarizes disk allocation for a particular file

fsck
Checks and interactively repairs inconsistent file systems. File systems are normally checked everytime the system is rebooted. If a file system is cleanly unmounted via the umount command, it's unlikely to encounter any problems when the fsck command is run on the file system again. Fsck can only be run on a file system that is unmounted (fsck will not make changes to a mounted file-system). If fsck passes without errors, its safe to mount the file system in question. If there's a discrepancy between the number of directory references to a file and the link count in the file and the file contains data (UNCLAIMED BLOCKS), the file is linked into the subdirectory named lost+found directory. fsck does not flag a bad block on your Physical Volume. Bad blocks are only relocated on a write operation. Fsck performs read operations and therefore is useful for soft errors - not hard errors. Also updates the JFS log - /dev hd8 Examples 1) fsck -fp /dev/hd1 2) mount /u What it does To make sure the /dev/hd1 (/u file system) is not damaged, followed by mounting that file system for user access. -f (fast check) Won't check file systems cleanly unmounted. -p Will fix minor problems without prompting user whether the problem detected should be fixed or not. The -y option gives fsck permission to automatically repair file systems when necessary. Use this command in case the superblock is corrupted. This will restore the BACKUP COPY of the superblock to the CURRENT copy.

fsck -y /dev/hd1 dd count=1 bs=4k skip=31 seek=1 if=/dev/hd4 of=/dev/hd4 fsck /dev/hd4 2>&1 | tee /tmp/fsck.errors top of page

fuser
Identifies processes using a file or file system fuser -u /dev/hd3 Sample output: /dev/hd3: 2964(root) 6615c(root) 8465(casado) 11290(bonner) top of page

istat
Displays dates of access for a file istat myfile (Displays attributes about the file named myfile) top of page

ln

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 5 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

Gives a file more than one name (alias). The symbolic link (-s) allows a user to point to a file and/or a directory. Symbolic links can link either a file or directory across a file system. Use unlink to remove a link. Examples ln test1 test2 ln -s /tmp ./junk 1) cd /u/COMPANY 2) ln -s /u/roger/* top of page What it does Creates a link from the original file named test1 to a new file named test2 Links subdirectory junk under the current directory to directory /tmp. All the files under /u/roger will now have links to /u/COMPANY.

ls
Displays the contents of a directory Options -a -d -e -l -t -F -R -b List directories only Indicates if a file has extended security information - 11th character: + means yes, means no Long listing - more detail Sorts by time of last modification (latest listed first) Puts a / (slash) after each filename if the file is a directory. An * (asterisk) after each filename if the file can be executed. An @ for a symbolic link Lists all subdirectories recursively Lists garbage or hidden characters in octal What it does List directory attributes for CURRENT directory List directory attributes for PARENT directory (one level up) Lists all files and subdirectories under current directory Displays the last time the data in a file has been changed. Displays the last time the attributes of a file have been changed. Displays the last time the data in a file has been accessed. What it does Lists all entries including hidden files that start with a "."

Examples ls -ld . ls -ld .. ls -aeltFR ls -l ls -lc ls -lu top of page

mkfs
Makes a file system. Example: cd /u find . -print|backup -ivqf/dev/rmt0 cd / umount /u mkfs dev/hd1 fsck -p /dev/hd1 mount /u cd /u restore -xvf/dev/rmt0 The above procedure is one way of making a file system contiguous again. Over the course of time, thousands of additions, deletions, creation, and extensions of files and/or records will create a file system that looks like Swiss cheese. This results in multiple disk accesses that formally may have taken only one. As a result, the system appears sluggish. top of page

mount
Displays file system attributes or makes file system available for use. Examples What it does

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 6 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

mount mount /u/data mount /usr/tmp /tmp mount -o wsize-8192, rsize=8192 mount -n cad -v nfs /transfer top of page

Displays attributes about all file systems that are on-line Mounts the file system named /u/data for accessibility. If you don't have enough room in the /tmp filesystem for a specific utility to work properly, and you do have enough room in the /usr filesystem, then you can mount the space from the /usr filesystem onto /tmp Set the read/write buffers to 8K to increase performance for NFS file systems. Since NFS verifies each packet that gets written to the server before it requests the next packet from the client, writes will take longer to execute than a read. By increasing the buffer size, less I/O operations will be needed, thereby increasing performance. Mount a remote file system (type=nfs) on the mount point named /transfer, that resides on node cad

mv
Renames one or more files mv report1 report2 (Renames the file named report1 to eport2) top of page

mvdir
Renames a directory. mv /u/roger /u/scott (Renames the directory roger to scott) top of page

rm
Removes a file or directory Examples rm -i * rm -r /u/roger/docs rm -i S\&e38912 Removes the file named S&38912. Since this file has a special character ('&') that the shell treats differently than most. -i system prompt if you wish to remove. rm `find . -print` rm ./-junkfile Removes all files from current directory including hidden files (file names such as {}, -exec, ;, etc) By preceding the filename (-junkfile) with the pathname (./), you are able to hide the '-' character that starts the filename. If this was not done, the following error message would be generated: usage: rm [-fir] file ... Removes all files named mbox found under any of the subdirectories located in /home. What it does Will prompt the user to remove each of the files in the current directory beforeremoving them EXCEPT for hidden files. Will recursively remove all files and any subdirectories found under /u/roger/docs.

rm /home/*/mbox top of page

rmfs
Removes a file system rmfs /u Removes a file system and the logical volume under it. The file system must be unmounted prior to the 'rmfs' command being executed else you will get a 'BUSY' error message. The '/u' entry in /etc/filesystems will also be removed. top of page

sync
Flushes system buffers to disk. There's a sync daemon (/etc/syncd) that flushes buffers automatically every 60 seconds (default).

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 7 of 8

1/29/2012 9:40 AM

AIX File Commands Tips Support

http://www.ahinc.com/aix/file.htm

top of page

umount
Unmounts a file system from system usage. umount /u Unmounts a file system so that files found under that file system will not be able to be accessed. The 'umount' will fail if one or more users are either currently on that file system or somebody has a file opened on that file system. top of page

unlink
Used to remove a link or symbolic link. unlink MyDoc (Removes the link MyDoc from the system) top of page

Services | Products | Support | About Us | Privacy Policy | Legal Stuff

Email us at Info@AHinc.com Advanced Horizons, Inc. All Rights Reserved

Create PDF files without this message by purchasing novaPDF printer (http://www.novapdf.com) 8 of 8

1/29/2012 9:40 AM

You might also like