Unix - tail Command

Purpose:

Writes a file to standard output, beginning at a specified point.

Standard Syntax:

tail [ -f ] [ -c Number | -n Number | -m Number | -b Number | -k Number ] [File ]

Description:

The tail command writes the file specified by the File parameter to standard
output beginning at a specified point. If no file is specified, standard input
is used. The Number variable specifies how many units to write to standard
output. The value for the Number variable can be a positive or negative
integer. If the value is preceded by + (plus sign), the file is written to
standard output starting at the specified number of units from the beginning of
the file. If the value is preceded by - (minus sign), the file is written to
standard output starting at the specified number of units from the end of the
file. If the value is not preceded by + (plus sign) or - (minus sign), the file
is read starting at the specified number of units from the end of the file.

The type of unit used by the Number variable to determine the starting point
for the count is determined by the -b, -c, -k, -m, or -n flag. If one of these
flags is not specified, the tail command reads the last ten lines of the
specified file and writes them to standard output. This is the same as entering
-n 10 at the command line.

The -m flag provides consistent results in both single- and double-byte
character environments. The -c flag should be used with caution when the input
is a text file containing multibyte characters, because output can be produced
that does not start on a character boundary.

Flags

-b Number Reads the specified file beginning at the 512-byte block location
indicated by the Number variable.

-c Number Reads the specified file beginning at the byte location indicated by
the Number variable.

-f If the input file is a regular file or if the File parameter specifies a
FIFO (first-in-first-out), the tail command does not terminate after the last
specified unit of the input file has been copied, but continues to read and
copy additional units from the input file as they become available. If no File
parameter is specified and standard input is a pipe, the -f flag is ignored.
The tail -f command can be used to monitor the growth of a file being written
by another process.

-k Number Reads the specified file beginning at the 1KB block location
indicated by the Number variable.

-m Number Reads the specified file beginning at the multibyte character
location indicated by the Number variable. Using this flag provides consistent
results in both single- and double-byte character-code-set environments.

-n Number Reads the specified file beginning at the line location indicated by
the Number variable.

-r Displays the output from the end of the file in reverse order. The default
for the -r flag prints the entire file in reverse order. If the file is larger
than 20,480 bytes, the -r flag displays only the last 20,480 bytes.

The -r flag is valid only with the -n flag. Otherwise, it is ignored.

Examples:

1. To display the last 10 lines of the notes file, enter:

tail notes

2. To specify the number of lines to start reading from the end of the notes
file, enter:

tail -n 20 notes

3. To display the notes file a page at a time, beginning with the 200th byte,
enter:

tail -c +200 notes | pg

4. To follow the growth of a file, enter:

tail -f accounts

This displays the last 10 lines of the accounts file. The tail command
continues to display lines as they are added to the accounts file. The
display continues until you press the Ctrl-C key sequence to stop it.

FTP Files from or To Server

Example Server: 200.1.54.64

- Open command prompt, type ftp 200.1.54.64
- Enter Username and Password
- type lcd "path in your descktop".E.g: "C:\"
- type cd "your sever directory".E.g: /home/script

If you want to get the files:

- Type get "file_name"
- If many files,type mget "file_name"
* If you dont want prompt message, type prompt off

If you want to put files:

- Type put "file_name"
- If many files,type mput "file_name"
* If you dont want prompt message, type prompt off

Hope it can help...

head Command

Purpose:

Displays the first few lines or bytes of a file or files.

Syntax:

head [ -Count | -c Number | -n Number ] [ File ... ]

Description:


The head command writes to standard output a specified number of lines or bytes
of each of the specified files, or of the standard input. If no flag is
specified with the head command, the first 10 lines are displayed by default.
The File parameter specifies the names of the input files. An input file must
be a text file. When more than one file is specified, the start of each file
will look like the following:

==> filename <==

To display a set of short files, identifying each one, enter:

example% head -9999 filename1 filename2...

Flags:


-Count Specifies the number of lines from the beginning of each specified file
to be displayed. The Count variable must be a positive decimal integer. This
flag is equivalent to the -n Number flag, but should not be used if portability
is a consideration.

-c Number Specifies the number of bytes to display. The Number variable must be
a positive decimal integer.

-n Number Specifies the number of lines from the beginning of each specified
file to be displayed. The number variable must be a positive decimal integer.
This flag is equivalent to the -Count flag.

Exit Status

This command returns the following exit values:

0 Successful completion.

>0 An error occurred.

Examples:

To display the first five lines of the Test file, enter:

head -5 Test

OR

head -n 5 Test

grep Command

Purpose:

Searches a file for a pattern.

Syntax:

grep [ -E | -F ] [ -i ] [ -h ] [ -s ] [ -v ] [ -w ] [ -x ] [ -y ] [ [ [ -b ] [
-n ] ] | [ -c | -l | -q ] ] [ -p [ Separator ] ] { [ -e PatternList ... ] [ -f
PatternFile ... ] | PatternList ... } [ File ... ]

Description:

The grep command searches for the pattern specified by the Pattern parameter
and writes each matching line to standard output. The patterns are limited
regular expressions in the style of the ed or egrep command. The grep command
uses a compact non-deterministic algorithm.

