General Commands

  • id – displays the system identity of the user
  • lslicense – list maximum number of users
  • last – information about previous logins
  • w – lists summary of current users
  • who – displays information about all current users
  • uname – displays system info
  • type – shows path location
  • whereis – shows path location
  • what – displays header information about the source file
  • whatis – displays a short description of a function
  • basename – returns the base file name
  • ac – displays connect time
  • date – displays or sets the date
  • timex – displays the elapsed time
  • cmp – compares two files
  • diff – compares text files
  • head or tail – display start or end of file
  • od – dumps the contents of a file
  • split – makes smaller files from a large one
  • cut – cuts out selected text
  • tr – translates characters
  • sed – stream edit command to change text
  • nl – produces an OUTPUT file by inserting the line number
  • captoinfo – converts termcap to terminfo
  • nvdmetoa – convert EBCDIC files to ASCII
  • sum – displays checksum for a file
  • errclear – deletes entries in the error log
  • errpt – generates an error report
  • diag – performs hardware problem determination
  • trace – kernel debugging
  • at – schedules jobs
  • batch – run 1 or more jobs in the background
  • nice – execute a command at a lower priority
  • tee – used to preserve output from a pipeline
  • find – finds files with matching expressions
  • grep – searches a file for a pattern
  • kill – stop a process
  • stopsrc – gracefully shuts down all subsystems
  • shutdown – shutdown system
  • fastboot – restarts the system without running fsck
  • fasthalt – halts the system
  • lsitab – list contents of the /etc/inittab file
  • rmitab – removes an entry from the /etc/inittab
  • telinit – forces the init process to re-read the /etc/inittab
  • strip – removes symbol table
  • xargs – constructs an argument list

top of page


ac – Displays connect time totals for users

Example: ac root

Outputs: total 52.80 seconds

top of page


at – Schedules jobs to run at a later date

Examples What it does
at 17:002) banner CALL HOME > /dev/tty0^D At 5:00 p.m., message CALL HOME is written to terminal tty0
at 18:002) make -f /u/roger/makefile3) ^D Compiles files specified in /u/roger/makefile. Results of this compilation are sent to user’s mailbox who initiated the ‘at’ request.
at -l List jobs in at queue.root.686858340.a Mon Oct 07 12:59:00 1991
at -r root.686858340.a Removes a job from at queue.at file: root.686858340.a deleted

top of page


basename – Returns the base file name of a string

