Skip to content

Next Bootcamp Edition
May 4th, 2026

Back to Blog

Linux Commands for Cybersecurity: Beginner's Guide

Terminal window displaying Linux security commands with network traffic visualization

Master essential Linux commands for cybersecurity: file navigation, network analysis, log investigation, and security tools for beginners.

Daute Delgado
12 min read
(Updated: )
  • Defense
  • Detection
  • Mindset
  • Career Paths
  • Confidence
Share this article:

TL;DR

Linux commands are essential for cybersecurity professionals because 96% of web servers and most security tools run on Linux. The core commands every beginner must learn include file navigation (ls, cd, cat), text processing (grep, find, awk), network analysis (netstat, tcpdump, ss), and process management (ps, top, kill). SOC analysts use these commands daily to investigate alerts, analyze logs, and respond to incidents.

The alert came in at 2:47 AM. A junior SOC analyst stared at the blinking notification on her screen: suspicious outbound traffic from a production server. She knew how to read the alert, understood the threat indicators, and could explain what lateral movement meant in theory. But when she connected to the Linux server via SSH and faced that unforgiving black terminal, her mind went blank. Which command reveals active network connections? How do you find files modified in the last hour? What was the syntax for searching log files again?

That moment of paralysis cost precious minutes. By the time a senior analyst took over, the attacker had already exfiltrated data. The junior analyst learned something painful that night: cybersecurity knowledge without Linux command proficiency is like having a map but no legs to walk the terrain.

This reality confronts every newcomer to cybersecurity. The Linux Foundation reports that 96.3% of the world's top one million web servers run on Linux. Most security tools, from Wireshark to Nmap to Metasploit, are native to Linux environments. Yet many aspiring security professionals focus exclusively on concepts and certifications while neglecting the command-line skills that separate theoretical knowledge from practical capability.

Why Do Cybersecurity Professionals Need Linux Commands?

The terminal is not merely a tool for security professionals; it is the primary interface through which security work happens. When a penetration tester gains access to a target system, they face a command prompt. When a SOC analyst investigates suspicious activity, they query logs through command-line utilities. When a malware analyst dissects a suspicious binary, they use terminal-based tools for static and dynamic analysis.

The command line interface provides unparalleled control and visibility into system operations, making it an indispensable tool for security analysis, incident response, penetration testing, and system hardening.

SANS Institute·FOR577 Linux Incident Response Course

Three fundamental reasons explain why Linux dominates the security landscape. First, Linux systems power the infrastructure that security professionals protect and attack. Cloud servers, network appliances, IoT devices, and critical infrastructure predominantly run Linux or Unix-like systems. Understanding the environment you are defending or testing requires fluency in its native language.

Second, security tools are built for Linux. According to Kali Linux documentation, the distribution includes over 600 pre-installed tools for penetration testing and security auditing. These tools expect users to navigate file systems, pipe output between commands, and automate tasks through shell scripts. A graphical interface simply cannot provide the precision and speed that security operations demand.

Third, logs and evidence live in text files. Incident response revolves around analyzing system logs, network captures, and forensic artifacts. The command line offers unmatched power for parsing massive log files, filtering specific events, and correlating data across multiple sources. Security professionals report spending 60-70% of investigation time on command-line analysis, according to practitioners interviewed by Cybernous.

What Are the Essential File System Commands for Security Work?

Before investigating threats or testing systems, you must navigate and manipulate the file system. These foundational commands appear in virtually every security task, from malware analysis to log review to privilege escalation.

The ls command lists directory contents, but security work demands specific options. Use ls -la to reveal hidden files (those beginning with a dot) and detailed permissions. Attackers frequently hide malicious scripts or configuration files as hidden entries. The permissions column reveals whether files have dangerous settings, such as world-writable permissions or the SUID bit that can enable privilege escalation.

Navigation with cd and orientation with pwd seem trivial until you are connected to an unfamiliar server during an active incident. Knowing your current location prevents catastrophic mistakes like deleting files from the wrong directory or executing commands in production rather than test environments.

Reading file contents requires choosing the right tool. cat outputs entire files, useful for short configuration files or scripts. For log files containing thousands of lines, head and tail show the beginning or end respectively. The command tail -f /var/log/auth.log follows a log file in real-time, allowing you to watch authentication attempts as they happen, a technique invaluable during active investigations.

File permissions matter enormously in security contexts. The chmod command modifies permissions, while chown changes ownership. When investigating a compromised system, examining who owns suspicious files and what permissions they carry often reveals the attack vector or persistence mechanism. A web shell typically requires execute permissions, for instance, and discovering a PHP file owned by the web server with execute permissions in an upload directory signals immediate concern.

How Do You Search Through Files and Logs Effectively?