The grep command displays the name of the file containing the matched line if
you specify more than one name in the File parameter. Characters with special
meaning to the shell ($, *, [, |, ^, (, ), \ ) must be in quotation marks when
they appear in the Pattern parameter. When the Pattern parameter is not a
simple string, you usually must enclose the entire pattern in single quotation
marks. In an expression such as [a-z], the - (minus sign) cml specifies a
range, according to the current collating sequence. A collating sequence may
define equivalence classes for use in character ranges. If no files are
specified, grep assumes standard input.

Notes:

1. Lines are limited to 2048 bytes.
2. Paragraphs (under the -p flag) are currently limited to a length of
5000 characters.
3. Do not run the grep command on a special file because it produces
unpredictable results.
4. Input lines should not contain the NULL character.
5. Input files should end with the new-line character.
6. The new-line character will not be matched by the regular expressions.
7. Although some flags can be specified simultaneously, some flags
override others. For example, the -l option takes precedence over all
other flags. And if you specify both the -E and -F flags, the last one
specified takes priority.

Flags:


-b Precedes each line by the block number on which it was found. Use this flag
to help find disk block numbers by context. The -b flag cannot be used with
input from stdin or pipes.

-c Displays only a count of matching lines.

-E Treats each pattern specified as an extended regular expression (ERE). A
NULL value for the ERE matches every line.

Note: The grep command with the -E flag is the same as the egrep command,
except that error and usage messages are different and the -s flag
functions differently.

-e PatternList Specifies one or more search patterns. This works like a simple
pattern but is useful when the pattern begins with a - (minus). Patterns should
be separated by a new-line character. A NULL pattern can be specified by two
adjacent new-line characters or a quotation mark followed by a new-line
character ("\n). Each pattern is treated like a basic regular expression (BRE)
unless the -E or -F flag is also specified. Multiple -e and -f flags are
accepted by grep. All of the specified patterns are used when matching lines,
but the order of evaluation is unspecified.

-F Treats each specified pattern as a string instead of a regular expression. A
NULL string matches every line.

Note: The grep command with the -F flag is the same as the fgrep command,
except that error and usage messages are different and the -s flag
functions differently.

-f PatternFile Specifies a file containing search patterns. Each pattern should
be separated by a new-line character, and an empty line is considered a NULL
pattern. Each pattern is treated like a basic regular expression (BRE), unless
the -E or -F flag is also specified.

-h Prevents the name of the file containing the matching line from being
appended to that line. Suppresses file names when multiple files are specified.

-i Ignores the case (uppercase or lowercase) of letters when making
comparisons.

-l Lists just the names of files (once) which contain matching lines. Each file
name is separated by a new-line character. If standard input is searched, a
path name of (StandardInput) is returned. The -l flag with any combination of
the -c and -n flags behaves like the -l flag only.

-n Precedes each line with the relative line number in the file. Each file
starts at line 1, and the line counter is reset for each file processed.

-p[Separator] Displays the entire paragraph containing matched lines.
Paragraphs are delimited by paragraph separators, as specified by the Separator
parameter, which are patterns in the same form as the search pattern. Lines
containing the paragraph separators are used only as separators; they are never
included in the output. The default paragraph separator is a blank line.

-q Suppresses all writing to standard output, regardless of matching lines.
Exits with a zero status if an input line is selected. The -q flag with any
combination of the -c, -l and -n flags behaves like the -q flag only.

-s Suppresses error messages ordinarily written for nonexistent or unreadable
files. Other error messages are not suppressed.

-v Displays all lines not matching the specified pattern.

-w Does a word search.

-x Displays lines that match the specified pattern exactly with no additional
characters.

-y Ignores the case of letters when making comparisons.

PatternList Specifies one or more patterns to be used during the search. The
patterns are treated as if they were specified using the -e flag.

File Specifies a name of a file to be searched for patterns. If no File
variable is given, the standard input is used.

Exit Status

This command returns the following exit values:

0 A match was found.

1 No match was found.

>1 A syntax error was found or a file was inaccessible (even if matches were
found).

Examples:

1. To use a pattern that contains some of the pattern-matching characters *,
^, ?, [, ], \(, \), \{, and \}, enter:

grep "^[a-zA-Z]" pgm.s

This displays every line in pgm.s whose first character is a letter.
2. To display all lines that do not match a pattern, enter:

grep -v "^#" pgm.s

This displays every line in pgm.s whose first character is not a # (pound
sign).
3. To display all lines in the file1 file that match either the abc or xyz
string, enter:

grep -E "abc|xyz" file1

4. To search for a $ (dollar sign) in the file named test2, enter:

grep \\$ test2

The \\ (double backslash) characters are necessary in order to force the
shell to pass a \$ (single backslash, dollar sign) to the grep command.
The \ (single backslash) character tells the grep command to treat the
following character (in this example the $) as a literal character rather
than an expression character. Use the fgrep command to avoid the necessity
of using escape characters such as the backslash.

ftp Command

Purpose:

Transfers files between a local and a remote host.

Syntax:

ftp [ -d ] [ -g ] [ -i ] [ -n ] [ -v ] [ -f ] [ -k realm] [-q[-C]][ HostName [
Port ] ]

Description:

The ftp command uses the File Transfer Protocol (FTP) to transfer files between
the local host and a remote host or between two remote hosts.

The FTP protocol allows data transfer between hosts that use dissimilar file
systems. Although the protocol provides a high degree of flexibility in
transferring data, it does not attempt to preserve file attributes (such as the
protection mode or modification times of a file) that are specific to a
particular file system. Moreover, the FTP protocol makes few assumptions about
the overall structure of a file system and does not provide or allow such
functions as recursively copying subdirectories.

Note: If you are transferring files between systems and need to preserve
file attributes or recursively copy subdirectories, use the rcp command.

Issuing Subcommands

At the ftp> prompt, you can enter subcommands to perform tasks such as listing
remote directories, changing the current local and remote directory,
transferring multiple files in a single request, creating and removing
directories, and escaping to the local shell to perform shell commands. See the
Subcommands section for a description of each subcommand.

If you execute the ftp command and do not specify the HostName parameter for a
remote host, the ftp command immediately displays the ftp> prompt and waits for
an ftp subcommand. To connect to a remote host, execute the open subcommand.
When the ftp command connects to the remote host, the ftp command then prompts
for the login name and password before displaying the ftp> prompt again. The
ftp command is unsuccessful if no password is defined at the remote host for
the login name.

The ftp command interpreter, which handles all subcommands entered at the ftp>
prompt, provides facilities that are not available with most file-transfer
programs, such as:

o Handling file-name parameters to ftp subcommands
o Collecting a group of subcommands into a single subcommand macro
o Loading macros from a $HOME/.netrc file

These facilities help simplify repetitive tasks and allow you to use the ftp
command in unattended mode.

The command interpreter handles file-name parameters according to the following
rules:

o If a - (hyphen) is specified for the parameter, standard input (stdin) is
used for read operations and standard output (stdout) is used for write
operations.
o If the preceding check does not apply and file-name expansion is enabled
(see the -g flag or the glob subcommand), the interpreter expands the file
name according to the rules of the C shell. When globbing is enabled and a
pattern-matching character is used in a subcommand that expects a single
file name, results may be different than expected.

For example, the append and put subcommands perform file-name expansion and
then use only the first file name generated. Other ftp subcommands, such as
cd, delete, get, mkdir, rename, and rmdir, do not perform file-name
expansion and take the pattern-matching characters literally.
o For the get, put, mget, and mput subcommands, the interpreter has the
ability to translate and map between different local and remote file-name
syntax styles (see the case, ntrans, and nmap subcommands) and the ability
to modify a local file name if it is not unique (see the runique
subcommand). Additionally, the ftp command can send instructions to a
remote ftpd server to modify a remote file name if it is not unique (see
the sunique subcommand).
o Use double quotes (" ") to specify parameters that include blank
characters.

Note: The ftp command interpreter does not support pipes. It also does
not necessarily support all multibyte-character file names.

To end an ftp session when you are running interactively, use the quit or bye
subcommand or the End of File (Ctrl-D) key sequence at the ftp> prompt. To end
a file transfer before it has completed, press the Interrupt key sequence. The
default Interrupt key sequence is Ctrl-C. The stty command can be used to
redefine this key sequence.

The ftp command normally halts transfers being sent (from the local host to the
remote host) immediately. The ftp command halts transfers being received (from
the remote host to the local host) by sending an FTP ABOR instruction to the
remote FTP server and discarding all incoming file transfer packets until the
remote server stops sending them. If the remote server does not support the
ABOR instruction, the ftp command does not display the ftp> prompt until the
remote server has sent all of the requested file. Additionally, if the remote
server does something unexpected, you may need to end the local ftp process.

Security and Automatic Login

If Standard is the current authentication method:

The ftp command also handles security by sending passwords to the remote host
and permits automatic login, file transfers, and logoff.

If you execute the ftp command and specify the host name (HostName) of a remote
host, the ftp command tries to establish a connection to the specified host. If
the ftp command connects successfully, the ftp command searches for a local
$HOME/.netrc file in your current directory or home directory. If the file
exists, the ftp command searches the file for an entry initiating the login
process and command macro definitions for the remote host. If the $HOME/.netrc
file or automatic login entry does not exist or if your system has been secured
with the securetcpip command, the ftp command prompts the user for a user name
and password. The command displays the prompt whether or not the HostName
parameter is specified on the command line.

Note: The queuing system does not support multibyte host names.

If the ftp command finds a $HOME/.netrc automatic login entry for the specified
host, the ftp command attempts to use the information in that entry to log in
to the remote host. The ftp command also loads any command macros defined in
the entry. In some cases (for example, when the required password is not listed
in an automatic login entry), the ftp command prompts for the password before
displaying the ftp> prompt.

Once the ftp command completes the automatic login, the ftp command executes
the init macro if the macro is defined in the automatic login entry. If the
init macro does not exist or does not contain a quit or bye subcommand, the ftp
command then displays the ftp> prompt and waits for a subcommand.

Note: The remote user name specified either at the prompt or in a
$HOME/.netrc file must exist and have a password defined at the remote
host. Otherwise, the ftp command fails.

If Kerberos 5 is the current authentication method:

The ftp command will use the extensions to ftp specifications as defined in
IETF draft document "draft-ietf-cat-ftpsec-09.txt". The FTP security extensions
will be implemented using the Generic Security Service API (GSSAPI) security
mechanism. The GSSAPI provides services independent to the underlying security
and communication mechanism. The GSSAPI is defined in rfc 1508 and 1509.

The ftp command will use the AUTH and ADAT commands to authenticate with the
ftpd daemon. If both support Kerberos authentication, then they will use the
local users DCE credentials to authenticate the user on the remote system. If
this fails and Standard authentication is configured on both systems, the
process described above will be used.

The HostName parameter is the name of the host machine to which files are
transferred. The optional Port parameter specifies the ID of the port through
which to transmit. (The /etc/services file specifies the default port.)

Flags:

-C Allows the user to specify that the outgoing file sent using the send_file
command must be cached in the Network Buffer Cache (NBC). This flag cannot be
used unless the -q flag is specified. This flag is only applicable when a file
is being sent out in the binary mode with no protection.

-d Sends debugging information about ftp command operations to the syslogd
daemon. If you specify the -d flag, you must edit the /etc/syslog.conf file and
add one of the following entries:

user.info FileName

OR

user.debug FileName

Note: The syslogd daemon debug level includes info level messages.

If you do not edit the /etc/syslog.conf file, no messages are produced. After
changing the /etc/syslog.conf file, run the refresh -s syslogd or kill -1
SyslogdPID command to inform the syslogd daemon of the changes to its
configuration file. For more information about debug levels, refer to the
/etc/syslog.conf file. Also, refer to the debug subcommand.

-g Disables the expansion of metacharacters in file names. Interpreting
metacharacters can be referred to as expanding (sometimes called globbing) a
file name. See the glob subcommand.

-i Turns off interactive prompting during multiple file transfers. See the
prompt, mget, mput, and mdelete subcommands for descriptions of prompting
during multiple file transfers.

-n Prevents an automatic login on the initial connection. Otherwise, the ftp
command searches for a $HOME/.netrc entry that describes the login and
initialization process for the remote host. See the user subcommand.

-q Allows the user to specify that the send_file subroutine must be used for
sending the file on the network. This flag is only applicable when a file is
being sent out in the binary mode with no protection.

-v Displays all the responses from the remote server and provides data transfer
statistics. This display mode is the default when the output of the ftp command
is to a terminal, such as the console or a display.

If stdin is not a terminal, the ftp command disables verbose mode unless the
user invoked the ftp command with the -v flag or issued the verbose subcommand.

-f Causes the credentials to be forwarded. This flag will be ignored if
Kerberos 5 is not the current authentication method.

-k realm Allows the user to specify the realm of the remote station if it is
different from the local systems realm. For these purposes, a realm is
synonymous with a DCE cell. This flag will be ignored if Kerberos 5 is not the
current authentication method.

Subcommands

The following ftp subcommands can be entered at the ftp> prompt. Use double
quotes (" ") to specify parameters that include blank characters.

![Command [Parameters]] Invokes an interactive shell on the local host. An
optional command, with one or more optional parameters, can be given with the
shell command.

$Macro [Parameters] Executes the specified macro, previously defined with the
macdef subcommand. Parameters are not expanded.

?[Subcommand] Displays a help message describing the subcommand. If you do not
specify a Subcommand parameter, the ftp command displays a list of known
subcommands.

account [Password] Sends a supplemental password that a remote host may require
before granting access to its resources. If the password is not supplied with
the command, the user is prompted for the password. The password is not
displayed on the screen.

append LocalFile [RemoteFile] Appends a local file to a file on the remote
host. If the remote file name is not specified, the local file name is used,
altered by any setting made with the ntrans subcommand or the nmap subcommand.
The append subcommand uses the current values for form, mode, struct, and type
subcommands while appending the file.

ascii Synonym for the type ascii subcommand.

bell Sounds a bell after the completion of each file transfer.

binary Synonym for the type binary subcommand.

block Synonym for the mode block subcommand.

bye Ends the file-transfer session and exits the ftp command. Same as the quit
subcommand.

carriage-control Synonym for the form carriage-control subcommand.

case Sets a toggle for the case of file names. When the case subcommand is On,
the ftp command changes remote file names displayed in all capital letters from
uppercase to lowercase when writing them in the local directory. The default is
Off (so the ftp command writes uppercase remote file names in uppercase in the
local directory).

cd RemoteDirectory Changes the working directory on the remote host to the
specified directory.

cdup Changes the working directory on the remote host to the parent of the
current directory.

close Ends the file-transfer session, but does not exit the ftp command.
Defined macros are erased. Same as the disconnect subcommand.

copylocal Toggles local copy. copylocal defaults to off. An effort is made by
ftp to make sure you do not zero out a file by ftp'ing it to itself (eg. same
hostname, same pathname). Turning copylocal ON bypasses this check.

