HP非常经典系统管理文章

18 篇文章 1 订阅

PDC Prompt at Boot...................................................................................................................................... 2

ISL Prompt at Boot........................................................................................................................................ 2

Show autofile Contents at HP-UX Prompt........................................................................................ 2

Modifying autofile Contents at HP-UX Prompt.............................................................................. 2

Checking Boot Disk Information............................................................................................................. 2

Executing Scripts at Server Boot........................................................................................................... 2

Kernel..................................................................................................................................................................... 2

Generating a New Kernel........................................................................................................................... 2

Listing Kernel parameters......................................................................................................................... 2

Dynamic Loadable Kernel Modules (HP-UX 11.x).............................................................................. 2

System.................................................................................................................................................................... 2

Running State.................................................................................................................................................. 2

Documentation............................................................................................................................................... 2

Checking Server Information.................................................................................................................... 2

Location of syslog.log and rc.log.......................................................................................................... 2

Scanning Hardware....................................................................................................................................... 2

Device Files........................................................................................................................................................ 2

Swap Space......................................................................................................................................................... 2

Displaying Swap Configuration.................................................................................................................. 2

Extending Primary Swap............................................................................................................................... 2

Configuring Secondary Swap (Device Swap)........................................................................................... 2

Configuring Secondary Swap (File System Swap).................................................................................. 2

Core Dump........................................................................................................................................................... 2

Displaying Dump Area Configuration........................................................................................................ 2

Configuring Kernel Dump Devices.............................................................................................................. 2

Configuring Runtime Dump Devices (HP-UX 11.0 only)........................................................................ 2

Core Dump Actions......................................................................................................................................... 2

Scheduling Jobs (crontab)........................................................................................................................... 2

Diagnostic User Interface.......................................................................................................................... 2

Adding a User.................................................................................................................................................... 2

HP Products....................................................................................................................................................... 2

Software Distributor.................................................................................................................................. 2

Log File Location........................................................................................................................................... 2

Common Commands....................................................................................................................................... 2

Managing Products........................................................................................................................................ 2

Cleaning Up Patches...................................................................................................................................... 2

Glance.................................................................................................................................................................. 2

Perfview.............................................................................................................................................................. 2

Omniback............................................................................................................................................................. 2

MeasureWare................................................................................................................................................... 2

RAID Manager (for Business Copy or Continuous Access for XP256)......................................... 2

Command Line................................................................................................................................................. 2

Disk, LVM & File System Management................................................................................................. 2

Managing EMC² Disks...................................................................................................................................... 2

Starting Open Symmetrix Manager............................................................................................................. 2

Checking EMC Disks Configuration (inq)................................................................................................ 2

Scanning LVM Disks......................................................................................................................................... 2

Full Process for Creating a File System.............................................................................................. 2

Creating a File System on a Specific Disk............................................................................................ 2

Mirroring a Logical Volume onto a Particular Physical Volume.......................................... 2

Expanding Online a VxFS File System (with OnlineJFS)................................................................ 2

Expanding a File System (without OnlineJFS)................................................................................... 2

Checking Disk & LVM Information........................................................................................................... 2

Checking a File System Block Size.......................................................................................................... 2

Checking Active Processes on a File System....................................................................................... 2

Specificities of VxFS File Systems............................................................................................................ 2

Special Mount Options.................................................................................................................................. 2

VxFS - Specific Commands............................................................................................................................ 2

OnlineJFS Features (fsadm)......................................................................................................................... 2

Running fsck on the root File System................................................................................................... 2

Repairing a Corrupt HFS File System..................................................................................................... 2

Repairing a Corrupt Journaled File System (VxFS)......................................................................... 2

Checking Read & Write Cache Hit Ratios Buffer Cache............................................................... 2

File management.............................................................................................................................................. 2

Command Options (ls, cp, rm, chmod)...................................................................................................... 2

File Rights.......................................................................................................................................................... 2

Information on a Binary File.................................................................................................................... 2

Information on a File................................................................................................................................... 2

Find  Files........................................................................................................................................................... 2

Executing a command on the found files.................................................................................................... 2

Removing Files Older than 1 Day in Current Directory......................................................................... 2

Finding Files Bigger Than 1KB................................................................................................................... 2

Printing................................................................................................................................................................. 2

Status of all printers.................................................................................................................................. 2

lp options........................................................................................................................................................... 2

Enabling / Disabling Printers..................................................................................................................... 2

Cancel Printing............................................................................................................................................... 2

