Solaris administrator commonly used 168 commands

xiaoxiao2021-03-06  97

Sysadmin Commands

Debugging

Truss Executable / * Trace Doing of Given Command (Useful Debugging) * /

Truss -f -p / * using multiple windows, this can be used to track setuid / setgid program * /

ARP, Ethernet Trouble Shooting

Arp -a. / * Shows the Ethernet Address ARP TABLE * /

Arp -d myhost / * delete a stale ethernet entry for host myhost * /

Disk commands

du -k. / * Reports Disk Space Used in Kilobytes * /

Du -sk. / * Reports Only Total Disk Space Used in Kilobytes * /

du -sk * | sort -k1,1n / * Reports Total Disk Space Used in Kilobytes In Present Directory * /

du -ad / var | sort -nr / * tells you how big the / var files are in reverse Order * /

FDFORMAT-D -U / * Format Diskette * /

/ usr / bin / iostat-E / * Command to Display Drives Statistics * /

/ BIN / MOUNT -F HSFS -O RO / DEV / SR0 / CDROM / * MOUNT AN ISO 9660 CDROM * /

Newfs -nv / dev / rdsk / c0t0d0s1 / * to view the superfblocks available * /

PRTVTOC / DEV / RDSK / C0T0D0S2 / * DISK Geometry and parting info * /

Quot -af / * how much space is buy by users in kilobytes * /

Driver parameters

NDD / DEV / IP /? / * Shows IP Variables in The Kernel * /

NDD / DEV / IP IP_FORWARDING / * TELLS You if forwarding is on (= 1) * /

NDD -SET / DEV / IP IP_FORWARDING 1 / * Enables IP Forwarding Between Interfaces * /

File manipulation

DOS2UNIX | -ASCII / * Converts DOS File Formats to unix * /

Split / * split files into pieces * /

[vi]:% s / evisting / new / g / * search and replace text in vi * /

[VI]: SET NU / * SET line NUMBERS IN VI * /

[VI]: SET TS = [NUM] / * SET TAB STOPS IN VI * /

File system

CAT / dev / null> filename / * ZERO's Out the file without breaking pipe * /

DD if = / dev / rdsk / ... of = / dev / rdsk / ... bs = 4096 / * make a mirror image of your boot disk * / df -k | grep DG | awk '{print $ 6}' | xargs -n 1 umount / * unmount all file systems in disk group DG * /

FSCK -F UFS / DEV / RDSK / C0T0D0S0 / * Check A UFS FILESYSTEM ON C0T0D0S0 * /

FSCK -F UFS -Y / DEV / RDSK / C0T0D0S0 / * Check Answering Yes To All Questions * /

FSck -f ufs -o b = 97472 / dev / rdsk / c0t0d0s0 / * check using an alternate super block * /

Gzip -dc file1.tar.gz | tar xf - / * unpack .tar.gz files in place * /

Gzip -d -c tarball.tgz | (CD / [Dir]; TAR XF -) & / * Unpacking Tarballs to Diff location * /

LN [-fhns] / * Creating hard links and software limited * /

LS -LA | awk '{print $ 5, "", $ 9}' | sort -rn / * file sizes of current directory * /

Mount -f PCFS / DEV / DSK / C0D0P1 / EXPORT / DOS / * MOUNT DOS FDISK Partition from Solaris * /

Mount -f ufs -o rw, remount / / * useed to remove root to make it it writeable * /

Mount -o Remount, Logging / Spare / * Re-Mount The Ro File System RW and Turn ON UFS Logging * /

Pax -rw. / newdir / * effect alternative for Copying Directories * /

PRTVTOC / DEV / RDSK / C0T0D0S2 | FMTHARD -S - / DEV / RDSK / C0T1D0S2 / * Cloning PartitionTables * /

TAR CVF filename.tar / * Create a Tape (tar) Archive * /

TAR XVF filename.tar / * extract a tape (tar) archive * /

TAR CF -. | (CD / NewDir; TAR XF -) / * Recursively Copy Files and their permissions * /

