☀️ Solaris Shell Basics
Solaris provides a robust enterprise Unix environment with powerful shell capabilities. Understanding Solaris shell fundamentals is essential for effective system administration in enterprise environments.
🎯 Solaris Shell Environment
Shell Options and Default Setup
Solaris supports multiple shell environments with enterprise-focused defaults:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | # Check current shell
echo $SHELL
# Available shells in Solaris
/bin/sh # POSIX Bourne shell
/usr/bin/ksh # KornShell (default for many users)
/usr/bin/bash # GNU Bash (if installed)
/usr/bin/zsh # Z Shell (if installed)
/usr/xpg4/bin/sh # X/Open compliant shell
# Check shell versions
ksh --version # KornShell version
bash --version # Bash version (if available)
# Shell configuration files
~/.profile # Login shell configuration
~/.kshrc # KornShell runtime configuration
|
Terminal and Console Management
1
2
3
4
5
6
7
8
9
10
11
12
13 | # Terminal configuration
stty -a # Display terminal settings
stty sane # Reset to sane defaults
tabs -8 # Set tab stops
# Console management
who -r # Run level information
who am i # Current login information
last # Last logged in users
# Virtual console switching (SPARC)
eject cdrom # Eject CD-ROM
poweroff # Shutdown system
|
🔧 Basic Command Structure
Standard Unix Commands with Solaris Extensions
Solaris includes both standard Unix commands and Oracle-enhanced versions:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # File operations
ls -la@ # List with extended attributes (@)
cp -p file1 file2 # Copy preserving attributes
mv oldname newname # Move/rename files
rm -f file.txt # Force remove
mkdir -p path/to/dir # Create parent directories
rmdir emptydir # Remove empty directory
# File viewing and editing
cat file.txt # Display file contents
more file.txt # Page through file
pg file.txt # Pager (Solaris specific)
head -20 file.txt # First 20 lines
tail -20 file.txt # Last 20 lines
vi file.txt # Vi editor
# Enhanced file operations
ls -ltra # Long format, time sorted, reverse
du -sh * # Disk usage summary
df -h # Human-readable disk space
find . -name "*.log" -mtime -7 # Find recent log files
|
Process Management
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # Process viewing
ps -ef # All processes (standard format)
ps -eo pid,ppid,uid,args # Custom format
prstat # Solaris top-like utility
ptree $$ # Process tree for current shell
# Process control
kill 1234 # Terminate process
kill -9 1234 # Force kill process
pkill -f "process_name" # Kill by name pattern
killall process_name # Kill all matching processes
# Process information
pargs 1234 # Process arguments
pmap 1234 # Process memory map
plimit 1234 # Process resource limits
|
📋 File System Navigation
Solaris Directory Structure
Solaris follows traditional Unix hierarchy with Oracle-specific additions:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 | # Core directories
/ # Root directory
/usr # Secondary hierarchy
/usr/bin # User binaries
/usr/sbin # System binaries
/usr/local # Local software
/etc # System configuration
/var # Variable data
/opt # Optional software (Oracle packages)
/export # Exported filesystems
# Solaris-specific directories
/usr/sfw # Solaris Freeware
/usr/ccs # Compiler collection
/usr/dt # Desktop tools
/usr/openwin # OpenWindows
/usr/X11 # X Window system
# System configuration
/etc/vfstab # Filesystem table (like fstab)
/etc/system # Kernel parameters
/etc/inet/hosts # Host name resolution
/etc/default/ # Default configuration files
# Device files
/devices # Device tree
/dev # Device aliases
/dev/rdsk # Raw disk devices
/dev/dsk # Block disk devices
|
File Permissions and Attributes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | # View file permissions and attributes
ls -l filename # Standard permissions
ls -la@ filename # Extended attributes
ls -lZ filename # SELinux context (if enabled)
# Permission modification
chmod 755 script.sh # Set permissions
chmod +x script.sh # Make executable
chmod -R 755 directory/ # Recursive permissions
# Ownership modification
chown user:group file.txt # Change owner and group
chown user file.txt # Change owner only
chgrp group file.txt # Change group only
# Solaris-specific attributes
chmod A+user:permission filename # ACLs
lsattr filename # List file attributes
chattr +i filename # Set immutable attribute
# Permission checking
[ -r file.txt ] && echo "Readable"
[ -w file.txt ] && echo "Writable"
[ -x file.txt ] && echo "Executable"
|
🌐 Network Operations
Network Configuration and Management
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | # Network interface configuration
ifconfig -a # All interfaces
ifconfig hme0 # Specific interface
ifconfig hme0 192.168.1.100 netmask 255.255.255.0 # Set IP
# Network services and status
netstat -an # All network connections
netstat -i # Interface statistics
netstat -rn # Routing table
# Solaris network management
svcs network/* # Network services
svcadm enable network/physical # Enable network service
# DNS and name resolution
nslookup google.com # DNS lookup
dig google.com # Detailed DNS query
getent hosts hostname # Host name resolution
# Network diagnostics
ping 192.168.1.1 # Basic connectivity
traceroute google.com # Route tracing
snoop # Packet sniffer (Solaris)
|
Remote Access and File Transfer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # Secure shell
ssh user@hostname
ssh -i ~/.ssh/key.pem user@host
# Secure copy
scp file.txt user@host:/path/
scp user@host:/path/file.txt .
# Solaris-specific remote tools
rlogin hostname # Remote login (legacy)
rsh hostname command # Remote shell (legacy)
rcp file user@host:/path # Remote copy (legacy)
# Network file systems
mount -F nfs server:/path /mnt # NFS mount
share # Show shared resources
|
🛠️ System Administration
Package and Patch Management
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # Solaris Package Management (SVR4)
pkginfo # List installed packages
pkgadd -d package.pkg # Install package
pkgrm package_name # Remove package
pkgchk package_name # Check package integrity
# Solaris 11 IPS (Image Packaging System)
pkg list # List installed packages
pkg install package_name # Install package
pkg uninstall package_name # Remove package
pkg update # Update packages
pkg search keyword # Search for packages
# Patch management
patchadd patch_id # Apply patch (Solaris 10 and earlier)
patchrm patch_id # Remove patch
showrev -p # Show installed patches
# Solaris 11 updates
pkg update system/kernel # Update kernel
pkg update # Update entire system
|
Service Management (SMF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # Service Management Facility (SMF)
svcs # List all services
svcs -a # List all services (including disabled)
svcs network/ssh # Check specific service
svcs -l network/ssh # Detailed service information
# Service control
svcadm enable service_name # Enable service
svcadm disable service_name # Disable service
svcadm restart service_name # Restart service
svcadm refresh service_name # Refresh service configuration
# Service configuration
svcprop service_name # Show service properties
svccfg -s service_name setprop property=value # Set property
svccfg import manifest.xml # Import service manifest
|
🎨 Development Environment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # Oracle Developer Studio (formerly Sun Studio)
cc # C compiler
CC # C++ compiler
f77 # Fortran 77 compiler
f95 # Fortran 95 compiler
# GNU tools (if installed)
gcc --version # GNU C compiler
g++ --version # GNU C++ compiler
make # Standard make
gmake # GNU make
# Build automation
cmake # CMake (if installed)
ant # Apache Ant (Java)
mvn # Apache Maven (Java)
# Version control
sccs # Source Code Control System (legacy)
svn --version # Subversion (if installed)
git --version # Git (if installed)
|
Scripting and Automation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # Shell scripting
ksh script.sh # Execute with KornShell
sh script.sh # Execute with Bourne shell
bash script.sh # Execute with Bash (if available)
# System monitoring scripts
sar -u # CPU usage statistics
sar -r # Memory usage statistics
iostat -x # I/O statistics
vmstat 5 # Virtual memory statistics
# Log analysis
logins # Show system logins
last # Last logged in users
lastb # Last bad login attempts
|
🔍 Advanced Features
ZFS File System
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | # ZFS management
zpool list # List storage pools
zfs list # List datasets
zpool status # Pool status
zpool iostat # Pool I/O statistics
# ZFS operations
zfs create pool/dataset # Create dataset
zfs destroy pool/dataset # Destroy dataset
zfs snapshot pool/[email protected] # Create snapshot
zfs rollback pool/[email protected] # Rollback to snapshot
# ZFS properties
zfs set compression=lz4 pool/dataset
zfs set quota=10G pool/dataset
zfs get all pool/dataset
|
Containers and Virtualization
| # Solaris Zones (Containers)
zoneadm list -cv # List zones
zonecfg -z zonename info # Zone configuration
zoneadm -z zonename boot # Boot zone
zlogin zonename # Login to zone
# Resource management
prctl $$ # Process resource controls
projects # Project management
|
🧾 Summary Quick Reference
Essential Commands
| Category |
Command |
Description |
| Navigation |
cd, pwd, ls |
Directory navigation |
| Files |
cp, mv, rm, mkdir |
File operations |
| Viewing |
cat, more, pg |
File content viewing |
| Processes |
ps, prstat, kill |
Process management |
| Network |
ifconfig, netstat, ping |
Network operations |
| Packages |
pkginfo, pkgadd |
Package management |
| Services |
svcs, svcadm |
Service management |
Solaris-Specific Locations
| Path |
Purpose |
/etc/vfstab |
Filesystem table |
/etc/system |
Kernel parameters |
/usr/sfw |
Solaris Freeware |
/usr/ccs |
Compiler collection |
/var/svc/manifest |
SMF manifests |
/rpool |
Default ZFS pool |
🧠 Best Practices
Solaris Shell Usage Guidelines
✅ Recommended Practices:
- Use SMF for service management
- Leverage ZFS for advanced storage features
- Utilize Solaris-specific monitoring tools
- Follow Oracle's security recommendations
- Use proper package management system
- Understand privilege separation model
❌ Common Pitfalls to Avoid:
- Mixing legacy and modern tools unnecessarily
- Ignoring ZFS capabilities
- Not using SMF properly
- Running services without proper configuration
- Disabling security features
- Using deprecated administrative interfaces
Enterprise Administration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # System monitoring
sar -A # All system activity
iostat -xn 5 # Extended I/O statistics
vmstat 5 # Memory and CPU statistics
mpstat 5 # Per-CPU statistics
# Log management
logadm # Log rotation
syslogd # System logging daemon
tail -f /var/adm/messages # Follow system log
# Performance tuning
prtconf # System configuration
psrinfo # Processor information
swap -s # Swap space usage
|
🧾 See Also