Administrator Commands........................................................................................................................... 2

Adding a Local Printer................................................................................................................................ 2

Removing a Printer......................................................................................................................................... 2

Network Management................................................................................................................................. 2

Checking Configuration.............................................................................................................................. 2

Configurations Files...................................................................................................................................... 2

/etc/hosts........................................................................................................................................................... 2

/etc/resolv.conf................................................................................................................................................ 2

/etc/nsswitch.conf............................................................................................................................................ 2

Other Files........................................................................................................................................................ 2

Changing Configuration.............................................................................................................................. 2

Utilities................................................................................................................................................................. 2

Tar Copy & Tar Gzip....................................................................................................................................... 2

Remotely........................................................................................................................................................... 2

X-Windows Environment............................................................................................................................. 2

Printing an X-window.................................................................................................................................... 2

Getting an hpterm Window with a Scrollbar............................................................................................. 2

Resizing a Window.......................................................................................................................................... 2

Accessing Command History....................................................................................................................... 2

Setting different command histories for one user...................................................................................... 2

String Substitution Under “vi”................................................................................................................ 2

Communicating with Connected Users................................................................................................. 2

Date & Time....................................................................................................................................................... 2

Execution time of a command....................................................................................................................... 2

Reformated “bdf”........................................................................................................................................... 2

Logging Actions............................................................................................................................................... 2

Scripting.............................................................................................................................................................. 2

Version Control with RCS.......................................................................................................................... 2

Storing Script Name in a Variable.......................................................................................................... 2

Syntax for Tests............................................................................................................................................. 2

Testing if a Variable is not Null............................................................................................................. 2

Converting String to Lowercase............................................................................................................. 2

Substituting a String in a File................................................................................................................. 2

Using an Array of Values............................................................................................................................ 2

Incrementing an Integer............................................................................................................................. 2

Debugging............................................................................................................................................................ 2

 

 


 

PDC Prompt at Boot

          autoboot on|off           # Activate or deactivate autoboot

          auto boot on|off          # Idem for V-class servers

          autosearch on|off         # Activate or deactivate autosearch

          auto search on|off        # Idem for V-class servers

          path                      # Display hardware path of current boot device

          path pri hardware_address # Set the primary boot path

          path alt hardware_address # Set the alternate boot path

          bo                        # Continue the boot process

ISL Prompt at Boot

          ISL> help                 # Display available commands

          ISL> hpux lsautofl        # Display the contents of the autofile

          ISL> hpux show autofile   # Display the boot string of the autofile

          ISL> sea                  # Search bootable and disk devices

          ISL> hpux (52.6.0;0)/stand/vmunix   # Normal boot at ISL prompt

          ISL> hpux (52.6.0;0)/stand/vmunix.prev # Boot on backup kernel

          ISL> hpux –is             # Boot in single user mode

          ISL> hpux –lq             # Boot without root VG meeting quorum

Show autofile Contents at HP-UX Prompt

          /usr/bin/lifcp /dev/rdsk/c0t0d0:AUTO  /tmp/file_name  # where c0t0d0 is the boot disk device file

          cat  /tmp/file_name

Modifying autofile Contents at HP-UX Prompt

          mkboot -a “hpux (56/52.5.0;0) /stand/vmunix” /dev/rdsk/c0t0d0

Checking Boot Disk Information

          lvlnboot –v               # Show boot disk and boot, root, swap & dump configuration

Executing Scripts at Server Boot

          You can use /sbin/init.d/template as a template for startup scripts.

          Scripts are located in /sbin/init.d

          Configuration files are located in /etc/rc.config.d

          Symbolic links called S900script_name and K100script_name are located in /etc/rcN.d et /etc/rcN-1.d

Generating a New Kernel

Remark: it is recommended to use SAM…

          cd /stand/build

          /usr/lbin/sysadm/system_prep -s system  # If necessary, extract a new system file from the current kernel

          Make desired changes with one of the following actions:

ü     vi system              

ü     kmtune [[-s param{=|+}value]…] [[-r param]…] -S system

# HP-UX 11.0 Modify tunable parameters (-r: reset to default)

          /usr/sbin/mk_kernel -s system    # Create the new kernel from the modified system file

          mv ../vmunix ../vmunix.prev  # Rename the current kernel, in case it is needed for recovery

          mv ../system ../system.prev  # Rename the old system file, in case it is needed

          mv ../dlkm ../dlkm.vmunix.prev   # HP-UX 11.0 only (Dynamically Loadable Kernel Modules)

          Move the new kernel in place, to be used after reboot:

ü     mv vmunix_test ../vmunix          # HP-UX 10.20

ü     kmupdate /stand/build/vmunix_test # HP-UX 11.0

          mv system ..              # Move the new system file, to be used after reboot

          shutdown -r 0             # Reboot the system

Listing Kernel parameters

          sysdef

          kmtune –l                 # HP-UX 11.0

-q parameter_name1…: specify parameters

-S system_file: specify system file

Dynamic Loadable Kernel Modules (HP-UX 11.x)

          kmadmin –Q                # Status of all DLKM

          kmadmin –L module_name    # Load a DLKM

          kmadmin –U module_name    # Unload a DLKM

Running State

          who –r                    # Display current running state

          who –b                    # Date of last reboot

          init –s                   # Bring the system to single user mode

          init 4                    # Bring system to run level 4

Documentation

          Generic documentation on the system  is located in /usr/share/doc

          catman –w &               # Prepare “man” to search by keywords

          man –k keyword            # Search in manual by keyword

Checking Server Information

          more /etc/PSS/hpux_config.HOSTNAME

          uname –a                  # Information on the server, OS, licence

          hostname                  # Hostname

          model                     # Server model reference

Location of syslog.log and rc.log

          /var/adm/syslog/syslog.log

          /etc/rc.log

Scanning Hardware

          ioscan –nf

-k: do not scan hardware again (read kernel)

-C disk|printer|tape|bus_adapter|processor…: specify type

Device Files

          insf –e                   # Recreate device files for all existing devices on system (overwrite customized device files!)

          lssf device_file_name     # List the characteristics of the specified device file

Swap Space

Primary swap is configured into the kernel is activated at boot. Secondary swap devices not in the kernel are activated by swapon command (often by /sbin/init.d/swap_start). File system paging is also activated by swapon.

To deactivate pseudo-swap (memory paging), put kernel parameter swapmem_on to 0. The maximum number of swap devices appears in nswapdev kernel parameter. The maximum total size of swap space is controled mainly by maxswapchunks kernel parameter.

Secondary swap logical volumes, for device swap, must be located on different physical volumes. Swap logical volumes must use contiguous extent allocation and no bad block relocation. It is better to have several swap logical volumes with a similar size than a big one with the same amount.

Displaying Swap Configuration

          swapinfo –ta              # Display total amount of swap used

-m: display value in Mb (KB) instead of Kb

Extending Primary Swap

          lvcreate –n lvol_name –L size_in_MB –C y –r n /dev/vg00  # Create a new logical volume in vg00

          lvlnboot -s /dev/vg00/lvol_name  # Update BDRA for swap

          lvlnboot -R /dev/vg00     # Relink BDRA

          Check /stand/system, modify it and regenerate kernel if necessary

          shutdown –r 0             # Reboot

Configuring Secondary Swap (Device Swap)

          lvcreate –n lvol_name –L size_in_MB –C y –r n /dev/vg_name      # Create the logical volume

          Add the following line in /etc/fstab:

/dev/vg_name/lvol_name  /  swap  defaults  0  0

          swapon –a                 # Enable all swap devices in /etc/fstab

 

Some other possibilities are:

          swapon -p 0 /dev/dsk/c0t0d0  # Activate swap on a device with high priority (p is in [0-10])

          swapon -f /dev/dsk/c12t0d0   # Force paging on a device, even if there is a file system (destructive…)

Configuring Secondary Swap (File System Swap)

          swapon [-m mini] [-l limit] [-r reserve] [-p priority] directory   # Enable file system paging (sizes are expressed in file system blocks)

 

To permanently configure a swap file system, add the following line in /etc/fstab:

device directory swapfs min=A, lim=B, res=C, pri=P 0 0

default /swap swapfs min=10,lim=4500,res=100,pri=0 0 0 # Example

Core Dump

After a panic, HPMC (High Priority Machine Check) or transfer of control, memory is writen to the dump device(s), the server reboots and savecore (10.20 ) or savecrash (11.0) is run by /sbin/rc1.d/sxxx to write the contents of the dump to the file system (default is /var/adm/crash).

Configuration file for savecrash or savecore is located in /etc/rc.config.d directory.

The size of the file system must be at least “Total Amount of RAM” + “Kernel Size”.

By default primary swap is used as a dump device. Dump devices must be in the root volume group (kernel dump devices) except for runtime dump devices (HP-UX 11.0 only) that can be either entire physical volumes or logical volumes on different physical volumes. Dump logical volumes must use contiguous extent allocation  and no bad block relocation.