/ sbin / uadmin x / * syncs file systems and reboots systems fast * /

Zcat [CPIO File] | CPIO -ITMV / * Show The Contents of a Compressed CPIO * /

Zcat

FILE TRANSFER

Get FileName.suffix | "TAR XF -" / * undocumented feature of ftp * / put "| TAR CF -." filename.tar / * undocumented feature of ftp * /

Find. -Depth | CPIO -PDMV / PATH / TOBE / COPIED / TO / * FAST Alternative to CP -PR * /

Sendport / * Transferring Large NumBers of Files Withnin The Same FTP Control Session * /

General

/ USR / BIN / CATMAN -W / * CREATE WINDEX DATABASES for Man Page Directories * /

FQ_FileName = ; echo $ {fq_filename% / *} / * extract directory from full-qualified file name. * /

Mailx -h-u / * list out mail headers for specified user * /

SET filec / * set file-completion for csh * /

UuEncode [filename] | mailx -s "subject" [user to mail] / * send files as attachments * /

Hardware

Cfgadm / * Verify Reconfigurable Hardware Resources * /

M64Config -Prconf / * Print M64 Hardware Configuration * /

M64Config -Depth 8 | 24 / * sets the screen depth of your m64 graphics accelerator * /

M64config -res 'video_mode' / * Change The Resolution of Your M64 Graphics Accelerator * /

Kernel

/ usr / sbin / modinfo / * Display kernel module information * /

/ usr / sbin / model / * load a kernel module * /

/ usr / sbin / modunload -i / * unload a kernel module * /

Nm -x / dev / ksyms | grep obj | more / * tuneable kernel parameters * /

/ usr / sbin / sysdef / * show system kernal tunable details * /

Memory

Prtconf | Grep Mem / * Display Memory Size * /

NetWork Information

NDD / DEV / ARP ARP_CACHE_REPORT / * PRINTS ARP TABLE IN CACHE with IP and MAC Address * /

NetStat -a | GREP EST | WC -L / * Displays Number Active Established Connections to the localhost * /

NetStat -k hme0 / * undocumented netstat command * /

Netstat -i / * show the tcp / ip network interfaces * / netstat -np / * Similar to arp -a withnout name resolution * /

NetStat -R / * Show Network Route Table * /

NetStat -Rn / * Displays Routing Information But ByPasses Hostname Lookup. * /

Netstat -a | More / * Show the State of All Sockets * /

Traceroute / * Follow The Route to the ipaddress * /

Network / tuning

IFCONFIG ETH0 MTU 1500 / * CHANGE MTU of Interface * /

Ifconfig eth0 10.1.1.1 Netmask 255.255.255.255 / * add an interface * /

/ sbin / ifconfig hme0: 1 inet 10.210.xx.xxx Netmask 255.255.0.0 Broadcast 10.210.xxx.xxx / * Virtual Interfaces * /

/ sbin / ifconfig hme0: 1 UP / * BRING VIRTUAL INTERFACE UP * /

/ usr / sbin / ndd -set / dev / hme adv_100fdx_cap 1 / * nailling to 100Mbps * /

NDD -SET / DEV / IP IP_ADDRS_PER_IF 1-8192 / * TO SET MORE THAN 256 Virtual IP Addresses. * /

NDD -SET / DEV / TCP TCP_XMIT_HIWAT 65535 / * Increase TCP-TransmitBuffers * /

NDD -SET / DEV / TCP TCP_RECV_HIWAT 65535 / * Increase TCP-ReceiveBuffers * /

Processes

FUSER -UC / VAR / * Processes That Are Running from / var * /

Kill-Hup `PS-EF | GREP [P] Roccess | awk '{print $ 2}'` / * hup Any Related Process in One Step * /

LSOF -I TCP: 25 / * mapping port with process * /

Pfiles / * Shows Processes' Current Open Files * /

Pkill -n / * kill a process by name * /

Kill `PS-EF | GREP Program_name | Grep -V Grep | Cut -f8 -D ''` / * pkill for solaris 2.6 * /