Log analysis separates effective security professionals from those who merely understand concepts. The grep command is perhaps the single most valuable tool in a SOC analyst's arsenal. It searches for patterns within files with remarkable speed, capable of processing gigabytes of logs in seconds.

Basic grep usage follows the pattern grep "pattern" filename. To find all failed SSH login attempts in authentication logs: grep "Failed password" /var/log/auth.log. But real power emerges through options. The -i flag enables case-insensitive matching. The -r flag searches recursively through directories. The -v flag inverts the match, showing lines that do not contain the pattern. The -c flag counts matches rather than displaying them.

Security professionals must master text processing tools like grep, sed, and awk. These commands transform raw data into actionable intelligence at speeds no graphical tool can match.

Red Hat Security Blog·Introduction to tcpdump

Combining grep with other commands through pipes unlocks sophisticated analysis. The command grep "Failed password" /var/log/auth.log | grep -v "invalid user" | cut -d' ' -f11 | sort | uniq -c | sort -rn extracts IP addresses from failed password attempts, excludes invalid username attempts, and ranks them by frequency. This single command line reveals which IP addresses are conducting password spraying attacks against valid accounts.

The find command locates files based on numerous criteria. Security applications include discovering recently modified files during incident response, finding files with dangerous permissions, and locating potential malware. The command find / -type f -mtime -1 2>/dev/null shows all files modified in the last 24 hours, a critical first step when investigating a potential compromise. The find / -perm -4000 2>/dev/null command locates all SUID binaries, which penetration testers check for privilege escalation opportunities.

The awk and sed commands provide advanced text processing. While their syntax appears cryptic to beginners, even basic usage accelerates security work. Using awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20 extracts and ranks the top 20 IP addresses from a web server access log, immediately highlighting heavy hitters that warrant investigation.

What Network Commands Do Security Analysts Use Daily?

Network analysis commands reveal what a system is doing on the wire, which connections exist, and what services are exposed. These commands appear constantly in SOC operations, penetration testing, and incident response.

The netstat command (and its modern replacement ss) displays network connections. During incident response, Erdal Ozkaya notes that "netstat runs directly on the affected system, providing an instant snapshot of active connections, listening ports, and associated processes". The command netstat -tulpn shows all TCP and UDP listening ports with their associated processes, revealing what services are running and whether unexpected programs are accepting network connections.

When investigating potential command-and-control communication, netstat -an | grep ESTABLISHED lists all active connections. Unusual destinations, non-standard ports, or connections from processes that should not communicate externally all warrant deeper investigation. Combining with grep allows filtering for specific concerns: netstat -an | grep ":4444" searches for connections on port 4444, commonly used by Metasploit payloads.

The ss command offers superior performance on modern systems. The command ss -tulpn provides the same information as netstat but queries the kernel directly rather than parsing /proc files. For systems with thousands of connections, this difference becomes significant.

Packet capture with tcpdump enables deep analysis of network traffic. Red Hat's documentation describes it as essential for "troubleshooting network issues as well as a security tool". Basic capture to a file: tcpdump -i eth0 -w capture.pcap. Filtering to specific traffic: tcpdump -i eth0 port 443 captures only HTTPS traffic. For incident responders, capturing traffic before, during, and after an alert provides evidence that GUI tools cannot replicate.

How Do You Monitor Processes and Hunt for Threats?

Process monitoring reveals what is actually running on a system. Malware, backdoors, and unauthorized access manifest as processes. Understanding process commands enables threat hunting at the system level.

The ps command lists processes. The command ps aux shows all processes with detailed information including the user running each process, CPU and memory usage, and the full command line. During investigations, comparing expected processes against actual running processes reveals anomalies. A webserver should run apache2 or nginx; unexpected processes like cryptocurrency miners or reverse shells indicate compromise.

Real-time monitoring with top or the more modern htop shows processes ranked by resource usage. During incident response, sorting by CPU reveals cryptominers. Sorting by network activity might expose data exfiltration. The top command also shows system load, helping distinguish between normal heavy usage and malicious activity.

Process trees via ps auxf or pstree reveal parent-child relationships. When malware spawns from a legitimate process, this relationship appears in the tree. A shell process spawned by a web server process suggests web shell activity. The command ps -ef --forest on Linux shows these relationships clearly.

Investigating specific processes requires examining their file descriptors and network connections. The lsof command (list open files) shows what files and network connections a process is using. The command lsof -p 1234 shows everything process 1234 has open. Finding that a "system" process has network connections to an external IP address confirms malicious activity.

For killing malicious processes, kill PID sends a termination signal. Stubborn processes require kill -9 PID for forceful termination. During incident response, killing processes provides immediate containment while you investigate further.

What Commands Support Log Analysis and Investigation?

