Solaris 管理员常用命令( 三 )



Resource Management

/usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */

/usr/proc/bin/pmap pid
/* Report address space map a process occupies */

Route Configuration

route add net 128.50.0.0 128.50.1.6 1
/* Adds route to 128.50 network via 128.50.1.6 */

route change 128.50.0.0 128.50.1.5
/* Changes the destination address for a route */

route delete net 128.50.0.0 128.50.1.6
/* Deletes route to 128.50 network */

route get [hostname]
/* Which interface will be used to contact hostname */

route monitor
/* Monitors traffic to the routes */

route flush
/* Removes all entries in the route table */

Searching Items

egrep "patterna|patternb"
/* Search for multiple patterns within the same file */

find . -exec egrep -li "str" {} ;
/* Find a string in files starting cwd */

find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
/* Find without traversing NFS mounted file systems */

find . -mtime -1 -type f
/* Find recently modified files */

find / -mtime <# of days>
/* Find files modified during the past # of days */

find . ! -mtime - | /usr/bin/xargs rm -rf
/* Finds and removes files older than specified */

find . -type f -exec grep "" {} ; -print
/* Find files (and content) containingwithin directory tree */

find . -type f -exec grep -l "" {} ;
/* Find filenames containingwithin directory tree */

find . -type f -print | xargs grep -i [PATTERN]
/* Recursive grep on files */

find / -user
/* Find all files owned by */

find / | grep [file mask]
/* Fast way to search for files */

find-name "" -exec rm -rf {} ;
/* Recursively finds files by name and automatically removes them */

find /proc/*/fd -links 0 -type f -size2000 -ls
/* Find large files held open by a process */

ls -lR | grep
/* Fast alternative to find */

Security

echo "Please go away" > /etc/nologin
/* Stops users logging in */

find / -perm -0777 -type d -ls
/* Find all your writable directories */

find / -type f -perm -2000 -print
/* Find all SGID files */

find / -type f -perm -4000 -print
/* find all SUID files */

Set Terminal Options

stty erase ^H
/* Sets the Backspace Key to erase */

stty erase ^?
/* Sets the Delete Key to erase */

stty sane
/* Rreset terminal after viewing a binary file. */

tput rmacs
/* Reset to standard char set */

Snoop Your Network

snoop -d pcelx0
/* Watch all network packets on device pcelx0 */

snoop -o /tmp/mylog pcelx0
/* Saves packets from device pcelx0 to a file */

snoop -i /tmp/mylog host1 host2
/* View packets from logfile between host1 & host2 */

snoop -i /tmp/mylog -v -p101
/* Show all info on packet number 101 from a logfile */

snoop -i /tmp/mylog -o /tmp/newlog host1
/* Write a new logfile with all host1 packets */

snoop -s 120
/* Return the first 120 bytes in the packet header */

snoop -v arp
/* Capture arp broadcasts on your network */

Swap File

mkfile -v 10m /export/disk1/myswap
/* Makes a 10 Megabyte swapfile in /export/disk */

mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile */

Swap Space

swap -s
/* List the amount of swap space available, also see mkfile */

swap -a /export/disk1/swapfile
/* Add a swapfile */

swap -d /dev/dsk/c0t0d0s4
/* Deletes a swap device */

swap -l
/* List the current swap devices */

System Configuration

drvconfig ; disks
/* Adding hot-plug disks to system */

/usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */

/usr/sbin/eeprom diag-switch? true

推荐阅读