PRSTAT -A / * AN Alternative for Top Command * /

/ USR / UCB / PS -AUX | More / * Displays CPU% Usage for Each Process In Ascending Order * /

/ USR / UCB / PS -AUXWW | GREP / * gives the full listing of the process (long listing) * /

PS-EF | GREP -I | awk '{print $ 2}' / * creates list of running pid by * / ps --ef | grep -v "0:00" | more / * gives you a list of any Process with cpu time more worth 0:00 * /

PS-EF | More / * show all processes running * /

PS-EO PID, ARGS / * List Processes in Simplified Format * /

PS -FU ORACLE | GREP PMON / * See Which Instances of Oracle Are Running * /

/ usr / proc / bin / ptree / * Print The Parent / Child Process 'Tree' of a Process * /

/ usr / proc / bin / pwdx / * Print The Working Directory of A Process * /

TOP -B 1 / * RETURns The Process Utilizing The MOST CPU and Quits * /

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 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 start cwd * /

Find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print / * Find without Traveingsing NFS MOUNTED File Systems * /

Find. -mtime -1 -type f / * find recently modified files * / find / -mtime <# of days> / * find files modified during the paste # of days * / find.! -mtime - | / USR / BIN / XARGS RM-RM-RM-RM / * FINDS AND Removes Files Older Than Specified * /

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

Find. -type f -exec grep -l "" {} /; / * Find filenames containing within 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 by name and automatic removes them * /

Find / proc / * / fd -links 0 -type f -size 2000 -ls / * Find Large Files Held Open BY A Process * /

LS -LR | grep / * fast alternative to find * /

Security

Echo 'please Go Away'> / etc / nologin / * Stops Uses Logging in * /

Find / -perm -0777 -type d -ls / * find all your write 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 backss key to ERASE * /

STTY ERASE ^? / * sets the delete key to Erase * /

Stty Sane / * RRRESET 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 & Host * /

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

Snoop -i / tmp / mylog -o / tmp / new logfile1 / * 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 defices * /

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 / * set the system to perform Diagnostics on the next reboot. * /

/ usr / sbin / eeprom local-mac-address? = true / * multiple port network card setting * /

/ usr / sbin / grpck / * check / etc / group file syntax * /

/ usr / sbin / pwck / * check / etc / passwd file syntax * /

/ usr / sbin / sys-unconfig / * Clear Host Specific Network Configuration Information * /

System Information and Monitoring, SYSTEM INMMATION

Coreadm-E LOG / * Report Global Core * /

/ bin / echo "0T $ {stamp}> y / n

/ USR / SBIN / EEPROM / * SHOW EEPROM Parameters * /

GREP "/-ROOT" / var / ad "| tail -25 / * list MOST Recent attempts to switch to super service account. * / isainfo -bv / * quickly checkout if machine is in 32 or 64 Bit mode * /

Last / * Tells Who Was or Still Is on The System * /

Logger -i / * log the process id * /

PSRADM -F [Processor ID] / * Take Processor offline * /

/ usr / sbin / prtconf -vp / * show system configuration details * /

/ usr / platform / `/ bin / uname -i` / sbin / prtdiag -v / * system diagnostics * /

Prtconf -PV | Grep banner-name | awk -f / '' {print $ 2} '| Head -1 / * show activ model name of machine * /

PSRINFO | WC -L / * Display Number of Processors * /

SAR -A

SAR -A

SAR -U / * Report CPU Utilization * /

Telnet 13 | GREP ':' / * Get The Time On Remote Unix Machine * /

Uname -a / * displays system information * /

VMSTAT 10 / * Displays Summary of what the system is doing every 10 seconds * /

WHO -B / * DISPLAYS the date of the last system reboot. * /

Ypcat hosts | sort -n -t. 0 -1 1 -2 2 -3 3 -4 / * Take the input of "Ypcat Hosts" or "catch / etc / inet / hosts" and sort by ip. * /

转载请注明原文地址:https://www.9cbs.com/read-107593.html

New Post(0)