System logs record security-relevant events that enable detection and investigation. Modern Linux systems using systemd store logs in the journal, accessible through journalctl. Traditional syslog entries reside in /var/log.

The journalctl command queries the systemd journal. Without arguments, it shows all logs. Common filters include: journalctl -u sshd for SSH daemon logs, journalctl --since "1 hour ago" for recent events, and journalctl -p err for error-level messages. For security investigations, combining filters narrows massive logs to relevant events: journalctl -u sshd --since "2026-01-30" --until "2026-01-31" | grep "Failed".

Traditional log files in /var/log contain valuable security information. The file /var/log/auth.log (or /var/log/secure on RHEL systems) records authentication events. The file /var/log/syslog captures general system messages. Web server logs typically reside in /var/log/apache2 or /var/log/nginx. Each log type requires different analysis approaches and grep patterns.

The last command shows recent logins, while lastb shows failed login attempts. During investigations, these commands quickly reveal authentication patterns. The who and w commands show currently logged-in users, essential for detecting unauthorized access during active incidents.

Combining commands creates powerful analysis pipelines. To find all unique source IPs that failed SSH authentication today:

grep "Failed password" /var/log/auth.log | grep "$(date +%b\ %d)" | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn

This single command extracts failed passwords from today only, parses out the IP addresses, counts unique occurrences, and ranks them. Such combinations distinguish efficient analysts from those who manually review logs.

How Do You Build Linux Skills for a Cybersecurity Career?

Learning Linux commands requires consistent practice in realistic environments. Reading about commands provides theoretical understanding; using them builds the muscle memory and intuition that security work demands.

Start with a local Linux environment. Windows Subsystem for Linux allows Windows users to run a full Linux distribution without dual-booting or virtual machines. Alternatively, install VirtualBox and create a virtual machine running Ubuntu or Kali Linux. The key is having an environment where you can practice without fear of breaking anything important.

Platforms like TryHackMe and HackTheBox provide structured learning paths with hands-on Linux challenges. These environments simulate real security scenarios while teaching command-line fundamentals. The HackTheBox blog notes that "the simple rule to follow when learning anything new, including Linux, is that the more you play with it, the easier it becomes".

Build a home lab for realistic practice. Set up a Security Onion instance for blue team practice, capturing and analyzing network traffic with the same tools used in enterprise SOCs. For offensive practice, Kali Linux provides the complete penetration testing toolkit. Working through deliberately vulnerable machines like those from VulnHub develops the practical skills employers seek.

Pursue certifications that validate Linux competency. CompTIA Linux+ proves foundational knowledge. For security-specific Linux skills, the SANS FOR577 course covers Linux incident response and threat hunting at an advanced level. Many SOC analyst positions list Linux experience as a requirement, and demonstrating command-line proficiency during interviews sets candidates apart.

Conclusion

The terminal represents where theoretical security knowledge transforms into practical capability. Every concept you learn about threats, vulnerabilities, and defenses eventually requires implementation through commands. Penetration testers conduct reconnaissance and exploitation through the command line. SOC analysts investigate alerts by querying logs and network connections. Incident responders contain breaches by examining processes and isolating systems.

The commands covered here represent the foundation. ls, cd, cat, grep, find, netstat, ps, and journalctl appear in nearly every security engagement. Master these before advancing to specialized tools. As your career progresses into areas like malware analysis, reverse engineering, or advanced penetration testing, the command-line foundation supports everything that follows.

Start today. Open a terminal, navigate to /var/log, and practice grep commands against real system logs. Set up Wireshark alongside tcpdump and compare their capabilities. Build the habit of solving problems through the command line rather than reaching for GUI tools. That junior analyst who froze at 2:47 AM eventually became the senior analyst who took over. The difference was not intelligence or education but dedicated practice with the commands that power security operations.

The path from cybersecurity beginner to capable practitioner runs directly through the Linux terminal. Every command you master brings you closer to the professional who handles incidents with confidence rather than consulting documentation during critical moments.

About the Author
Daute Delgado
Daute Delgado

Founder & Bootcamp Director

Security Engineer · AI Research

Cybersecurity strategist with experience spanning international organizations, aviation security, and Security Operations Centers. Former threat analyst and offensive security specialist now focused on workforce development. Researches the intersection of AI anthropology and machine behaviour to shape next-generation security education.

View Profile
Start Your Journey

Ready to Start Your Cybersecurity Career?

Join hundreds of professionals who've transitioned into cybersecurity with our hands-on bootcamp.

Start Your Journey

Ready to Start Your Cybersecurity Career?

Join hundreds of professionals who've transitioned into cybersecurity with our hands-on bootcamp.

Hours
360+
Success Rate
94%
Avg. Salary
$85K
Explore the Bootcamp