cr Strips the carriage return character from a carriage return and line-feed
sequence when receiving records during ASCII-type file transfers. (The ftp
command terminates each ASCII-type record with a carriage return and line feed
during file transfers.)

Records on remote hosts with operating systems other than the one you are
running can have single line feeds embedded in records. To distinguish these
embedded line feeds from record delimiters, set the cr subcommand to Off. The
cr subcommand toggles between On and Off.

debug [0 | 1] Toggles debug record keeping On and Off. Specify debug or debug 1
to print each command sent to the remote host and save the restart control
file. Specify debug again, or debug 0, to stop the debug record keeping. The
Ctrl-C key sequence also saves the restart control file.

Specifying the debug subcommand sends debugging information about ftp command
operations to the syslogd daemon. If you specify the debug subcommand, you must
edit the /etc/syslog.conf file and add one of the following entries:

user.info FileName

OR

user.debug FileName

Note: The syslogd daemon debug level includes info level messages.

If you do not edit the /etc/syslog.conf file, no messages are produced. After
changing the /etc/syslog.conf file, run the refresh -s syslogd or kill -1
SyslogdPID command to inform the syslogd daemon of the changes to its
configuration file. For more information about debug levels, refer to the
/etc/syslog.conf file. Also, refer to the ftp -d flag.

delete RemoteFile Deletes the specified remote file.

dir [RemoteDirectory][LocalFile] Writes a listing of the contents of the
specified remote directory (RemoteDirectory) to the specified local file
(LocalFile). If the RemoteDirectory parameter is not specified, the dir
subcommand lists the contents of the current remote directory. If the LocalFile
parameter is not specified or is a - (hyphen), the dir subcommand displays the
listing on the local terminal.

disconnect Ends the file-transfer session but does not exit the ftp command.
Defined macros are erased. Same as the close subcommand.

ebcdic Synonym for the type ebcdic subcommand.

exp_cmd Toggles between conventional and experimental protocol commands. The
default is off.

file Synonym for the struct file subcommand.

form [ carriage-control | non-print | telnet ] Specifies the form of the file
transfer. The form subcommand modifies the type subcommand to send the file
transfer in the indicated form. Valid arguments are carriage-control,
non-print, and telnet.

carriage-control
Sets the form of the file transfer to carriage-control.
non-print
Sets the form of the file transfer to non-print.
telnet
Sets the form of the file transfer to Telnet. Telnet is a Transmission
Control Protocol/Internet Protocol (TCP/IP) protocol that opens connections
to a system.

get RemoteFile [LocalFile] Copies the remote file to the local host. If the
LocalFile parameter is not specified, the remote file name is used locally and
is altered by any settings made by the case, ntrans, and nmap subcommands. The
ftp command uses the current settings for the type, form, mode, and struct
subcommands while transferring the file.

glob Toggles file-name expansion (globbing) for the mdelete, mget, and mput
subcommands. If globbing is disabled, file-name parameters for these
subcommands are not expanded. When globbing is enabled and a pattern-matching
character is used in a subcommand that expects a single file name, results may
be different than expected.

For example, the append and put subcommands perform file-name expansion and
then use only the first file name generated. Other ftp subcommands, such as cd,
delete, get, mkdir, rename, and rmdir, do not perform file-name expansion and
take the pattern-matching characters literally.

Globbing for the mput subcommand is done locally in the same way as for the csh
command. For the mdelete and mget subcommands, each file name is expanded
separately at the remote machine and the lists are not merged. The expansion of
a directory name can be different from the expansion of a file name, depending
on the remote host and the ftp server.

To preview the expansion of a directory name, use the mls subcommand:

mls RemoteFile

To transfer an entire directory subtree of files, transfer a tar archive of the
subtree in binary form, rather than using the mget or mput subcommand.