Size of kernel dump logical volumes (configured with lvlnboot -d) must not exceed 2GB and they must be on the first 2GB of the physical volume.

Displaying Dump Area Configuration

          lvlnboot –v               # HP-UX 10.20

          crashconf –v              # HP-UX 11.0

Configuring Kernel Dump Devices

          lvcreate –n lvol_name –L size_in_MB –C y –r n /dev/vg00  # Create the logical volume in vg00

          lvlnboot -d /dev/vg00/lvol_name  # Update BDRA for dump (do this for all dump logical volumes)

          lvlnboot -R /dev/vg00     # Relink BDRA

          Check that a line “dump lvol” is in /stand/system. If not, add it, and regenerate the kernel.

          Shutdown –r 0             # Reboot

Configuring Runtime Dump Devices (HP-UX 11.0 only)

          lvcreate –n lvol_name –L size_in_MB –C y –r n /dev/vg00  # Create the logical volume (if not using a whole physical volume)

          To permanently configure a runtime dump device, add one of the following lines in /etc/fstab:

/dev/dsk/c0t0d0 / dump defaults 0 0

/dev/vg_name/lvol_name / dump defaults 0 0

          Do one of the following:

ü     crashconf /dev/vg_name/lvol_name  # Activate a dump lvol

ü     crashconf /dev/dsk/c0t0d0     # Activate a dump physical volume

ü     crashconf –a            # Read /etc/fstab to update the list of active (runtime) dump devices

ü     crashconf –ar           # Read /etc/fstab to replace the list of active (runtime) dump devices

Core Dump Actions

To manually initiate a core dump when the system hangs at boot:

ü     [CTRL-b]

ü     CM> tc                  # Transfer of control

          savecrash                 # (11.0) Write core dump to file system

 

To deactivate savecrash during the boot process:

ü     vi /sbin/rc.config.d/savecrash # (11.0) Set SAVECRASH=0

          savecore -t /dev/rmt/0m /tmp &   # (10.20) Write core from dump devices directly to a tape

Scheduling Jobs (crontab)

          ps –ef | grep cron        # Check that daemon is running

          /etc/cron                 # Start the cron daemon

          crontab –l                # Display crontab file of current user

 

To modify current user crontab:

ü     [cd /usr/spool/cron/crontabs]

ü     crontab –l >crontab_file   # List current settings

ü     vi crontab_file         # Modify crontab file

ü     crontab crontab_file    # Load new configuration

OR:

ü     crontab –e              # Edit crontab with vi

Format of crontab file is: 1-Minute (00-59|*), 2-Hour (00-23|*), 3-Day (1-31|*), 4-Month (1-12|*), 5-Weekday (0-6|*, 0 being Sunday), 5-Command

Diagnostic User Interface

          suplicen                  # Change password - Test if Diag Tools are installed (if error, they are not)

          sysdiag                   # (HP-UX 10.20) Start DUI

          DUI> help [command]       # Get help at DUI prompt

Adding a User

          vi /etc/passwd            # Add a line for new user (with empty  password field)

          vi /etc/group             # Update group

          mkdir /home/user          # Create home directory

          chown user:group /home/user  # Change owner of the home directory

          chmod 755 /home/user      # Change rights of the home directory

          passwd user               # Assign a password

          cp /etc/skel/.profile /home/user/.profile  # Copy .profile

Software Distributor

See The Software Depot Cookbook for more information…

Log File Location

          /var/adm/sw/swagent.log

Common Commands

          swreg –l depot /depot/dir # Register a depot

          swlist -l depot [@ host]  # List registered depots [on a specific remote host]

          swlist -d @ host:depot    # List available products in a depot on a specific remote host

          swlist –s depot           # List available products in a local depot

          swlist -l product -s /dev/rmt/0m # List installable products that are on the tape drive

          swlist -l product [@ host]   # List installed products [on a specific remote host]

          swlist [-v] -l product product   # List information on a product

          swinstall                 # Start GUI for swinstall

          swcopy                    # Start GUI for swcopy

          swacl –l host             # Display rights on local host

          swacl –l host –M user:root@hostname:crwit  # Give all rights to root user

          cat /var/adm/sw/security/_ACL    # Display rights (possible to edit manually if necessary)

Managing Products

          swpackage –s psf_file –d depot_name # Create a product in the specified depot according to psf_file

          swcopy –s source_depot product_or_fileset @ dest_depot   # Copy a product or fileset into a depot

          swinstall –x mount_all_filesystems=false –s [host:]depot_name package_name   # Install a package from a depot [on a specific remote host]