Example: echo `basename \`pwd\“

Returns the name of the current directory your in. Does not show the full pathname of that directory.

top of page


batch – Run 1 or more jobs in the background.

All output will be sent to the mail system. Jobs submitted are started immediately.

Example:
batch
job1
job2
^D

Note: Once a batch job starts, it’s job number can’t be seen via the at -l because that job is no longer in the batch queue – it’s a running process.

Further, once a batch job is running, it can’t be canceled by the at -r <job #> command since this only cancels jobs that are still pending in the batch/at queue.

top of page


captoinfo – Converts a termcap source file to a terminfo source file

Example: captoinfo Wyse150.tc > wyse150.ti

Once the termcap file (*.tc) has been translated to a terminfo (*.ti) file, compile the .ti file with the tic compiler (tic wyse150.ti).

top of page


cmp – Compares two files for differences

Example: cmp test1 test2

If the files are identical, no message is displayed, else the first difference is displayed.

top of page


cut – Cuts out selected text from a file or environment variable

Examples What it does
echo `date|cut -d’ ‘ -f2` Oct (returns the month from the date command )
cat /etc/passwd|cut -d: -f1,3 Will output the 1st and 3rd field delimited by ‘:‘ from the /etc/passwd file:root:0
daemon:1
bin:2
lpd:104

top of page


date – Displays or sets the date/time.

Date format is: mmddHHMM.SSyy

Example: date 02030830.0054 (This sets the date/time to Feb 03 08:30:00 CST 1954)

top of page


iag – Performs hardware problem determination

  • FORMAT & CERTIFY: Writes all of the ID fields and writes a bit pattern in all of the data fields. Also reassigns data blocks that are BAD during formatting. If too many BAD BLOCKS, a message is sent to alert operator. If data resides on the PV being formatted, it will be removed – lost forever.
  • CERTIFY DISK Reads all ID and data fields. Checks for BAD DATA in the ID and data fields. If too many BAD BLOCKS, a message is sent to the alert operator that it’s time to get another disk drive before this one fails.

NOTE: The software defect map is written at block of the PV device. This map is 22 blocks in size (AIX 3.1 version) and has enough space to hold about 1400 defects. Hardware relocations are performed only on WRITE operations where a READ request will return an I/O error back to the requesting application.

top of page


diff – Compares text files for differences

Example: diff -wi filea fileb
-w ignores all spaces and tab characters
-i case insensitive
top of page


errclear – Deletes entries in the error log

Example: errclear 0 (Truncates the errlog to 0 bytes)

top of page


errpt – Generates an error report from entries in the error log

Examples What it does
errpt -a|pg Produces a detailed report for each entry in the error log
errpt -aN hdisk1 Displays an error log for ALL errors occurred on this drive. If more than a few errors occur within a 24 hour period, execute the CERTIFY process under DIAGNOSTICS to determine if a PV is becoming marginal.
/etc/lpp/disagnostics/bin/run_ela Use this script to DETERMINE or JUSTIFY hard file REPLACEMENT. A message will be displayed on the CONSOLE device if a THRESHOLD value has been reached in regards to the number of hard file errors logged by the errpt utility. The following message may be seen: HDISKx : ERROR LOG ANALYSIS INDICATES A HARDWARE FAILURE. (x represents the hdisk number)

top of page


fastboot – Restarts the system without checking the file systems with the fsck command

top of page


fasthalt – Halts the system

top of page


find – Finds files with matching expressions

Note: If the following error message is generated find: 0652-081 cannot change directory to </transfer/printers>: file access permissions do not allow the specified action. This means that the user you are currently logged in as (even root) doesn’t have the authority to READ that directory.

Examples What it does
find / -name jan92.rpt -print Search all file systems for any file named jan92.rpt
find / -size +1000k -exec ls -l {} \; -print Searches all file systems to report back those files larger than 1MB in size
find / -size 0 -print Find all files of ZERO length
find / -type f -exec grep bananas {} \; -print Searches all plain files to determine if the string ‘bananas’ is contained within it
find /usr/lpp/FINANCIALS -print | xargs chown roger.staff Changes the ownership of all files under usr/lpp/FINANACIALS to be owned by user roger and have a group ownership of staff.
find / -user roger -print Find all files owned by user roger
find / -nouser -print Displays all unowned files in the system
find / -group staff -print Find all files owned by group staff
find / -nogroup staff -print List all files that belong to a non-existent group not found in /etc/group
find . -perm 600 -print | xargs chmod 666 Find all the files that have READ/WRITE permissions set for the owner of a file and change those permissions to READ/WRITE for everybody.
find / -mtime +100 -print Search all file systems for files that have not be modified in over 100 days.
find . -mtime 0 -print List all files in the current directory that have changed during the current 24 hour period.
find / -name /transfer -prune -o -print List the name of all files from the / (root) directory except for the NFS file system named /transfer
find . -name PERSONAL -prune -o -print List the name of all files in or below the current directory, except the directory named PERSONAL or files in that directory.
find / -fstype nfs -print List the name of all the files that reside in an NFS file system
find . -newer disk.log -print Display all files that have been modified more recently than the file named disk.log

top of page


grep – Searches a file for a pattern.

Grep stands for Global Regular Expression Printer

Examples What it does
grep -i WhereIs * Search all files in current directory to determine if the string ‘WhereIs’ is contained within it. The -i option ignores the case of letters (WhereIs is same as whereis)
lsdev -C|grep lp List all configured printers
grep [0-9][A-Z] *.doc List any file that has a .doc suffix that contains a number (0-9) followed by a capital letter (A-Z).
grep [^0-5][A-Z] *.doc List any file that has a .doc suffix that contains any number except 0 to 5 and is followed by a capital letter (A-Z)
grep “^IBM” *.doc Displays lines that BEGIN with the word IBM
grep “IBM$” *.doc Displays lines that END with the word IBM
grep “^IBM is GREAT$” *.doc Displays only those lines that consist of the phrase ‘IBM IS GREAT’
grep -v “^ *$” testfile > goodfile Removes all the blank lines from the source file ‘testfile’ and  redirects the output to a new file named ‘goodfile’.

top of page


head – Displays the first 10 lines (default) of a file.

Example: head -25 /tmp/phase2.out (Displays the first 25 lines of the file /tmp/phase2.out.)

top of page


id – Displays the system identity of the user

Examples What it does
id uid=0(root) gid=0(system)
id -ru Displays the UID of the current login process 0

top of page


last – Display information about previous logins stored in the /usr/adm/wtmp accounting file

Examples What it does
last reboot|head -5 List last 5 times systems has been rebooted
last roger Display times user roger has logged in/out of the system
last tty0 Display times users have logged in/out of port tty0

top of page


login – Initiates a new user session.

Example: login -h rs6000 root

Login to the root account on a machine whose hostname is rs6000

top of page


logout

Terminates all processes on the port your logged in on, including your login shell. Note: exit will perform the same action as logout.

Example: logout (Logs you off the system. Login prompt will reappear.)

top of page


lsitab – List contents of the /etc/inittab file

Example: lsitab -a

top of page


lslicense – List maximum number of users that can be concurrently logged in

Example: lslicense

Outputs: Maximum number of concurrent users: >32

top of page


kill – Sends a signal to stop or suspend a process from running

Example: kill -l (Lists valid signals to use with the kill command.)

top of page


nl

Produces an output file by inserting the line number of each line of an input file at the beginning of each line

Example: nl /etc/passwd > /tmp/user.list

top of page


nice – Execute a command at a lower priority.

Super-user may run commands with a higher priority by using a negative number. Higher numbers mean lower priorities (base priority is 10)

Examples What it does
nice -n 15 make Run the ‘make’ command at the low priority of 15
nice -10 /usr/bin/mview Run the ‘mview’ application at a high priority of 10

top of page


nvdmetoa – Convert EBCDIC files to ASCII

Examples What it does
nvdmetoa <AS400.dat  >AIXver3.dat Converts an EBCDIC file taken off an AS400 and converts to an ASCII file for the RS/6000
nvdmetoa 132 <AS400.txt  >AIXver3.txt Converts an EBCDIC file with a record length of 132 characters to an ASCII file with 132 bytes per line PLUS 1 byte for the linefeed character.

top of page


od

Dumps the contents of a file in the requested format (ASCII,octal, hex, or extended character set)

Examples What it does
od -c /tmp/rc.net.out -c displays bytes as ascii characters
1) od -cd2) \<FUNCTION KEY>3) \<SHIFT><FUNCTION KEY>

4) \<ALT><FUNCTION KEY>

By typing in this command, one may check the control codes being generated by function keys. From the command line, you press the ‘\’ (backslash) character, then press a function key which results in the escape sequence for that key to be displayed.

top of page


rmitab – Removes an entry from the /etc/inittab file

Example: rmitab ice (Removes the ice stanza from the /etc/inittab file)

top of page


sed – Stream edit command to change text.

Examples What it does
cat /tmp/mytest | sed -e “s/reports/report/” > /tmp/mytest All instances of the string “reports” is replaced with the string “report” for the file named /tmp/mytest
sed -e ‘s/ *$//’ < SOURCE_FILE > DESTINATION_FILE Removes trailing blanks, not internal blanks, from each line in a file
sed ‘/total/d’ /tmp/report > /tmp/report1 Delete all lines that contains the word total
sed ‘/^$/d’ /tmp/report > /tmp/report1 Delete all blank lines from file
sed ‘s/[ ]//g’ /ibm/report > /tmp/report Delete all tabs from file

top of page


shutdown – Shutdown system operations

Examples What it does
shutdown +0 Shuts down a system immediately.
shutdown -Fr Shuts down the system cleanly, followed by rebooting the system.
shutdown -Fm Shuts down the system into maintenance mode. When using the ‘m’ option, make sure you are at the console, because thats where control will be returned to.

top of page


split – Makes smaller files from a large one.

Each of the new files can be up to a specified number of lines long. The smaller files are each named with the input filename or a specified name, followed by an ‘x’ and an increasing two letter sequence (xaa, xab, etc).

top of page


stopsrc

Example: stopsrc -a

Gracefully shuts down all subsystems controlled by the SRC – System Resource Controller.

top of page


strip

Removes symbol table and other Extended Common Object File Format (XCOFF) data from an executable image.

Example: strip /usr/bin/uniplex

Reduces the storage overhead required by an executable file. This translates to less real memory usage required to have program run.

top of page


su

Runs a sub-shell with the effective user ID of the username passed in as a parameter to this command (root if no parameter is passed).  Type in ‘exit’, or ‘logout’ to return to previous user’s session.

Examples What it does
su roger Sets up environment as if you had logged in as user roger WITHOUT executing /etc/environment, $HOME/.profile or changing directories to $HOME for user roger.
su – root Initializes the user environment from attributes set in the etc/security/user database and /etc/environment file, followed by executing the $HOME/.profile and changing directories to $HOME. Basically sets up the environment as if you had logged in as root.

top of page


sum – Displays a checksum for a file.

Often used to validate if a file has been corrupted by comparing the suspect file’s checksum to that of a known good file. Used to verify if a file has been corrupted or a file transfer was sent/received properly.

Example: sum /unix
Outputs: 13042 1253 /unix

top of page


tail – Displays the last 10 lines (default) of a file.

Example: tail /tmp/phase2.out

top of page


tee

Used to preserve intermediate outputfrom within a pipeline to a file for later processing or review

Example: find . -cpio /dev/fd0 -print | tee /tmp/BACKUP.LOG

A list of the files backed up by the cpio command will be saved by the tee utility in a file named /tmp/BACKUP.LOG

top of page


telinit

Examples What it does
telinit q Forces the init process to re-read the /etc/inittab
telinit 1 Brings the operating system into maintenance (single-user) mode. Same as typing in init 1

top of page


timex

Displays the elapsed time it took for a command to execute. Real time is amount of time user waited for the process to execute. CPU time is amount of time that the process actually used the cpu.

Example: timex find /tmp -print|backup -ivqf/dev/null

top of page


tr – Translates characters in a file.

Handy for translating files from uppercase (DOS files) to lowercase (UNIX files).

Examples What it does
tr ‘~’ ‘\012’ </tmp/DOSFILE > /tmp/UNIXFILE Replace the tilde as a DELIMITER character in file DOSFILE with a NEWLINE character in file UNIXFILE.
tr -d ‘\15’ < file1 > file2 Remove CR from file1 and creates a new file named file2

top of page


trace

Kernel debugging to trace the events associated with the device your are monitoring.

Examples What it does
traceon turns trace on
traceoff turns trace off

top of page


type – Shows path location of the specified command

Example: type basename

Outputs: basename is /usr/bin/basename

top of page


uname – Displays attributes relating to hardware/software.

Examples What it does
uname -a Displays system name, operating system version, LAN network number, type of hardware running and so on.
uname -m XXYYYYYYMMSS (machine ID) where…

  • XX=Feature of operating system. Always 00
  • YYYYYY=CPU ID. Value stored in ROM on processor board
  • MM=Model number. Set to 7th & 8th digits returned by lscfg -v command
  • SS=Submodel number. Always 00
uname -rv -r=release, -v=version. Results: 2 3  (Version 3 Release 2)
uname -S `hostname` Since the system name can be set in two places (hostname and uname -S), just set them to the same string.

top of page


w – Lists summary of current user activity

top of page


what

Displays header information about the source files required to build the executable file your reviewing, timestamps as to when the source files where compiled, their build level, and so on.

Example:
what /unix

top of page


whatis – Displays a short description of the function a command performs

Example: whatis vmstat

Outputs: vmstat(1) – Reports virtual memory statistics.

top of page


whereis – Shows path location of the specified command

Example: whereis motd

Outputs: motd: /etc/motd

top of page


who – Displays information about all users currently on local system.

When you log in, the login program writes a record in the /etc/utmp file. This record includes your user name, date, time of login, and the login tty/pts device. The who command checks this file to find out which users are currently logged in, along with the hostname and display terminal they are logged under.

Examples What it does
who -b Displays date system was last booted system boot Nov 17 13:58
who -r Displays run-level of machine
who -u Displays information about users currently logged in. The line activity field will EITHER have…

  • a dot (.) if there has been activity on the terminal within the past minute OR
  • the number of hours/minutes since activity last occurred OR
  • is marked with ‘old’ if the line has been quiet for more than 24 hours.
who -a /usr/adm/wtmp Displays the name, terminal, and date users logged into the system
who -u /etc/security/failedlogin Displays the account, terminal and date that a failed login was attempted.
/usr/lib/acct/fwtmp < /usr/adm/wtmp > /tmp/ACCT.INFO Creates an ASCII version of the /usr/adm/wtmp file that can be read by the system administrator

top of page


xargs – Constructs an argument list and executes a command

Examples What it does
find /u/netinst -print | xargs chmod 500 Files under /u/netinst will have permissions changed to 500
find /u/netinst -print | xargs chown netinst Files under /u/netinst will have ownership changed to netinst
find /u/netinst -print | xargs chgrp staff Files under /u/netinst will have group changed to staff

top of page