Linux System Administration and Monitoring Commands
System identification begins with viewing machine identity and runtime statistics. The hostname utility displays or temporarily modifies the system hostname, though persistent changes require editing network configuration files rather than runtime invocation.
$ hostname # Display system hostname
$ hostname -f # Show fully qualified domain name (FQDN)
For user context inspection, the id command reveals numeric identifiers and group memberships. When executed without arguments, it targets the current session; specifying a username queries that account's credentials.
$ id
$ id username
Verify these values against /etc/passwd for user data and /etc/group for group definitions. Scripts frequently employ whoami to capture the active username for audit trails and conditional execution paths.
$ whoami
Process inspection utilizes ps with appropriate flags. While ps alone shows terminal-specific processes, comprehensive system-wide enuemration requires the -e flag for all processes and -f for full-format listing.
$ ps -ef
Key column interpretations:
- UID: User identifier executing the process
- PID: Unique process identifier
- PPID: Parent process identifier (processes lacking valid parents become defunct/orphaned)
- C: Processor utilization percentage
- STIME: Process initiation timestamp
- TTY: Controlling terminal (indicates
?for daemon processes) - TIME: Accumulated CPU execution time
- CMD: Executable path or command name
Filter specific processes using pattern matching:
$ ps -ef | grep process_pattern
For real-time resource monitoring, top provides dynamic process statistics. This interactive interface refreshes continuously until terminated with q. Critical metrics include:
- PID: Process identifier
- USER: Process owner
- PR: Scheduling priority
- VIRT: Total virtual address space allocated
- RES: Resident set size (physical memory occupied)
- SHR: Shared memory footprint
- S: State indicators (
Sfor sleeping/interruptible wait,Rfor running) - %CPU: Processor consumption percentage
- %MEM: Physical memory utilization percentage
- COMMAND: Executable name or path
Memory calculation note: Actual physical memory consumption equals RES minus SHR, as shared segments count toward multiple processes simultaneously.
Interactive shortcuts within top:
M: Sort by memory utilization (descending)P: Sort by CPU utilization (descending)1: Toggle individual CPU core statistics on multi-processor systems
Storage analysis employs du (disk usage) with summary flags. The -s flag aggregates directory totals while -h renders sizes in human-readable units (KB, MB, GB).
$ du -sh /path/to/directory
File system traversal utilizes find with type and name predicates. This utility searches directory hierarchies based on various metadata criteria.
$ find /search/path -name "pattern"
$ find /search/path -type f # Regular files only
$ find /search/path -type d # Directories only
Service management traditionally used service commands, though modern distributions prefer systemctl. Both interfaces control daemon initialization states.
$ service daemon_name start|stop|restart
$ systemctl start|stop|restart daemon_name.service
For Apache HTTP server specifically:
$ systemctl start httpd
# Verify activation:
$ ps aux | grep httpd
Process termination signals interrupt execution via kill (requiring PID identification) or killall (targeting by process name). These utilities dispatch SIGTERM or SIGKILL to manage unresponsive or completed applications.
$ kill PID_number
$ killall process_name
Network interface configuration inspection historically relied on ifconfig, though ip addr serves as the modern replacement. Both display interface identifiers, IP assignments, and hardware addresses.
$ ifconfig
$ ip addr show
System power management commands control machine states. reboot initiates restart sequences, while shutdown schedules cessation with optional warning messages.
$ reboot
$ reboot -w # Simulate restart (log test only)
$ shutdown -h now "System maintenance imminent"
$ shutdown -h 14:30 "Scheduled downtime"
Cancel pending shutdowns with shutdown -c (Ctrl+C works on legacy systems).
Alternative halt methods include:
$ init 0
$ halt
$ poweroff
System availability metrics from uptime display current time, duration since initialization, active user sessions, and load averages. This metric persists across suspend/resume cycles.
$ uptime
Kernel and architecture details emerge through uname. The -a flag reveals comprehensive system attributes including kernel release, machine hardware name, and operating system.
$ uname
$ uname -a
Network connection enumeration uses netstat or the newer ss utility. Filter TCP listening sockets with specific flags:
$ netstat -tnlp
$ ss -tlnp
Flag meanings:
-t: TCP protocol filter-n: Numeric display (avoid DNS resolution)-l: Listening sockets only-p: Associated process identifiers and names
Documentation access occurs through man pages, providing comprehensive command references.
$ man command_name
# Press 'q' to exit pager
Shell line editing accelerates command composition. Ctrl+U clears text from cursor to line beginning, while Ctrl+K removes from cursor to line end.