Cleaning Up Patches

          cleanup                   # To gain space in /var

Glance

          gpm                       # Start glance

Perfview

          pv                        # Start perfview

Omniback

          omnidb -session session_name –report # Checking an Omniback session report

          omnidb  -filesystem  hostname:/file/system  datalst # Checking that a file system from “hostname” server in the “datalst” datalist was backed up

MeasureWare

          mwa                       # Start MeasureWare Agent

          /opt/perf/bin contains executable files.

          /var/opt/perf(/datafiles) contains “log” files.

          /etc/opt/perf can contain the configuration file (“parm”).

          The scope is called scopeux. It uses “midaemon” daemon.

 

Interactive tools are:

          extract

          utility

RAID Manager (for Business Copy or Continuous Access for XP256)

Daemon on the UNIX host is called HORCM (HP Open Remote Copy Manager)

Each RAID Manager instance has a host-specific configuration file (ex: /etc/horcm0.conf)

HORCM_MON

#ip-address  service     poll(10ms)  timeout(10ms)

HST1         horcm0      1000        3000

HORCM_CMD

#dev_name for command device

/dev/rdsk/c0t0d0

HORCM_DEV

#dev_group   dev_name    port#       TargetID   LU#  MU#(BC only)

Oradb        oradev1     CL1-A       1          1

Oradb        oradev2     CL1-A       1          2

HORCM_INST

#dev_group   ip_address  service

Oradb        HST2        horcm0 

/etc/services contains a line such as  the following for each RAID Manager instance (port number used and defined in the config file) :

horcm0  11000/udp  # horcm0 instance of RAID Manager

 

Command Line

To run commands export  HORCMINST=inst_nb  first !

To run BC commands export HORCC_MRCF=1 first

          horcmstart.sh [inst_nb_1] … [inst_nb_n] # Start RAID Manager instance(s)

          horcmshutdown             # Stop RAID Manager

          horctakover –g <dev_group>   # (CA only) Host executing horctakeover takes ownership of the pair(s) (P-VOL)

          paircreate –g <dev_group> -vl –f never|data –c 15 # Create pair(s) with P-VOL on local side

          pairsplit –g <dev_group> -rw -S  # Split pair(s)

          pairresync –g <dev_group> # Resynchronize pair(s)

          pairdisplay –g <dev_group> -fxc  # Display pair status

          pairdisplay –g <dev_group> -fxc -l  # Display pair status from the local point of view only

Managing EMC² Disks

Starting Open Symmetrix Manager

          Check DISPLAY

          cd /opt/soft/symmapps

          . ./symmappsrc.sh

          cd bin

          omsgui

 

If reaffecting disk with sddr, create new special files:

          ioscan –nf –C disk

          insf -e

Checking EMC Disks Configuration (inq)

          inq –et > /tmp/inq.out

Scanning LVM Disks

          vgscan

Full Process for Creating a File System

          If physical volume not initialized:

ü     pvcreate /dev/rdsk/c0t0d0  # Create PV

–f: force, –B: bootable

          If volume group exists already:

ü     vgextend /dev/vg_name /dev/dsk/c0t0d0    # Add PV to VG

-g pvg_name: if using Physical VG (for mirroring)

          If volume group must be created:

ü     ll /dev/*/group         # Check available minor numbers

ü     mknod /dev/vg_name/group c 64 0x010000

ü     vgcreate /dev/vg_name /dev/dsk/c0t0d0    # Create VG

-g pvg_name: if using PVG (for mirroring)

-p max_PV: max number of physical volumes in the VG (16)

-s PE_size: PE size in MB (4)

          lvcreate –L size_in_MB –n lv_name /dev/vg_name # Create LV

-r (y)|n: bad block relocation (n for root, swap, dump, EMC² disks),

-s (s)|n|g: strict allocation policy (g if using PVG),

-m (0)|1|2: mirror_copies,

-C (n)|y: contiguous extent allocation (y for root, swap, dump)

          newfs –F vxfs /dev/vg_name/rlv_name # Create FS

-F hfs|vxfs|nfs|cdfs|lofs: file system type

-b block_size: FS block size

-o largefiles|nolargefiles: enable large files

          Edit /etc/fstab to add the file system

          mkdir /mount/point/name

          mount /mount/point/name   # Mount File System

Creating a File System on a Specific Disk

          lvcreate –n lv_name /dev/vg_name # Create LV without size

          lvextend –L size_in_MB /dev/vg_name/lv_name /dev/dsk/c0t0d0     # Extend on the expected disk

Mirroring a Logical Volume onto a Particular Physical Volume

          vgextend /dev/vg_name /dev/dsk/c1t1d1   # Add mirror disk in VG

-g pvg_name: if using PVG

          lvextend -m 1 /dev/vg_name/lv_name /dev/dsk/c1t1d1    # Mirror LV

Expanding Online a VxFS File System (with OnlineJFS)

          lvextend –L new_size_in_MB /dev/vg_name/lv_name   # Extend LV

          fsadm –F vxfs –b size_in_block /FS/mount/point # Extend FS

Expanding a File System (without OnlineJFS)

          lvextend –L new_size_in_MB /dev/vg_name/lv_name # Extend LV

          umount /dev/vg_name/lv_name  # Unmount the FS

          extendfs /dev/vg_name/rlv_name # Extend FS

          mount /dev/vg_name/lv_name   # Mount the FS

Checking Disk & LVM Information

          diskinfo /dev/rdsk/c0t0d0 # Display information on the disk

          pvdisplay [–v] /dev/rdsk/c0t0d0  # Display PV information

          vgdisplay [–v] /dev/vg_name  # Display VG information

          lvdisplay [–v] /dev/vg_name/lv_name # Display LV information

          mount                     # Display mounted file system

-a: mount all file system not already mounted

          bdf                       # Display FS usage (%available, %free…)

          lssf /dev/dsk/*           # Display LV and paths

Checking a File System Block Size

          fstyp –v /dev/vg_name/lvol_name  # For all FS types

          tunefs -v /dev/vg_name/lvol_name # For HFS (read parameter bsize)

          getext file_name          # For VxFS, file_name being any regular file on the FS (read parameter Bsize)

Checking Active Processes on a File System

          fuser –u /dev/vg_name/lvol_name

Specificities of VxFS File Systems

Special Mount Options

          mount -F vxfs -o option block_device_file mount_point_dir

-o option purpose:

blkclear,mincache=closesync: enhanced data integrity

delaylog: enhanced performance

tmplog,nolog: enhanced performance for temporary file systems

datainlog,convosync=dsync: improved synchronous writes

VxFS - Specific Commands

          vxdump                    # Back up JFS file system, including extent attribute information

          vxrestore                 # Restore JFS file system from a vxdump backup

          fsadm                     # FS administration utility, mainly used for Online JFS features

          setext                    # Set extent attributes

          getext                    # List extent attribute information

OnlineJFS Features (fsadm)

          fsadm -b new_size mount_point    # Resize (in blocks) a FS

          fsadm -D mount_point      # Report on directory fragmentation

          fsadm -d mount_point      # Reorganize directories to reduce fragmentation

          fsadm -E mount_point      # Report on extent fragmentation

          fsadm -e mount_point      # Defragment extents

Running fsck on the root File System

          init –s                   # Switch to single user mode

          fsck /dev/vg00/lvol_name  # cf repairing a corrupt HFS file system

Repairing a Corrupt HFS File System

          umount /dev/vg_name/lvol_name    # Unmount the file system

          fsck -p /dev/vg_name/lvol_name   # Run fsck in preen mode for simple corruption

          fsck -n /dev/vg_name/lvol_name > /tmp/fsck_output # Do if previous step failed

          Use output of previous step to find corrupted files

          mkdir /FSCK; mount -f /dev/vg_name/lvol_name /FSCK    # Force file system to be mounted

          Backup the now mounted file system (ex: fbackup -f /dev/rmt/0m -0vi /FSCK)

          umount /dev/vg_name/lvol_name    # Unmount the file system

          Only as a last resort:

ü     fsck -y /dev/vg_name/lvol_name > /tmp/fsck_output

Repairing a Corrupt Journaled File System (VxFS)

          umount /dev/vg_name/lvol_name    # Unmount the file system

          fsck –F vxfs -n /dev/vg_name/lvol_name > /tmp/fsck_output

          Use output of previous step to find corrupted files

          mkdir /FSCK; mount -f /dev/vg_name/lvol_name /FSCK    # Force file system to be mounted

          Backup the now mounted file system (ex: fbackup -f /dev/rmt/0m -0vi /FSCK)

          umount /dev/vg_name/lvol_name    # Unmount the file system

          Only as a last resort:

ü     fsck –F vxfs -y /dev/vg_name/lvol_name > /tmp/fsck_output

Checking Read & Write Cache Hit Ratios Buffer Cache

          sar -b 5 5                # Display read and write cache hit ratios (%rcache & %wcache respectively)

Command Options (ls, cp, rm, chmod)

          ls

–a: includes hidden files, –F: adds suffix

–R: recursive, –d: sees directory as file

-r: reverse order, -t: sort by date

          cp

–r: recursive, -i: asks fo confirmation

          rm

-r: recursive, -i: asks fo confirmation , -f: force

          chmod

-R: recursive

File Rights

          chmod (ex: chmod u+x,g=rx,o-rw…), umask, chown, chgrp, newgrp

          lsacl, chacl              # To be more specific on the rights (HFS only)

Information on a Binary File

          strings –a file_name | more

Information on a File

To locate where is command_name in the current user path:

ü     whence –v command_name

ü     which command_name

ü     type command_name

          what command_name         # Information on file

          file file_name            # Information on file content nature

Find  Files

          whereis file_name         # Find all occurences of file_name

          find start_location –name file_name

Executing a command on the found files

          find start_location –name file_name –exec command_name {} /;

          find start_location –name file_name –print | xargs command_name

Removing Files Older than 1 Day in Current Directory

          find . –mtime +1 –exec rm {} /;

Finding Files Bigger Than 1KB

          find start_location –type f –size +1024c

Status of all printers

          lpstat -t

lp options

          -ddest: destination, -ttitle: comment on first page

          -nn: number of copies, -w: message sent when printing complete

          -ohalf: 2 pages on one, -oc: compressed, -onb: no banner

Enabling / Disabling Printers

          enable printer_name       # Enable printer

          disable printer_name      # Disable printer

-c: cancel current requests

-r”reason_message”: display the reason

Cancel Printing

          cancel printer_name       # Cancel current job

          cancel printer_name-ID_number    # Cancel ID_number job

          cancel –uuser_name        # Cancel for user xxx

Administrator Commands

          lpsched                   # Start up printer scheduler

          lpadmin –ddest            # Sets default printer

          lpadmin –xdest            # Remove the printer

Adding a Local Printer

          lpshut                    # Shut down printer scheduler

          lpadmin -pprinter -v/dev/device_file –mmodel   # Create printer, the model being /usr/lib/lp/model

          accept printer            # Let the spooler accept requests for printer

          enable printer            # Enable printer

          lpadmin –dprinter         # Set as default printer

          lpsched                   # Restart printer scheduler

Removing a Printer

          lpshut                    # Shut down printer scheduler

          reject -r"Use alternate printer." printer  # Reject new requests

          lpstat -o printer         # Check for pending jobs

          disable -r"Printer printer disabled." printer  # Disable printer

          lpmove printer alternate_printer # Optionnally move pending request to another printer queue

          lpcancel printer          # Optionnally cancel all request

          lpadmin –xprinter         # Remove the printer

          lpsched                   # Restart printer scheduler

Checking Configuration

          lanadmin                  # Interactive menu to manage lan cards

          landiag                   # Display, diagnose, reset LAN cards information

          lanscan                   # List LAN interfaces (display the network card NMID numbers)

          ifconfig lann             # Display configuration of a LAN interface

          arp –a                    # Display arp tables

          netstat –i                # Show interface status

          netstat –g                # Show interface multicast information

          netstat –r                # Display routing tables

-n: display IP address instead of name

          ping host                 # Test connection with a remote host

          linkloop –i local_nmid remote_station_address  # Test at level 2

          linkloop -i 5 0x001083F537AB # Example

Configurations Files

/etc/hosts

/etc/hosts contains the known hosts; it must have at least the following 2 lines:

127.0.0.1               localhost    loopback

Server_IP_address       hostname      alias

And then, one line per network interface and one per BIND, NIS or NIS+ server that you use

/etc/resolv.conf

/etc/resolv.conf is used for name resolution; for example, it can contain:

domain       my.domain.com

nameserver   name_server_IP_address

/etc/nsswitch.conf

/etc/nsswitch.conf is used for name resolution; for example, it can contain:

hosts:      dns [NOTFOUND=continue] files

services:   files

protocols:  files

networks:   files

rpc:        files

netgroup:   files

Other Files

          /etc/host.equiv           # For remote login without password (server-wide)

          /.rhosts (or $HOME/.rhosts)  # For remote login without password (user-defined)

          /etc/networks             # Known networks

          /etc/services             # Services and associated port numbers

          /usr/adm/inetd.sec        # Allowed/denied hosts, networks, …

          /etc/rc.config.d/netconf  # Network information configured at boot

Changing Configuration

          uname –S system_name      # Change system name

          hostname hostame          # Change hostname (for permanent change, edit /etc/rc.config.d/netconf and run /sbin/init.d/hostname start)

          /sbin/set_parms hostname  # Change hostname

          /sbin/set_parms ip_address   # Change IP address

          /sbin/set_parms timezone  # Change time zone

          /sbin/set_parms addl_netwrk  # Change additional network parameters:

subnetwork mask, network gateway, network gateway IP address, local domain name, Domain Name System (DNS) server host name, DNS server IP address, Network Information Service domain name

          ifconfig lann IP_address netmask 0xffffff00 up # Configure and enable an interface

          ifconfig lann 0.0.0.0     # Unconfigure an interface

To configure a default gateway:

ü     /usr/sbin/route add default  gateway_address  1

ü     vi / /etc/rc.config.d/netconf

ROUTE_DESTINATION[0]="default"

ROUTE_GATEWAY[0]=" gateway_address "

ROUTE_COUNT[0]="1"      # Set to “0” if the host is the gateway

Tar Copy & Tar Gzip

          cd source_dir ; tar cf - . | ( cd dest_dir ; tar xf -i )

          tar cvf – files_to_zip | gzip –c > zip_file_name.gzip

          gunzip –c zip_file_name.gzip | tar xvf – unzip_location

Remotely

          tar cvf - files_to_zip_full_path | gzip -c | remsh HOST "gunzip -c | tar xvf –"

          cd source_dir; tar cvf - files_to_zip_relative_path | gzip -c | remsh HOST "gunzip -c | tar xvf – dest_dir"

X-Windows Environment

Printing an X-window

          Set up DISPLAY

          xwd | xpr –rxv –device ljet | lp –oraw –onb –dprinter_name

Getting an hpterm Window with a Scrollbar

          hpterm –sb –sl 1024

Resizing a Window

          resize

Accessing Command History

          set -o vi                 # HISTSIZE and HISTFILE must be defined

Setting different command histories for one user

HISTSIZE=128

HISTFILE=$HOME/.sh_history_`basename $(tty)`

export HISTSIZE HISTFILE

String Substitution Under “vi”

          :1,$s/old_string/new_string/g    # Replaces all occurences

Communicating with Connected Users

          write user_name [tty]     # Validate with [CTRL-D]

          wall                      # Write to all users

          vi /etc/motd              # Message displayed at logon

          vi /etc/issue             # Message displayed at logoff

          mesg [y|n]                # To “check if accepted” / accept / refuse messages

          who                       # To know users’ tty

          who –R                    # Display IP address of connected users

          who am i                  # To know my tty

          finger [hostname]         # Connected users

          whodo                     # Who does what…

Date & Time

          date '+Il est %H:%M:%S,le %d:%m:%y'

Execution time of a command

          time command_name

Reformated “bdf”

          bdf | awk '{ if ( $0 !~ /%/ ) { printf("%s",$0) ; getline ; printf("/t%s/t%s/t%s/t%s/t%s/n",$1,$2,$3,$4,$5) } else printf("%s/t%s/t%s/t%s/t%s/t%s/n",$1,$2,$3,$4,$5,$6)}'

Logging Actions

          script –a file_name

Version Control with RCS

          co -l script_name         # Put a lock on the script version n

          vi script_name

          ci script_name            # Validate version n+1

          co script_name            # Extract latest copy of the script

Storing Script Name in a Variable

          proc=`basename $0`        # Store the name without its full path

Syntax for Tests

          man test

Testing if a Variable is not Null

          if [ -z ${variable_name:=””} ] ; then … # To do when the variable might be unset

Converting String to Lowercase

          cat $STRING | dd conv=lcase 2>/dev/null

          cat $STRING | tr “[:upper:]” “[:lower:]”

Substituting a String in a File

          sed –e “s/string1/string2/g” file_name > new_file

Using an Array of Values

          array_name[n]=value_n     # Assign values (n=0,1,2,…)

          echo ${array_name[n]}     # Display a given value

          for I in ${array_name[@]} # Go through all values

          do

            echo $I

          done

Incrementing an Integer

          integer R=0               # Initiate

          (( R = $R + 1 ))          # Increment

Debugging

          sh –n script_name         # Check syntax

          sh –x script_name         # Debug

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值