hash Toggles hash sign (#) printing. When the hash subcommand is on, the ftp
command displays one hash sign for each data block (1024 bytes) transferred.

help [Subcommand] Displays help information. See the ? subcommand.

image Synonym for the type image subcommand.

lcd [Directory] Changes the working directory on the local host. If you do not
specify a directory, the ftp command uses your home directory.

local M Synonym for the type local M subcommand.

ls [RemoteDirectory] [LocalFile] Writes an abbreviated file listing of a remote
directory to a local file. If the RemoteDirectory parameter is not specified,
the ftp command lists the current remote directory. If the LocalFile parameter
is not specified or is a - (hyphen), the ftp command displays the listing on
the local terminal.

macdef Macro Defines a subcommand macro. Subsequent lines up to a null line
(two consecutive line feeds) are saved as the text of the macro. Up to 16
macros, containing at most 4096 characters for all macros, can be defined.
Macros remain defined until either redefined or a close subcommand is executed.

The $ (dollar sign) and \ (backslash) are special characters in ftp macros. A $
symbol followed by one or more numbers is replaced by the corresponding macro
parameter on the invocation line (see the $ subcommand). A $ symbol followed by
the letter i indicates that the macro is to loop, with the $i character
combination being replaced by consecutive parameters on each pass.

The first macro parameter is used on the first pass, the second parameter is
used on the second pass, and so on. A \ symbol prevents special treatment of
the next character. Use the \ symbol to turn off the special meanings of the $
and \. (backslash period) symbols.

mdelete RemoteFiles Expands the files specified by the RemoteFiles parameter at
the remote host and deletes the remote files.

mdir [RemoteDirectories LocalFile] Expands the directories specified by the
RemoteDirectories parameter at the remote host and writes a listing of the
contents of those directories to the file specified in the LocalFile parameter.
If the RemoteDirectories parameter contains a pattern-matching character, the
mdir subcommand prompts for a local file if none is specified. If the
RemoteDirectories parameter is a list of remote directories separated by
blanks, the last argument in the list must be either a local file name or a -
(hyphen).

If the LocalFile parameter is - (hyphen), the mdir subcommand displays the
listing on the local terminal. If interactive prompting is on (see the prompt
subcommand), the ftp command prompts the user to verify that the last parameter
is a local file and not a remote directory.

mget RemoteFiles Expands the RemoteFiles parameter at the remote host and
copies the indicated remote files to the current directory on the local host.
See the glob subcommand for more information on file-name expansion. The remote
file names are used locally and are altered by any settings made by the case,
ntrans, and nmap subcommands. The ftp command uses the current settings for the
form, mode, struct, and type subcommands while transferring the files.

mkdir [RemoteDirectory] Creates the directory specified in the RemoteDirectory
parameter on the remote host.

mls [RemoteDirectories LocalFile] Expands the directories specified in the
RemoteDirectories parameter at the remote host and writes an abbreviated file
listing of the indicated remote directories to a local file. If the
RemoteDirectories parameter contains a pattern-matching character, the mls
subcommand prompts for a local file if none is specified. If the
RemoteDirectories parameter is a list of remote directories separated by
blanks, the last argument in the list must be either a local file name or a -
(hyphen).

If the LocalFile parameter is - (hyphen), the mls subcommand displays the
listing on the local terminal. If interactive prompting is on (see the prompt
subcommand), the ftp command prompts the user to verify that the last parameter
is a local file and not a remote directory.

mode [ stream | block ] Sets file-transfer mode. If an argument is not
supplied, the default is stream.

block
Sets the file-transfer mode to block.
stream
Sets the file-transfer mode to stream.

modtime Shows the last modification time of the specified file on the remote
machine. If the ftp command is not connected to a host prior to execution, the
modtime subcommand terminates with an error message. The ftp command ignores
parameter beyond the first parameter. If the FileName parameter is not
specified, the ftp command prompts for a file name. If no file name is given,
the ftp command sends a usage message to standard output and terminates the
subcommand.

If the name specified by the FileName parameter exists on the remote host, and
the name specifies a file, then the ftp command sends a message containing the
last modification time of the file to standard output and terminates the
subcommand. If FileName specifies a directory, the ftp command sends an error
message to standard output and terminates the subcommand.

Note: The modtime subcommand interprets metacharacters when allowed.

mput [LocalFiles] Expands the files specified in the LocalFiles parameter at
the local host and copies the indicated local files to the remote host. See the
glob subcommand for more information on file-name expansion. The local file
names are used at the remote host and are altered by any settings made by the
ntrans and nmap subcommands. The ftp command uses the current settings for the
type, form, mode, and struct subcommands while transferring the files.

nlist [RemoteDirectory][LocalFile] Writes a listing of the contents of the
specified remote directory (RemoteDirectory) to the specified local file
(LocalFile). If the RemoteDirectory parameter is not specified, the nlist
subcommand lists the contents of the current remote directory. If the LocalFile
parameter is not specified or is a - (hyphen), the nlist subcommand displays
the listing on the local terminal.

nmap [InPattern OutPattern] Turns the file-name mapping mechanism On or Off. If
no parameters are specified, file-name mapping is turned off. If parameters are
specified, source file names are mapped for the mget and mput subcommands and
for the get and put subcommands when the destination file name is not
specified. This subcommand is useful when the local and remote hosts use
different file-naming conventions or practices. Mapping follows the pattern set
by the InPattern and OutPattern parameters.

The InPattern parameter specifies the template for incoming file names, which
may have already been processed according to the case and ntrans settings. The
template variables $1 through $9 can be included in the InPattern parameter.
All characters in the InPattern parameter, other than the $ (dollar sign) and
the \$ (backslash, dollar sign), are treated literally and are used as
delimiters between InPattern variables. For example, if the InPattern parameter
is $1.$2 and the remote file name is mydata.dat, the value of $1 is mydata and
the value of $2 is dat.

The OutPattern parameter determines the resulting file name. The variables $1
through $9 are replaced by their values as derived from the InPattern
parameter, and the variable $0 is replaced by the original file name.
Additionally, the sequence [Sequence1,Sequence2] is replaced by the value of
Sequence1, if Sequence1 is not null; otherwise, it is replaced by the value of
Sequence2. For example, the subcommand:

nmap $1.$2.$3 [$1,$2].[$2,file]

would yield myfile.data from myfile.data or myfile.data.old, myfile.file from
myfile, and myfile.myfile from .myfile. Use the \ (backslash) symbol to prevent
the special meanings of the $ (dollar sign), [ (left bracket), ] (right
bracket), and , (comma) in the OutPattern parameter.

non-print Synonym for the form non-print subcommand.

ntrans [InCharacters [OutCharacters]] Turns the file-name character translation
mechanism On and Off. If no parameters are specified, character translation is
turned off. If parameters are specified, characters in source file names are
translated for mget and mput subcommands and for get and put subcommands when
the destination file name is not specified.

This subcommand is useful when the local and remote hosts use different
file-naming conventions or practices. Character translation follows the pattern
set by the InCharacters and OutCharacters parameter. Characters in a source
file name matching characters in the InCharacters parameter are replaced by the
corresponding characters in the OutCharacters parameter.

If the string specified by the InCharacters parameter is longer than the string
specified by the OutCharacters parameter, the characters in the InCharacters
parameter are deleted if they have no corresponding character in the
OutCharacters parameter.

open HostName [Port] Establishes a connection to the FTP server at the host
specified by the HostName parameter. If the optional port number is specified,
the ftp command attempts to connect to a server at that port. If the automatic
login feature is set (that is, the -n flag was not specified on the command
line), the ftp command attempts to log in the user to the FTP server.

You must also have a $HOME/.netrc file with the correct information in it and
the correct permissions set. The .netrc file must be in your home directory.

passive Toggles passive mode for file transfers. When a file transfer command
(such as get, mget, put, or mput) is invoked with passive mode off, the ftp
server opens a data connection back to the client. In passive mode, the client
opens data connections to the server when sending or receiving data.

private Sets the protection level to "private." At this level, data is
integrity and confidentially protected.

prompt Toggles interactive prompting. If interactive prompting is on (the
default), the ftp command prompts for verification before retrieving, sending,
or deleting multiple files during the mget, mput, and mdelete subcommands.
Otherwise, the ftp command acts accordingly on all files specified.

protect This command returns the current level of protection.

proxy [Subcommand] Executes an ftp command on a secondary control connection.
This subcommand allows the ftp command to connect simultaneously to two remote
FTP servers for transferring files between the two servers. The first proxy
subcommand should be an open subcommand to establish the secondary control
connection. Enter the proxy ? subcommand to see the other ftp subcommands that
are executable on the secondary connection.

The following subcommands behave differently when prefaced by the proxy
subcommand:

o The open subcommand does not define new macros during the automatic login
process.
o The close subcommand does not erase existing macro definitions.
o The get and mget subcommands transfer files from the host on the primary
connection to the host on the secondary connection.
o The put, mput, and append subcommands transfer files from the host on the
secondary connection to the host on the primary connection.
o The restart subcommand can be handled by the proxy command.
o The status subcommand displays accurate information.

File transfers require that the FTP server on the secondary connection must
support the PASV (passive) instruction.

put LocalFile [RemoteFile] Stores a local file on the remote host. If you do
not specify the RemoteFile parameter, the ftp command uses the local file name
to name the remote file, and the remote file name is altered by any settings
made by the ntrans and nmap subcommands. The ftp command uses the current
settings for the type, form, mode, and struct subcommands while transferring
the files.

pwd Displays the name of the current directory on the remote host.

quit Closes the connection and exits the ftp command. Same as the bye
subcommand.

quote String Sends the string specified by the String parameter verbatim to the
remote host. Execute the remotehelp or quote help subcommand to display a list
of valid values for the String parameter.

Note: "Quoting" commands that involve data transfers can produce
unpredictable results.

record Synonym for the struct record subcommand.

recv RemoteFile [LocalFile] Copies the remote file to the local host. Same as
the get subcommand.

reinitialize Reinitializes an FTP session by flushing all I/O and allowing
transfers to complete. Resets all defaults as if a user had just started an FTP
session without logging in to a remote host.

remotehelp [Subcommand] Requests help from the remote FTP server.

rename FromName ToName Renames a file on the remote host.

reset Clears the reply queue. This subcommand resynchronizes the command
parsing.

restart get | put | append Restarts a file transfer at the point where the last
checkpoint was made. To run successfully, the subcommand must be the same as
the aborted subcommand, including structure, type, and form. Valid arguments
are get, put, and append.

rmdir RemoteDirectory Removes the remote directory specified by the
RemoteDirectory parameter at the remote host.

runique (ReceiveUnique) Toggles the facility for creating unique file names for
local destination files during get and mget subcommands. If this facility is
Off (the default), the ftp command overwrites local files. Otherwise, if a
local file has the same name as that specified for a local destination file,
the ftp command modifies the specified name of the local destination file with
.1. If a local file is already using the new name, the ftp command appends the
postfix .2 to the specified name. If a local file is already using this second
name, the ftp command continues incrementing the postfix until it either finds
a unique file name or reaches .99 without finding a unique file name. If the
ftp command cannot find a unique file name, the ftp command reports an error
and the transfer does not take place. Note that the runique subcommand does not
affect local file names generated from a shell command.

safe Sets the protection level to "safe." At this level, data is integrity
protected.

send LocalFile [RemoteFile] Stores a local file on the remote host. Same as the
put subcommand.

sendport Toggles the use of FTP PORT instructions. By default, the ftp command
uses a PORT instruction when establishing a connection for each data transfer.
When the use of PORT instructions is disabled, the ftp command does not use
PORT instructions for data transfers. The PORT instruction is useful when
dealing with FTP servers that ignore PORT instructions while incorrectly
indicating the instructions have been accepted.

site Args Displays or sets the idle time-out period, displays or sets the
file-creation umask, or changes the permissions of a file, using the chmod
command. Possible values for the Args parameter are umask and chmod.

size RemoteFile Displays the size in bytes of the remote file specified by the
RemoteFile parameter.

status Displays the current status of the ftp command as well as the status of
the subcommands.

stream Synonym for the mode stream subcommand.

struct [ file | record ] Sets the data transfer structure type. Valid arguments
are file and record.

file
Sets the data-transfer structure type to file.
record
Sets the data-transfer structure type to record.

sunique (Send/Store Unique) Toggles the facility for creating unique file names
for remote destination files during put and mput subcommands. If this facility
is off (the default), the ftp command overwrites remote files. Otherwise, if a
remote file has the same name as that specified for a remote destination file,
the remote FTP server modifies the name of the remote destination file. Note
that the remote server must support the STOU instruction.

system Shows the type of operating system running on the remote machine.

telnet Synonym for the form telnet subcommand.

tenex Synonym for the type tenex subcommand.

trace Toggles packet tracing.

type [ ascii | binary | ebcdic | image | local M | tenex ] Sets the
file-transfer type. Valid arguments are ascii, binary, ebcdic, image, local M,
and tenex. If an argument is not specified, the current type is printed. The
default type is ascii; the binary type can be more efficient than ascii.

ascii
Sets the file-transfer type to network ASCII. This type is the default. File
transfer may be more efficient with binary-image transfer. See the binary
argument for further information.
binary
Sets the file-transfer type to binary image. This type can be more efficient
than an ASCII transfer.
ebcdic
Sets the file-transfer type to EBCDIC.
image
Sets the file-transfer type to binary image. This type can be more efficient
than an ASCII transfer.
local M
Sets the file-transfer type to local. The M parameter defines the decimal
number of bits per machine word. This parameter does not have a default.
tenex
Sets the file-transfer type to that needed for TENEX machines.

user User [Password] [Account] Identifies the local user (User) to the remote
FTP server. If the Password or Account parameter is not specified and the
remote server requires it, the ftp command prompts for the password or account
locally. If the Account parameter is required, the ftp command sends it to the
remote server after the remote login process completes.

Note: Unless automatic login is disabled by specifying the -n flag on the
command line, the ftp command sends the User, Password, and Account
parameters automatically for the initial connection to the remote server.
You also need a .netrc file in your home directory in order to issue an
automatic login.

verbose Toggles verbose mode. When the verbose mode is on (the default), the
ftp command displays all responses from the remote FTP server. Additionally,
the ftp command displays statistics on all file transfers when the transfers
complete.

Examples:

1. To invoke the ftp command, log in to the system canopus, display local
help information, display remote help information, display status, toggle
the bell, prompt, runique, trace, and verbose subcommands, and then quit,
enter:

$ ftp canopus

Connected to canopus.austin.century.com.

220 canopus.austin.century.com FTP server (Version 4.1 Sat Nov 23 12:52:09
CST 1991) ready.

Name (canopus:eric): dee

331 Password required for dee.

Password:

230 User dee logged in.

ftp> help

Commands may be abbreviated. Commands are:

! delete mdelete proxy runique

$ debug mdir sendport send

account dir mget put size

append disconnect mkdir pwd status

ascii form mls quit struct

bell get mode quote sunique

binary glob modtime recv system

bye hash mput remotehelp tenex

case help nmap rstatus trace

cd image nlist rhelp type

cdup lcd ntrans rename user

close ls open reset verbose

cr macdef prompt rmdir ?

clear private protect safe

ftp> remotehelp

214-The following commands are recognized(* =>'s unimplemented).

USER PORT RETR MSND* ALLO DELE SITE* XMKD CDUP

PASS PASV STOR MSOM* REST* CWD STAT* RMD XCUP

ACCT* TYPE APPE MSAM* RNFR XCWD HELP XRMD STOU

REIN* STRU MLFL* MRSQ* RNTO LIST NOOP PWD

QUIT MODE MAIL* MRCP* ABOR NLST MKD XPWD

AUTH ADAT PROT PBSZ MIC ENC CCC

214 Direct comments to ftp-bugs@canopus.austin.century.com.

ftp> status

Connected to canopus.austin.century.com.

No proxy connection.

Mode: stream; Type: ascii; Form: non-print; Structure: file

Verbose: on; Bell: off; Prompting: on; Globbing: on

Store unique: off; Receive unique: off

Case: off; CR stripping: on

Ntrans: off

Nmap: off

Hash mark printing: off; Use of PORT cmds: on

ftp> bell

Bell mode on.

ftp> prompt

Interactive mode off.

ftp> runique

Receive unique on.

ftp> trace

Packet tracing on.

ftp> verbose

Verbose mode off.

ftp> quit

$

2. To invoke the ftp command, log in to the system canopus, print the working
directory, change the working directory, set the file transfer type to
ASCII, send a local file to the remote host, change the working directory
to the parent directory, and then quit, enter:

$ ftp canopus

Connected to canopus.austin.century.com.

220 canopus.austin.century.com FTP server (Version 4.1 Sat Nov 23 12:52:09
CST 1991) ready.

Name (canopus:eric): dee

331 Password required for dee.

Password:

230 User dee logged in.

ftp> pwd

257 "/home/dee" is current directory.

ftp> cd desktop

250 CWD command successful.

ftp> type ascii

200 Type set to A.

ftp> send typescript

200 PORT command successful.

150 Opening data connection for typescript (128.114.4.99,1412).

226 Transfer complete.

ftp> cdup

250 CWD command successful.

ftp> bye

221 Goodbye.

$

3. To invoke the ftp command with automatic logon (using the .netrc file),
open a session with the system canopus, log in, change the working
directory to the parent directory, print the working directory, list the
contents of the current directory, delete a file, write a listing of the
contents of the current directory to a local file, close the session, and
then quit, enter:

$ ftp canopus

Connected to canopus.austin.century.com.

220 canopus.austin.century.com FTP server (Version 4.1 Sat Nov 23 12:52:09
CST 1991) ready.

331 Password required for dee.

230 User dee logged in.

ftp> cdup

250 CWD command successful.

ftp> pwd

257 "/home" is current directory.

ftp> dir

200 PORT command successful.

150 Opening data connection for /usr/bin/ls (128.114.4.99,1407)

(0 bytes).

total 104

drwxr-xr-x 2 system 32 Feb 23 17:55 bin

Drwxr-xr-x 26 rios 4000 May 30 17:18 bin1

drwxr-xr-x 2 system 32 Feb 23 17:55 books

drwxrwxrwx 18 rios 1152 Jun 5 13:41 dee

-r--r--r-- 1 system 9452 May 17 12:21 filesystems

drwxr-xr-x 2 system 32 Feb 23 17:55 jim

drwxr-xr-x 5 system 80 Feb 23 17:55 krs

drwxrwxrwx 2 rios 16432 Feb 23 17:36 lost+found

-rwxr-xr-x 1 rios 3651 May 24 16:45 oldmail

drwxr-xr-x 2 system 256 Feb 23 17:55 pubserv

drwxrwxrwx 2 system 144 Feb 23 17:55 rein989

drwxr-xr-x 2 system 112 Feb 23 17:55 reinstall

226 Transfer complete.

ftp> delete oldmail

250 DELE command successful.

ftp> mdir /home/dee/bin binlist

output to local-file: binlist? y

200 PORT command successful.

150 Opening data connection for /usr/bin/ls (128.114.4.99,1408) (0 bytes).

226 Transfer complete.

ftp> close

221 Goodbye.

ftp> quit

$

Files

/usr/samples/tcpip/netrc Contains the sample .netrc file.

/etc/syslog.conf Contains configuration information for the syslogd daemon.

Related Information

The csh command, kill command, rcp command, refresh command, rlogin command,
rsh command, stty command, telnet command, tftp command.

The ftpd daemon, the syslogd daemon.

The .netrc file format.

Copying Files Using the ftp Command in AIX 5L Version 5.2 System User's Guide:
Communications and Networks.

Network Overview in AIX 5L Version 5.2 System Management Guide: Communications
and Networks.

Secure Rcmds in AIX 5L Version 5.2 System User's Guide: Communications and
Networks.

Network Option Tunable Parameters in AIX 5L Version 5.2 Performance Management
Guide.

du Command

Purpose:

Summarizes disk usage.

Syntax:

du [ -a | -s ] [ -k ] [ -m ] [ -g ][ -l ] [ -r ] [ -x ] [ -H | -L ][ File ... ]

Description:

The du command displays the number of blocks used for files. If the File
parameter specified is actually a directory, all files within the directory are
reported on. If no File parameter is provided, the du command uses the files in
the current directory.

If the File parameter is a directory, then the number of blocks reported is the
sum of blocks allocated for the files in the directory and the blocks allocated
for the directory itself.

Specifying the -a flag reports the number of blocks in individual files.
Whether the -a flag is used or not, individual files specified by the File
parameter are always listed.

Specifying the -s flag reports the total blocks for all specified files or all
files in a directory.

The block count includes indirect blocks of each file. Block count is
calculated in 512-byte units independent of the cluster size used by the
system. Specifying the -k flag calculates the block count in 1024-byte units.
Notes:

1. Files with multiple links are counted and written for only one entry.
2. Block counts are based only on file size; therefore, unallocated blocks
are not accounted for in the reported block counts.
3. If du cannot obtain the file attributes or cannot read directories, it
reports an error and the exit status of the command is affected.

Flags:

-a Displays disk usage for each file specified, or displays the individual disk
usage for each file in a directory. Contrast this flag with the -s flag.

-g Calculates the block count in GB 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.

-H If a symbolic link is specified on the command line, the du command shall
count the size of the file or file hierarchy referenced by the link.

-k Calculates the block count in 1024-byte units rather than the default
512-byte units.

-l Allocates blocks evenly among the links for files with multiple links. By
default, a file with two or more links is counted only once.

-L If a symbolic link is specified on the command line or encountered during
the traversal of a file hierarchy, the du command shall count the size of the
file or file hierarchy referenced by the link.

-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.

-r Reports names of inaccessible files and directories. This is the default.

-s Displays the total disk usage for all specified files, or displays the total
disk usage for all files in a directory. Contrast this flag with the -a flag.

-x When evaluating file sizes, evaluates only those files that reside on the
same device as the file or directory specified by the File parameter. For
example, you may specify a directory that contains files on several devices. In
this case, the -x flag displays block sizes for all files that reside on the
same device as the directory.

If all or any two of the -k, -m and -g flags are specified, the last one
specified takes effect. The output of the disk usage with the flags -m and -g
would be rounded off to the nearest second decimal digit.

Exit Status

This command returns the following exit values:

0 Successful completion.

>0 An error occurred.

Examples:

1. To summarize the disk usage of a directory tree and each of its subtrees,
enter:

du /home/fran

This displays the number of disk blocks in the /home/fran directory and
each of its subdirectories.
2. To summarize the disk usage of a directory tree and each of its subtrees
in 1024-byte blocks, enter:
du -k /home/fran

This displays the number of 1024-byte disk blocks in the /home/fran
directory and each of its subdirectories.
3. To summarize the disk usage of a directory tree and each of its subtrees
in MB blocks, enter:
du -m /home/fran

This displays the number of MB disk blocks rounded off to nearest 2nd
decimal digit in the /home/fran directory and each of its subdirectories.
4. To summarize the disk usage of a directory tree and each of its subtrees
in GB blocks, enter:
du -g /home/fran

This displays the number of GB disk blocks rounded off to nearest 2nd
decimal digit in the /home/fran directory and each of its subdirectories.
5. To display the disk usage of each file, enter:
du -a /home/fran

This displays the number of disk blocks contained in each file and
subdirectory of the /home/fran directory. The number beside a directory is
the disk usage of that directory tree. The number beside a regular file is
the disk usage of that file alone.
6. To display only the total disk usage of a directory tree, enter:
du -s /home/fran

The -s flag instructs the du command to display only the sum total disk
usage of the /home/fran directory and the files it contains. By default,
the du command displays an error message if it cannot read a file or
directory.
7. To display the disk usage of the files and file hierarchies referenced by
all the symbolic links in addition to the normal files found during
traversal of a the /home/fran directory, type:
du -L /home/fran

8. To report the disk usage of the file or file hierarchy referenced by the
symbolic link mylink, type:
du -H mylink

df Command

Purpose:

Reports information about space on file systems. This document describes the
AIX df command as well as the System V version of df.

Syntax:

df [ [ -P ] | [ -I | -M | -i | -t | -v ] ] [ -k ] [ -m ] [ -g ] [ -s ]
[FileSystem ... | File... ]

Description:

The df command displays information about total space and available space on a
file system. The FileSystem parameter specifies the name of the device on which
the file system resides, the directory on which the file system is mounted, or
the relative path name of a file system. The File parameter specifies a file or
a directory that is not a mount point. If the File parameter is specified, the
df command displays information for the file system on which the file or
directory resides. If you do not specify the FileSystem or File parameter, the
df command displays information for all currently mounted file systems. File
system statistics are displayed in units of 512-byte blocks by default.

The df command gets file system space statistics from the statfs system call.
However, specifying the -s flag gets the statistics from the virtual file
system (VFS) specific file system helper. If you do not specify arguments with
the -s flag and the helper fails to get the statistics, the statfs system call
statistics are used. Under certain exceptional conditions, such as when a file
system is being modified while the df command is running, the statistics
displayed by the df command might not be accurate.
Note: Some remote file systems, such as the Network File System (NFS), do not
provide all the information that the df command needs. The df command prints
blanks for statistics that the server does not provide.

Flags:


-g Displays statistics in units of GB blocks. The output values for the file
system statistics would be in floating point numbers as value of each unit in
bytes is significantly high.

-i Displays the number of free and used i-nodes for the file system; this
output is the default when the specified file system is mounted.

-I Displays information on the total number of blocks, the used space, the free
space, the percentage of used space, and the mount point for the file system.

-k Displays statistics in units of 1024-byte blocks.

-m Displays statistics in units of MB blocks. The output values for the file
system statistics would be in floating point numbers as value of each unit in
bytes is significantly high.

-M Displays the mount point information for the file system in the second
column.

-P Displays information on the file system in POSIX portable format.

When the -P flag is specified, the header line appears similar to:

Filesystem 512-blocks Used Available Capacity Mounted on\n

If the -k, -m or -g flag is specified in addition to the -P flag, the column
heading 512-blocks is replaced by the respective units, depending on which of
these flags is used with the -P flag.

File system statistics are displayed on one line in the following order:

FileSystem, TotalSpace, UsedSpace, FreeSpace, UsedPercentage, MountPoint

-s Gets file system statistics from the VFS specific file system helper instead
of the statfs system call. Any arguments given when using the -s flag must be a
JFS or Enhanced JFS filesystem mount point or device. The filesystem must also
be listed in /etc/filesystems.

-t Includes figures for total allocated space in the output.

-v Displays all information for the specified file system.

The values of the output parameters with the flags -m and -g would be rounded
off to nearest second decimal digit. If all or any two of the -k, -m and -g
flags are specified, the last one specified takes effect.

Exit Status

This command returns the following exit values:

0 Successful completion.

>0 An error occurred.

Examples:


1. To display information about all mounted file systems, enter:

df

If your system has the /, /usr, /site, and /usr/venus file systems
mounted, the output from the df command resembles the following:
Filesystem 512-blocks Free %Used Iused %Iused Mounted on

/dev/hd0 19368 9976 48% 4714 5% /

/dev/hd1 24212 4808 80% 5031 19% /usr

/dev/hd2 9744 9352 4% 1900 4% /site

/dev/hd3 3868 3856 0% 986 0% /usr/venus

2. To display information about /test file system in 1024-byte blocks, enter:
df -k /test

Filesystem 1024 blocks Free %Used Iused %Iused Mounted on

/dev/lv11 16384 15824 4% 18 1% /tmp/ravi1

This displays the file system statistics in 1024-byte disk blocks.
3. To display information about /test file system in MB blocks, enter:
df -m /test

Filesystem MB blocks Free %Used Iused %Iused Mounted on

/dev/lv11 16.00 15.46 4% 18 1% /tmp/ravi1

This displays file system statistics in MB disk blocks rounded off to
nearest 2nd decimal digit.
4. To display information about the /test file system in GB blocks, enter:
df -g /test

Filesystem GB blocks Free %Used Iused %Iused Mounted on

/dev/lv11 0.02 0.02 0% 18 1% /tmp/ravi1

This displays file system statistics in GB disk blocks rounded off to
nearest 2nd decimal digit.
5. To display available space on the file system in which your current
directory resides, enter:

cd/

df .

The output from this command resembles the following:
Device 512-blocks free %used iused %iused Mounted on

/dev/hd4 19368 9976 48% 4714 5% /

Files

/etc/filesystems Lists the known file systems and defines their
characteristics.

/etc/vfs Contains descriptions of virtual file system types.

Related Information

The fsck command.

The filesystems file.

The File Systems Overview for System Management in AIX 5L Version 5.2 System
Management Concepts: Operating System and Devices explains file system types,
management, structure, and maintenance.

The Mounting Overview in AIX 5L Version 5.2 System Management Concepts:
Operating System and Devices explains mounting files and directories, mount
points, and automatic mounts.

System V df Command

Purpose:

Reports number of free disk blocks and files.

Syntax:

/usr/sysv/bin/df [ -a ] [ -l ] [ [ [ -e ] [-g ] [ -n ] ] | [ [ -i ] [ -v ] ] |
-t ] ] [FileSystem ...] [File ...]

Description:


The df command displays information about total space and available space on a
file system. File system statistics are displayed in units of 512-byte blocks

Flags:

-a Performs the default operation and prints the mount point, the device name,
number of free blocks and number of used inodes (files).

-e Print only the number of free files.

-g Print the entire statvfs structure. This option overrides the -a , -e, -i,
-n, -t and -v options. The numbers for available, total, and free blocks are
reported in 512 byte blocks.

-i Displays the total number of inodes, the number of free inodes, the number
of used inodes, and the percentage of inodes in use.

-l Reports on local file systems only.

-n Prints the type of filesystem.

-t Causes total allocated block figures to be reported.

-v Reports percent of blocks used as well as the number of blocks used and
free.

Parameters:


File The File parameter specifies a file or a directory that is not a mount
point. If the File parameter is specified, the df command displays information
for the file system on which the file or directory resides.

FileSystem The FileSystem parameter specifies the name of the device on which
the file system resides, the directory on which the file system is mounted, or
the relative path name of a file system.
Note: If the FileSystem or File parameter is not specified, the df command
displays information for all currently mounted file systems.

Exit Status

0
The command completed successfully
>0
An error occurred.

Examples:

1. To display information about all mounted file systems, enter:
/usr/sysv/bin/df

The output looks similar to the following:
/ (/dev/hd4 ): 19656 blocks 1504 files

/usr (/dev/hd2 ): 1139904 blocks 20254 files

/var (/dev/hd9var ): 23096 blocks 512 files

/tmp (/dev/hd3 ): 2464 blocks 204 files

/home (/dev/hd1 ): 44208 blocks 146 files

/proc (/proc ): 0 blocks 0 files

/opt (/dev/hd10opt ): 13880 blocks 310 files

2. To display information about the file system in which your current
directory resides, enter:
/usr/sysv/bin/df .

3. To display the total number of inode, the number of free inodes and the
number of available inodes in all mounted file systems, enter:
/usr/sysv/bin/df -i

The output looks similar to the following:
Mount Dir Filesystem iused avail itotal %iused

/ /dev/hd4 1504 6688 8192 19%

/usr /dev/hd2 20254 127202 147456 14%

/var /dev/hd9var 512 3584 4096 13%

/tmp /dev/hd3 204 5940 6144 4%

/home /dev/hd1 146 14190 14336 2%

/proc /proc 0 0 0 0

/opt /dev/hd10opt 310 5834 6144 6%

4. To display the total number of blocks , the number of used blocks and the
number of free blocks on a the /tmp file system, enter:
/usr/sysv/bin/df -v /tmp

5. To display the type of filesystem, enter:
/usr/sysv/bin/df -n

6. To display inode information on all local filesystems, enter:
/usr/sysv/bin/df -i -l

7. To display the statvfs structure information on all the filesystems,
enter:
/usr/sysv/bin/df -g

8. To display the number of free files on filesystems, enter:
/usr/sysv/bin/df -e

date Command

Purpose:

Displays or sets the date or time.

Syntax:

To Set the Date and Time as Root User

/usr/bin/date [ -n ] [ -u ] [ Date ] [ +FieldDescriptor ... ]

To Display the Date and Time

/usr/bin/date [ -u ] [ +FieldDescriptor ... ]

To adjust the Time in Seconds as root User

/usr/bin/date [ -a [ + | - ]sss[.fff ]

Description:


Attention: Do not change the date when the system is running with more than one
user.

The date command writes the current date and time to standard output if called
with no flags or with a flag list that begins with a + (plus sign). Otherwise,
it sets the current date. Only a root user can change the date and time. The
date command prints out the usage message on any unrecognized flags or input.

The following formats can be used when setting the date with the Date
parameter:

o mmddHHMM[YYyy]
o mmddHHMM[yy]

The variables to the Date parameter are defined as follows:

mm Specifies the month number.

dd Specifies the number of the day in the month.

HH Specifies the hour in the day (using a 24-hour clock).

MM Specifies the minute number.

YY Specifies the first two digits of the year. Note: If you do not specify the
first two digits of the year, values in the range 69 to 99 refer to the
twentieth century, 1969 to 1999 inclusive, and values in the range 00 to 68
refer to years in the twenty-first century, 2000 to 2068 inclusive.

yy Specifies the last two digits of the year. Note: The date command accepts a
4 digit year as input. For example, if a four-digit year is specified, the date
command tries to set the year to "YYyy" and fails for values which are out of
range (less than 1970 and greater than 2037).

The current year is used as the default value when the year is not specified.
The system operates in Coordinated Universal Time (CUT).

If you follow the date command with a + (plus sign) and a field descriptor, you
can control the output of the command. You must precede each field descriptor
with a % (percent sign). The system replaces the field descriptor with the
specified value. Enter a literal % as %% (two percent signs). The date command
copies any other characters to the output without change. The date command
always ends the string with a new-line character.

Flags:

-a [ + | - ]sss[.fff ] Slowly adjusts the time by sss.fff seconds (fff
represents fractions of a second). This adjustment can be positive or negative.
The system's clock will be sped up or slowed down until it has drifted by the
number of seconds specified.

-n Does not set the time globally on all machines in a local area network that
have their clocks synchronized.

-u Displays or sets the time in Coordinated Universal Time (CUT).

Field Descriptors

%a Displays the locale's abbreviated weekday name.

%A Displays the locale's full weekday name.

%b Displays the locale's abbreviated month name.

%B Displays the locale's full month name.

%c Displays the locale's appropriate date and time representation. This is the
default.

%C Displays the first two digits of the four-digit year as a decimal number
(00-99). A year is divided by 100 and truncated to an integer.

%d Displays the day of the month as a decimal number (01-31). In a two-digit
field, a 0 is used as leading space fill.

%D Displays the date in the format equivalent to %m/%d/%y.

%e Displays the day of the month as a decimal number (1-31). In a two-digit
field, a blank space is used as leading space fill.

%h Displays the locale's abbreviated month name (a synonym for %b).

%H Displays the hour (24-hour clock) as a decimal number (00-23).

%I Displays the hour (12-hour clock) as a decimal number (01-12).

%j Displays the day of year as a decimal number (001-366).

%m Displays the month of year as a decimal number (01-12).

%M Displays the minutes as a decimal number (00-59).

%n Inserts a character.

%p Displays the locale's equivalent of either AM or PM.

%r Displays 12-hour clock time (01-12) using the AM-PM notation; in the POSIX
locale, this is equivalent to %I:%M:%S %p.

%S Displays the seconds as a decimal number (00- 59).

%t Inserts a character.

%T Displays the 24-hour clock (00-23) in the format equivalent to HH:MM:SS .

%u Displays the weekday as a decimal number from 1-7 (Sunday = 7). Refer to the
%w field descriptor.

%U Displays week of the year(Sunday as the first day of the week) as a decimal
number[00 - 53] . All days in a new year preceding the first Sunday are
considered to be in week 0.

%V Displays the week of the year as a decimal number from 01-53 (Monday is used
as the first day of the week). If the week containing January 1 has four or
more days in the new year, then it is considered week 01; otherwise, it is week
53 of the previous year.

%w Displays the weekday as a decimal number from 0-6 (Sunday = 0). Refer to the
%u field descriptor.

%W Displays the week number of the year as a decimal number (00-53) counting
Monday as the first day of the week.

%x Displays the locale's appropriate date representation.

%X Displays the locale's appropriate time representation.

%y Displays the last two numbers of the year (00-99).

%Y Displays the four-digit year as a decimal number.

%Z Displays the time-zone name, or no characters if no time zone is
determinable.

%% Displays a % (percent sign) character.

Modified Field Descriptors

The %E and %O field descriptors can be modified to indicate a different format
or specification, as described in LC_TIME Category for the Locale Definition
Source File Format in AIX 5L Version 5.2 Files Reference. If the corresponding
keyword (see the era, era_year, era_d_fmt, and alt_digits keywords) is not
specified or not supported for the current locale, the unmodified field
descriptor value is used.

%Ec Displays the locale's alternative appropriate date and time representation.

%EC Displays the name of the base year (or other time period) in the locale's
alternative representation.

%Ex Displays the locale's alternative date representation.

%EX Displays the locale's alternative time representation.

%Ey Displays the offset from the %EC field descriptor (year only) in the
locale's alternative representation.

%EY Displays the full alternative year representation.

%Od Displays the day of the month using the locale's alternative numeric
symbols.

%Oe Displays the day of the month using the locale's alternative numeric
symbols.

%OH Displays the hour (24-hour clock) using the locale's alternative numeric
symbols.

%OI Displays the hour (12-hour clock) using the locale's alternative numeric
symbols.

%Om Displays the month using the locale's alternative numeric symbols.

%OM Displays minutes using the locale's alternative numeric symbols.

%OS Displays seconds using the locale's alternative numeric symbols.

%Ou Displays the weekday as a number in the locale's alternative representation
(Monday=1).

%OU Displays the week number of the year using the locale's alternative numeric
symbols. Sunday is considered the first day of the week.

%OV Displays the week number of the year using the locale's alternative numeric
symbols. Monday is considered the first day of the week.

%Ow Displays the weekday as a number in the locale's alternative representation
(Sunday =0).

%OW Displays the week number of the year using the locale's alternative numeric
symbols. Monday is considered the first day of the week.

%Oy Displays the year (offset from %C) in alternative representation.

Exit Status

This command returns the following exit values:

0 The date was written successfully.

>0 An error occurred.

Examples:

1. To display current date and time, enter:

date

2. To set the date and time, enter:

date 0217142590


For a system using CST as its time zone, this sets the date and time to
Sat Feb 17 14:25:00 CST 1990.

Note: You must have root authority to change the date and time.
3. To display the date and time in a specified format, enter:

date +"%r %a %d %h %y (Julian Date: %j)"

This displays the date shown in Example 2 as:
02:25:03 PM Fri 17 Feb 90 (Julian Date: 048)

Environment Variables

The following environment variables affect the execution of the date command.

LANG Determines the locale to use when both LC_ALL and the corresponding
environment variable (beginning with LC_) do not specify a locale.

LC_ALL Determines the locale to be used to override any values for locale
categories specified by the setting of LANG or any environment variable
beginning with LC_.

LC_CTYPE Determines the locale for the interpretation of sequences of bytes of
text data as characters (for example, single versus multibyte character in an
argument).

LC_MESSAGES Determines the language in which messages should be written.

LC_TIME Determines the contents of date and time strings written by date.

NLSPATH Determines the location of message catalogues for the processing of
LC_MESSAGES.

TZ Specifies the time zone in which the time and date are written, unless the
-u option is specified. If the TZ variable is not set and the -u flag is not
specified, an unspecified system default time zone is used.

cp Command

Purpose:

Copies files.

Syntax:

To Copy a File to another File

cp [ -E{force|ignore|warn} ] [ -f ] [ -h ] [ -i ] [ -p ][ -- ] SourceFile
TargetFile

To Copy a File to a Directory

cp [ -E{force|ignore|warn} ] [ -f ] [ -h ] [ -i ] [ -p ] [[ -r | -R ] [ -H | -L
| -P ]] [ -- ] SourceFile ... TargetDirectory

To Copy a Directory to a Directory

cp [ -E{force|ignore|warn} ] [ -f ] [ -h ] [ -i ] [ -p ] { -r | -R } [ -H | -L
| -P ] [ -- ] SourceDirectory ... TargetDirectory

Description:


The cp command copies the source file specified by the SourceFile parameter to
the destination file specified by the TargetFile parameter. If the target file
exists, cp overwrites the contents, but the mode, owner, and group associated
with it are not changed. The last access time of the SourceFile and the last
modification time of the TargetFile are set to the time the copy was done. If
the TargetFile does not exist, cp creates a new file named TargetFile that has
the same mode as the source file except that the sticky bit is not set unless
it was done by a superuser; the owner and group of the TargetFile is that of
the user. When the TargetFile is a link to another file, cp overwrites the
destination link with the content of the source file; the links from the
TargetFile remains. Also, the cp command can copy the source files specified by
the SourceFile parameter (or directories named by the SourceDirectory
parameter) to the directory specified by the TargetDirectory parameter.

Note: If one of the source parameters is a directory, you need to specify
one of the -r or -R flags.

If any directories are created by the cp command during the copying process,
the newly created directory will have the same mode as the corresponding source
directory.

You can also copy special device files. The preferred option for accomplishing
this is the -R flag. Specifying -R causes the special files to be re-created
under the new path name. Specifying the -r flag causes the cp command to
attempt to copy the special file to a regular file.

Flags:

-E The -E option requires one of the following arguments. If you omit the -E
option, warn is the default behavior.

force
Fails the cp operation on a file if the fixed extent size or space
reservation of the file cannot be preserved.

ignore
Ignores any errors in preserving extent attributes.

warn
Issues a warning if the space reservation or the fixed extent size of the
file cannot be preserved.

-f Specifies removal of the target file if it cannot be opened for write
operations. The removal precedes any copying performed by the cp command.

-h Forces the cp command to copy symbolic links. The default is to follow
symbolic links, that is, to copy files to which symbolic links point.

-H Take actions based on the type and contents of the file referenced by any
symbolic link specified as a SourceFile operand.

-i Prompts you with the name of a file to be overwritten. This occurs if the
TargetDirectory or TargetFile parameter contains a file with the same name as a
file specified in the SourceFile or SourceDirectory parameter. If you enter y
or the locale's equivalent of y, the cp command continues. Any other answer
prevents the cp command from overwriting the file.

-L Take actions based on the type and contents of the file referenced by any
symbolic link specified as a SourceFile operand or any symbolic links
encountered during traversal of a file hierarchy.

-p Duplicates the following characteristics of each SourceFile/SourceDirectory
in the corresponding TargetFile and/or TargetDirectory:

o The time of the last data modification and the time of the last access. If
this duplication fails for any reason, the cp command will write a
diagnostic message to standard error.
o The user ID and group ID. If this duplication fails for any reason, the cp
command may write a diagnostic message to standard error.
o The file permission bits and the S_ISUID and S_ISGID bits. If this
duplication fails for any reason, the cp command will write a diagnostic
message to standard error.

If the user ID or group ID cannot be duplicated, the file permission bits
S_ISUID and S_ISGID are cleared.

In order to preserve the owner ID and group ID, permission modes, modification
and access times, user must have the appropriate file access permissions (user
should be a superuser or have the same owner ID as the destination file)

The target file will not be deleted if these characteristics cannot be
preserved.

Access control lists (ACLs) associated with the SourceFile are also preserved.
See User Accounts in AIX 5L Version 5.2 System User's Guide: Operating System
and Devices to learn more about ACLs.

-P Take actions on any symbolic link specified as a SourceFile operand or any
symbolic link encountered during traversal of a file hierarchy.

-r Copies file hierarchies under the file or directory specified by the
SourceFile or SourceDirectory parameter (recursive copy). The -r flag processes
special files in the same manner as regular files.

-R Copies file hierarchies under the regular files and directories from the
directory specified by the SourceFile or SourceDirectory parameter to the
directory specified by the TargetDirectory parameter. Special file types, such
as first-in, first-out (FIFO) files and block and character device files, are
re-created instead of copied. Symbolic links are followed unless the -h flag is
specified. (The -R flag is preferred to the -r flag.)

If none of the -H, -L, or -P options were specified, it is unspecified which of
those options will be used as the default. Consider the following:

o If the -H option was specified, the cp command will take action based on
the type and contents of the file referenced by any symbolic link specified
as a SourceFile operand.
o If the -L option was specified, the cp command will take action based on
the type and contents of the file referenced by any symbolic link specified
as a SourceFile operand or any symbolic links encountered during traversal
of a file hierarchy.
o If the -P option was specified, the cp command will copy any symbolic link
specified as a SourceFile operand and any symbolic links encountered during
traversal of a file hierarchy and will not follow any symbolic links.

-- Indicates that parameters following the -- (dash, dash) flag are to be
interpreted as file names. This null flag allows the specification of file
names that start with a - (minus sign).

Exit Status

This command returns the following exit values:

0 All files were copied successfully.

>0 An error occurred.

Examples:

1. To make a copy of a file in the current directory, enter:

cp prog.c prog.bak

This copies prog.c to prog.bak. If the prog.bak file does not already
exist, the cp command creates it. If it does exist, the cp command
replaces it with a copy of the prog.c file.
2. To copy a file in your current directory into another directory, enter:

cp jones /home/nick/clients

This copies the jones file to /home/nick/clients/jones.
3. To copy a file to a new file and preserve the modification date, time, and
access control list associated with the source file, enter:

cp -p smith smith.jr

This copies the smith file to the smith.jr file. Instead of creating the
file with the current date and time stamp, the system gives the smith.jr
file the same date and time as the smith file. The smith.jr file also
inherits the smith file's access control protection.
4. To copy all the files in a directory to a new directory, enter:

cp /home/janet/clients/* /home/nick/customers

This copies only the files in the clients directory to the customers
directory.
5. To copy a directory, including all its files and subdirectories, to
another directory, enter:

cp -R /home/nick/clients /home/nick/customers

Note: A directory cannot be copied into itself. This copies the clients
directory, including all its files, subdirectories, and the files in those
subdirectories, to the customers/clients directory.
6. To copy a specific set of files to another directory, enter:

cp jones lewis smith /home/nick/clients

This copies the jones, lewis, and smith files in your current working
directory to the /home/nick/clients directory.
7. To use pattern-matching characters to copy files, enter:

cp programs/*.c .

This copies the files in the programs directory that end with .c to the
current directory, signified by the single . (dot). You must type a space
between the c and the final dot.

Find It