Cylabs
  • 😊Welcome to CyLabs
  • 101 Series
    • Cyber Security 101
      • Introduction to Cyber Security and core concepts
      • Getting Started into Cyber Security Career
      • Online Cybersecurity Practice Labs to Sharpen Your Skills
      • Cyber Security Interview Q&A
        • Careers in Cybersecurity
      • Stay Tuned : Cyber Resources
        • Blogs for Cyber Security
          • Blogs
            • Penetration Testing Automation
            • Security
              • Metasploit Framework
              • Jenkins Servers: Identifying Vulnerabilities and Exploiting Unauthenticated Access with Groovy Scrip
              • Securing Your Network: Printer Vulnerabilities, LDAP Exploits, and Defense Strategies
              • SSH for Red Teaming and Security Analysis
              • Operating Systems for Penetration Testing: Enhancing Your Cybersecurity Arsenal
              • Hacking Notes
                • Phineas Fisher
        • Cyber News
        • Leading Cybersecurity Companies to follow
        • Cybersecurity Courses and Certifications: Trends in 2024
        • ISACs: Enhancing Cybersecurity through Collaboration and Information Sharing
        • Global and National Cybersecurity Agencies: Guardians of the Digital Realm
        • Cyber Security News Feed Resources
    • Kubernetes 101
    • Web 101
    • Operating Systems
      • Linux 101
        • Linux Kernel
        • Basic Commands and Usage
          • Shell Commands
        • Linux File System
        • apt
        • su and sudo
        • File Search
        • Linux Services
        • Networking
          • Netcat
        • Corn Jobs
        • Shell Scripting
        • Linux OS API's
      • Windows 101
        • Windows system calls
        • Windows Event Logs and IDs
        • Windows UAC
        • Windows Registry
        • Windows Bit Locker
        • Volume Shadow Copy Service
        • Windows OS API's
    • Building the Security Lab
      • Virtualization with Virtual Box
        • Installing and setting Virtual Box
        • Vritual Box Networking
      • Home Lab Setup
        • PF Sense Installation
        • Ubuntu Installation
        • Metasploit Installation
        • Kali Linux Installation
    • Fundamentals of Programming
      • Python 101
      • Powershell 101
      • SQL 101
    • AI/ML and Data Science for Cyber Security and Analytics
    • IT Infrastructure and Hardware
    • Governance, Risk and Compliance
    • Networking 101
      • Network Packets and Frames
      • Network Switches and Routers: The Backbone of Connectivity
      • Network Security Devices and Strategies
      • Network Design and Architecture: A Foundation for Robust Connectivity
      • Specialized Network Equipment and Functions
      • Network Traffic Management and Analysis
      • Advanced Networking Concepts
      • ARP and RARP
      • How DNS, HTTP and HTTPS works
      • Understanding the Basics of Networking
  • Introduction to Cyber Security Operations
    • Security Architecture and Engineering
      • Security Controls
        • Preventive
        • Deterrent
        • Detective
        • Corrective
        • Compensating
        • Directive
    • GRC
      • Information Security and Risk Management
        • Risk Management
        • Supply Chain Risk Management
        • Governance
        • Asset Management
        • Cyber Security Road Map
        • Cyber Security Controls
        • Cyber Security Strategy and Architecture
        • Cyber Security Architecture
        • Risk Assessment and Security Questionnaire
        • Ransomware Prevention
        • Gap Assessment
        • Principle of Least Privilege
      • Governance
      • Asset Security
      • Communication and Network Security
      • Identity and Access Management
      • Security Assessment and Testing
      • Security Operations
      • Software Development Security
      • Security Baselines
      • Security Reporting
      • Data Loss Prevention
      • Zero Trust
      • MFA
      • Compliance
    • Security Policies and Procedures
    • Offensive Security
      • Stages of Penetration Testing
    • Cyber Defense
      • Security Operations Center (SOC)
        • SOC Architecture Development with ELK Stack:
      • Different Classes of Threat Actor
    • Security Principles, Controls and Strategies
      • Defense in Depth
      • Least Privilege
      • Zero Trust
  • Cyber Security Assessment
    • Planning and Scoping
      • Security Engagement
      • Security Assessment Questionaire
      • Who Targeting you
    • Reconnaissance
      • Active Recon
        • Tools
          • NMAP
          • Maascan
          • Recon-NG
          • Maltego
          • Spider Foot
          • Whois
          • TraceRoute
          • Amass
          • The Harvester
          • Nslookup
          • DNS Dumpster
          • BloodHound
          • Relay Attacks
          • Packet Crafting
          • NMAP+Proxychains+TOR
      • Passive Reconnaissance
        • Network Sniffing
          • Wireshark
          • TCPDump
        • Whois (online services)
        • EMail Account Enumeration
          • Hunter.io
        • Search Engine Analysis
          • Google Hacking Database
          • Shodan
          • Censys.io
        • Information Disclousre
        • Banner Grabbing
        • HTML Scrapping
        • Certificate Transparency Logs
        • Open Source Intelligence (OSINT)
          • Ship OSINT
          • Social Media
          • Code Repositories
          • Darkweb Analysis
          • DNS
          • Cached Pages
          • Password Dumps
          • Anonymity
    • Enumeration
      • OS Finger Printing
      • Service Discovery
      • Protocol Enumeration
      • DNS Enumeration
      • FTP Service
      • HTTP/HTTPS
      • WMI
      • DCOM
      • RPC Remote Procedure Call
      • Directory Enumeration
      • Host Discovery
      • Share Enumeration
        • SMB
      • Local User Enumeration
      • Email Account Enumeration
      • SSH Service
      • Wireless Enumeration
        • Wigle.net
        • InSSIDer
        • Aircrack-ng
      • Permission Enumeration
      • Secrets Enumeration
        • Passwords
        • Session Tokens
        • Cloud Access Keys
      • Attack Path Mapping
      • VNC
      • Web Application Firewall
      • Wordpress Scan
      • Remote Desktop Protocol
      • SNMP
      • SMTP
      • Web Crawling
        • Platform Plugins
        • Sitemap
        • Robots.txt
      • Active Directory Enumeration
    • Vulnerability Assessment and Management
      • Terminology
      • Vulnerability Database
      • Vulnerability Scoring
        • CWE
        • CVSS
        • CVE
        • EPSS
      • Vulnerability Scan
        • Authenticated vs Unauthenticated Scans
        • OS Security Assessment
        • Tenable
        • Nikto
        • Open VAS
      • Exploit Databases
      • Tools
        • Tenable.IO
        • Open VAS
    • Exploitation
      • Attack Surface and Target Prioritization
        • High Valued Assets and Identification
        • Vulnerability Metrics
        • End of Life Softwares
        • Default Configuration
        • Running Services
        • Vulnerable Encryption Methods
        • Defensive Capabilities
        • Attack Path
      • Attack Types
        • Network Attacks
          • Virtual LAN Hopping
          • Packet Crafting
            • Attacks Scenario
          • Default Credentials
          • On-Path / Man in the Middle Attacks
          • Certificate Services Attacks
      • Host Based Attacks
        • Privilege Escalation
        • Credential Dumping
        • Shell Escape
        • UAC Bypass
        • Payload Obfuscation
        • Endpoint Security Bypass
        • Process Hallowing
        • Log Tampering
        • DLL Injection
        • Service Path Injection
      • Authentication Attacks
        • LDAP Injection
        • SAML Attacks
        • Open ID Connect Attacks
        • Dictionary Attacks
        • Credential Stuffing
        • MFA Fatigue
        • Pass the Hash attacks
        • Kerberos Attacks
        • Pass the Ticket Attacks
      • Vulnerable Encryption Methods
      • Tools
        • Metsploit
        • Netcat
        • LOLbins
        • Mimikatz
        • Rubeus
        • Certify
        • AD Search
        • Powerview
        • SeaBelt
        • Evil winRM
        • PSEXEC
        • Powersploit
        • Metasploit
        • Impacket
        • Responder
        • CrackMapExec
        • Msfvenom
        • Responder
        • Searhsploit
        • Powersploit
      • Password Attacks
        • Password Cracking
        • Password Spraying
        • Tools
          • Medusa
          • Burpsuite
          • John the Ripper
          • Hydra
          • Hashcat
        • Password Attacks
    • Lateral Movement
      • Relay Creation
      • String Searches
      • Service Discovery
      • Tunneling
        • SSH Tunneling
      • Pivoting
      • Exfiltration
        • DNS
        • HTTPS
        • EMail
        • Cloud Storage
      • Tools
        • sshuttle
        • Page 1
    • Post Exploitation
      • Persistance
        • Scheduled Taks
        • Bind Shell
        • Registry Keys
        • C2 Frameworks
        • Tampering Security Controls
        • Back Door
          • Trojan
          • Root Kit
          • Web Shell
        • Searching Valid Account Credetials
        • New Account Creation
        • Reverse Shell
        • Service Creation
        • Cron Jobs
      • Command and Control
    • Reporting
  • Cybersecurity Frameworks and Standards
    • CREST
    • CIS
    • NIST Publications
      • NIST SP 800-171
      • NIST CSF
      • NIST SP 800-115
    • MITRE
      • MITRE D3FEND
      • MITRE ATT&CK
    • Penetration Testing Execution Standard (PTES)
    • OWASP Top 10
    • Purdue Model
    • Open Source Security Testing Methodology Manual (OSSTMM)
    • Council of Registered Ethical Security Testers (CREST)
    • Zero Trust
    • CMMC
    • Threat Modeling Frameworks
      • STRIDE
      • OCTAVE
      • DREAD
    • Mitigation Strategies
      • Network Segmentaion
      • Access Control
      • Application Control
      • Isolation Techniques
      • Default Password Changes
      • Host based firewall
      • Protocol blocking
      • Port blocking
      • Host based intrusion prevention
      • Endpoint Management
      • Decommissioning
      • Configuration Management
      • Least Privilege
      • Logging
      • Monitoring
      • Encryption
      • Patching
    • Security Governance
      • Data and System: Roles and Responsiblities
      • Security Policies
        • Access Use Policy
      • Security Standards
        • Access Control
        • Encryption
        • Password
      • Security Procedures
        • Change Management
  • Security Domains
    • Security Designing
    • Application Security
      • Cryptographic Attacks
      • Password Attacks
      • Web Application Security
        • Enumeration
          • Cookie and Header Security Review
        • Bruteforce Attack
        • Directory Traversal
        • Insecure Direct Object Reference (IDOR)
        • Session Hijacking
        • File Inclusion Attacks
          • LFI
          • Webshell
          • RFI
        • Server-Side Request Forgery (SSRF)
        • Deserialization Attacks
        • Command Injection
        • Server Side Template Injection
        • Cross Site Scripting (XSS)
        • SQL Injection
          • Union Based SQL Injection
          • Blind SQL Injection
        • Cross-Site Request Forgery (CSRF)
        • XML External Entity (XXE)
        • File Upload Vulnerabilites
        • Remote Code Execution (RCE)
        • Tools
          • Hetty
      • OWASP TOP 10 API
        • API Abuse
        • JWT Token manipulation
        • Graph QL security
        • API security
      • OWASP Top 10 Mobile
      • OWASP Top 10 IOT
      • Web Application Security
        • Getting Started in BugBounty Hutning
        • Subdomain Enumeration
        • Subdomain Takeover: Understanding the Risks and Prevention
        • Tools and Technologies
      • Microservices
      • WPscan
        • Burpsuite
        • Ffuf
        • Gobuster
        • Postman
        • Dirbuster
        • Wfuzz
        • ZAP
      • Tools
        • BurpSuite
        • SQLmap
    • Cloud Security
      • Metadata Service Attacks
      • IAM misconfigurations
      • Tools
        • Pacu
        • Prowler
        • Scoutsuite
        • Docker Bench
      • Container Escape
      • Workload Runtime Attacks
      • Supply Chain Attacks
      • Misconfigurations
        • Network Segmentation
        • Network Controls
        • IAM Credentials
        • Public Access to Services
        • Exposed Storage Buckets
        • Logging Information Exposure
      • Azure Security : Components and Assessment Guide
        • Azure Security Assessment Tools : Installation and usuage
    • Identity and Access Management
    • Cloud Security
      • Cloud Engineering and Architecture concepts
      • Cloud Data Security
      • Cloud Platform and Infrastructure Security
      • Cloud Application Security
      • Cloud Security Operations
      • Cloud Legal, Risk and Compliance
      • Azure Security
      • Azure Pentest
    • DevSecOps
      • Static Application Security Testing (SAST)
        • Code Quality
        • CheckMarx
        • Sonarqube
          • Sonarqube Installation using Helm Chart on AKS
      • Interactive Application Security Testing (IAST)
      • Dynamic Application Security Testing (DAST)
      • SCA
      • Wazuh SIEM and XDR
        • Wazuh on Azure AKS
        • Azure + Argo
      • DevSecOps
    • Social Engineering
      • Vishing
      • Spearphishing
      • Smishing
      • Eavesdropping
      • Impersonation
      • Watering Hole
      • Shoulder Surfing
      • Whaling
      • Phishing
      • Tools
        • GoPhish
        • Beef
        • Evilginx
        • SET social engineering toolkit
    • DevOps
      • Kubernetes
        • Kubernetes Architecture and Components
        • Mastering kubectl: The Command Line Interface for Kubernetes
        • Overview of Kubernetes Tools and Utilities
        • Container vs Pod vs Deployment
        • Kubernetes and Docker Swarm
        • Deploying a Kubernetes Cluster Using Minikube
        • Deploying a Kubernetes Cluster Using Kind
        • Integrating Kubernetes with Azure Key Vault
        • Containers vs Virtual Machines
        • Comprehensive Guide to Kubernetes Security and Analysis Tools
        • Monitoring Kubernetes with Prometheus and Grafana
        • Introduction to Azure Kubernetes Service (AKS) and Deploying Your First Cluster
        • Kubernetes Persistence with Backend Databases
        • Kubernetes StatefulSet vs. Deployment
        • DevSecOps Architecture for Kubernetes
      • Docker
      • Helm
        • Scenario : Configuring Azure Key Vault and Using Secrets in Helm Deployments
      • Git Ops
        • Argo CD
      • Git and Versioning
      • Terraform
      • Virtualization
    • Mobile Security
      • Android Mobile App Security Assessment
      • Suspicious Malware App Analysis
      • Android App Penetration Testing
      • Permission Abuse
      • Jailbreak/Rooting
      • Tools
        • MobSF
        • Drozer
        • Frida
    • IOT/OT/SCADA
      • Power Supply
        • Juice Jacking
      • RFID
      • Bluetooth
        • BlueJacking
        • Bluetooth Spamming
      • Ports and Services
      • Port Mirroring
      • Modbus Attack
      • CAN Bus Attack
      • Replay Attack
      • Memory Registry Attacks
      • Tools
        • BlueCrack
        • Scapy
        • TCP Replay
    • Network Security
      • Network Attacks
        • DNS Attacks
        • DDOS
      • Network Assessment
      • Wireshark
      • Zeek
      • Snort
      • TCPDump
      • Defensive Network
        • Firewalls
        • Intrusion Detection System
    • Wireless Attacks
      • Service Set Identifier (SSID)
      • Wardriving
      • Evil Twin Attack
      • Deauthentication Attacks
      • Signal Jamming
      • Channel Scanning
      • Signal Strength Scanning
      • Tools
        • WiFi Pumpkin
        • AirCrack Ng
        • Kismet
    • Purple Teaming
      • Tools
        • Infection Monkey
        • Atomic RedTeam
        • Caldera
    • Kubernetes Security
      • AKS Security
      • Kube-Hunter
      • KubeEscape
    • Hardware Security
    • Container Security
      • Grype
      • Trivy
      • Clair
    • AI
      • LLM (Large Language Models)
      • Prompt Engineering
      • AI Cyber Security Risk Management
        • AI Policies
      • AI Security
      • AI Attacks
        • Prompt Injection
        • Model Manipulation
      • Security Frameworks
        • MITRE ATLAS
        • OWASP Top 10 LLMs
        • NIST AI Risk Management Framework
    • Reverse Engineering
      • Scenarios
        • Browser Plugin
        • PDF document
        • Word Doc
        • Windows Binary File
        • Mobile App
      • Buffer Overflow
  • Operational Security
    • Identity and Access Management
      • Identity
      • Authentication
      • Accountability
      • Access Management
      • Authorization
      • Access Controls
    • Deception Technology
      • Honeypot
      • Honeynet
      • Honeyfile
      • Honey Token
    • Cryptography
      • Data at Rest
      • Data at Transit
      • Hashing
      • BlockChain
      • Digital Signatures
      • Certificates
      • Encryption
        • Public Key Infrastructure (PKI)
          • Public Key
          • Private Key
        • Tools
      • Certification Preparation
        • Penetration Testing
        • GRC and Audit
    • File Integrity Monitoring
    • Data Security
      • DLP
    • Change Management
      • Impact Analysis
    • Malware Analysis
      • Malware Analysis Tool
      • Malware Analysis Books
      • university courses and resources related to malware analysis
      • Binary Analysis
    • Data Loss Prevention
    • Threat Modeling
      • Attack Surface Management
        • Introduction
      • Threats, Technologies, Procedures
        • Threat Actors
      • Threat Hunting
        • Indicators of Compromise
      • Threat Assessment
        • Threat Modeling
          • OCTAVE
          • DREAD
          • STRIDE
        • Threat Hunting
          • Threat Hunting Blogs
          • Ransomware: An Overview
          • Threat Hunting and Incident Response Q&A
          • Network Traffic Analysis: Wireshark
          • Threat Hunting Questionnaire
          • KQL
          • Email Header Analysis
          • TH
          • Windows Process Exploration
        • Threat Intelligence
          • Threat Intelligence Tools and Techniques
            • Yara
      • Malware Attacks
    • Digital Forensics
      • Network Forensics
      • Forensic Tool Analysis
      • Data Recovery
    • Endpoint Management
    • SOC/SOAR
      • Threat hunting scenarios
      • Log Management
        • AWS VPC flow log analysis
        • Linux Logs
        • Windows Logs
    • Ransomware Prevention
      • APT Groups
    • Security Automation
      • C
      • Powershell
      • Python
      • C++
      • GO
      • Rust
    • Incident Response
      • Scenarios
        • Windows : No Event Logs
      • Tools
        • Chainsaw
    • Defensive Security Controls
    • Physical Security
      • Physical Attacks
        • USB (Universal Serial Bus)
        • Tailgating
        • Lock Picking
        • RFID Cloning
          • Badge Cloning
    • Personal Security
    • Security Awareness and Training
    • Firewall
    • Network Access Control
    • Intrusion Detection System
    • Intrusion Prevention System
    • Operating System Security
    • Secure Protocol Usuage
    • Business Continuity
    • Email Security
    • DNS Filtering
    • user behaviour analytics
    • Host Security
    • Mobile Device Security
    • Change Management
    • Vulnerability Management
      • Vulnerability Assessment
        • Vulnerability Analysis
      • Types of Vulnerabilites
    • Penetration Testing/Red Teaming
    • Disaster Recovery
    • Logging and Monitoring
      • Monitoring
        • Systems
        • Infrastructure
        • Applications
      • Logging
        • Log Data
          • Application Logs
          • Network Logs
          • WAF Logs
          • IDS/IPS logs
          • OS logs
          • Endpoint Logs
          • Firewall Logs
        • Alerting
        • Log Aggregation
      • Tools
    • Endpoint
    • Security Metrics
  • Industry Specific Security:Case Studies
    • Aviation Security
      • The Integral Role of Airports in National Security : Operations Perspective
      • Cyber Attacks on Airports
      • Navigating the Complex Web of Airport Operations: Key Components and Leading Industry Providers
    • Aviation Security
  • Computational Science
    • Quantum Computing
      • Quantum Computing: Unleashing the Power of Qubits
    • Probability
  • Data Engineering
  • AI/ML and Data Science
    • Installation
      • Ollama
    • Machine Learning
    • Large Language Models (LLM)
    • Security Analytics
    • Untitled
      • Roles and Responsibilites
      • Azure AI Services
        • AI Services Security
        • Monitoring Azure AI Services
        • AI services on containers
  • Application Development
    • Django
  • Radom Topics :)
    • CSA WAI
  • CISSP
Powered by GitBook
On this page

Was this helpful?

  1. 101 Series
  2. Operating Systems
  3. Linux 101

Basic Commands and Usage

Linux, with its robust set of commands, is a playground for those who crave control over their computing environment. Whether you are a system administrator, a developer, or a cybersecurity enthusiast, mastering Linux commands is an essential skill. Let's delve into some of the fundamental commands and their usage in various scenarios, including network communication, file manipulation, system management, and security testing.

Certainly, let's go through each of the Linux commands listed and explain their basic usage:

  1. ls: This command lists the contents of a directory. If no directory is specified, it lists the contents of the current directory. For example, ls /home will list all files and directories in the /home directory.

  2. pwd: Stands for "print working directory". This command prints the full pathname of the current working directory.

  3. cd: Stands for "change directory". This command changes the current directory to another one. For example, cd /var/www changes the current directory to /var/www.

  4. man: This command displays the user manual of any command that we can run on the terminal. For example, man ls shows the manual pages for the ls command.

  5. adduser: The adduser command is used to create a new user. For example, adduser moha would create a new user named moha.

  6. To add a user to the sudoers group, the command should be usermod -aG sudo moha, where moha is the username.

  7. touch: This command is used to create a new empty file. For example, touch filename will create a new file named filename in the current directory.

  8. cp: This command is used to copy files and directories. For example, cp source destination will copy the file from source to destination.

  9. rm: This command is used to remove files or directories. For example, rm filename will delete the file named filename. It is a command that must be used with caution.

  10. echo: This command is used to display a line of text/string that are passed as an argument. For example, echo hello > demo creates a file named demo and writes "hello" to it.

  11. echo hello >> demo: Appends "hello" to the file demo. If demo does not exist, it will be created.

  12. File Permissions:

    • Read (4): Permission to read the file.

    • Write (3): Permission to modify the file.

    • Execute (1): Permission to execute the file as a program/script.

    File permissions are denoted as a three-digit number, with each digit corresponding to the user, group, and others, respectively.

  13. chmod: This command changes the file permissions. For example, chmod 755 filename sets the read, write, and execute permissions for the user, and read and execute permissions for the group and others for filename.

  14. Editors (vi and nano):

    • vi: A text editor in the Unix systems, vi filename opens the file in the vi editor.

    • nano: A simpler, user-friendly text editor, nano filename opens the file in the nano editor.

  15. cat: Concatenate files and print on the standard output. For example, cat filename will display the contents of filename.

  16. grep: Used to search text or searches the given file for lines containing a match to the given strings or words. For example, grep 'pattern' filename will search for 'pattern' in filename.

  17. cut: Removes sections from each line of files. For example, cut -d':' -f1 filename will cut the first field from each line in filename.

  18. sed: Stands for "stream editor", it is used to perform basic text transformations on an input stream. For example, sed 's/old/new/g' filename will replace all occurrences of 'old' with 'new' in filename.

  19. awk: A programming language and utility that excels at text processing and is often used for data extraction and reporting. For example, awk '{print $1}' filename will print the first column in filename.

  20. whoami

Each of these commands can be very powerful and are often combined in scripts or command lines to perform complex tasks. Always ensure you understand the commands and use them carefully, especially when modifying or deleting files.

File and Text Manipulation Commands

  • wget: This network downloader can retrieve files from the web and is often used to download packages or files from a specified URL.

  • cat: Short for concatenate, cat reads file contents and outputs them in the terminal. It’s often piped with other commands for file creation and merging.

  • grep: The global regular expression print command is used to search for text patterns within files. For example, grep "cisco\.com" would search for instances of 'cisco.com'.

  • cut: This command is used to extract sections from each line of files, often combined with delimiters to parse data.

  • sort -u: Sorts the input data and -u flag ensures that the output is unique, removing duplicate lines.

  • find: A powerful command to search for files in a directory hierarchy, capable of running commands on the files found.

  • locate: Quickly searches for files by name, leveraging a database updated by updatedb.

Network Communication with Netcat

  • netcat (nc): A versatile networking tool used for reading from and writing to network connections using TCP or UDP. It's used for creating server-client setups, port scanning, and transferring files.

    • Listening mode: nc -nlvp 444 sets up a listener on port 444, which can be used to receive data.

    • Connecting mode: nc -nc victim_ip 444 initiates a connection to a listening port, enabling data transfer.

System Services Management

  • SSH: ssh command is used for secure remote logins to other systems. Managing the SSH service involves starting (service ssh start) and stopping (service ssh stop) the daemon, as well as enabling persistence across reboots (update-rc.d ssh enable).

  • Apache: Managing the Apache web server often involves starting (service apache2 start) and stopping (service apache2 stop) the service, as well as enabling it at boot (update-rc.d apache2 enable).

Cybersecurity and Penetration Testing Commands

  • chmod +x and chmod 777: These commands change the file permissions to make scripts executable or universally accessible, a necessary step in many penetration testing tasks.

  • ping sweep: A basic network scanning technique to discover active hosts on a network.

  • bindshell and reverse shell: Techniques used to maintain access to a compromised system. The bind shell opens a new service on the victim, while the reverse shell makes the victim connect to the attacker's system.

  • ncat: An advanced version of netcat that provides additional features like SSL encryption for secure communication.

Regular Expressions and Scripting

  • Bash Script: A bash script can automate the process of finding subdomains and IP addresses. For example, a loop like `for url in $(file.txt); do ...; done

` can iterate through a list of URLs in a file and perform actions on each.

  • Regular expressions: Used with commands like grep, they allow for pattern matching and data extraction from text files.

Monitoring and Diagnostics Tools

  • Wireshark: A GUI-based network protocol analyzer that can capture and interactively browse the traffic running on a computer network. It's used extensively in network troubleshooting and analysis.

  • Remote Desktop: rdesktop is a command-line utility that allows you to create a remote desktop session with another system.

System Update and Upgrade

  • Apt-get Commands: On Debian-based systems, apt-get update, apt-get upgrade, and apt-get dist-upgrade are used to update the package index and then upgrade all the installed packages to their latest versions.

Using Linux Commands in Penetration Testing

The aforementioned Linux commands are not only useful for regular system administration tasks but are also crucial in the context of cybersecurity and penetration testing. Here's a brief overview of how some of these commands can be used in a penetration testing scenario:

  • Ping Sweep: Used to identify which IP addresses are active on a network.

  • Netcat: A Swiss army knife for networkers which can be used to set up ad-hoc servers to catch or send data. It can also be used for port scanning and is frequently employed in the creation of backdoors and reverse shells.

  • Bind Shell and Reverse Shell: Creating a command-line interface on the victim's system that can be accessed remotely by an attacker, allowing them to execute commands as if they were physically present.

  • Firewall Bypassing with Ncat: By using SSL with Ncat, attackers can attempt to bypass firewall restrictions on a network to establish a secure and hidden channel.

Shell Scripting

  • Definition: Shell scripting is a way to automate tasks and create programs within a command-line interface (CLI) environment like Bash, Zsh, or PowerShell.

  • Uses:

    • System administration: Automating repetitive tasks like backups, updates, and file management.

    • Data processing: Manipulating files, text, and data within the CLI.

    • Creating custom tools: Building small programs to enhance command-line workflows.

  • Components: shell scripts are composed of:

    • Commands: Standard commands you'd normally type at the command prompt (like ls, cd, grep)

    • Variables: Placeholders for storing data.

    • Control flow structures:

      • Conditional statements (if, else)

      • Loops (for, while)

    • Functions: Reusable blocks of code

Shell Operators

Shell operators are special symbols used within shell scripts to perform various operations. Here are some main categories:

  • Arithmetic Operators

    • + (addition)

    • - (subtraction)

    • * (multiplication)

    • **/ ** (division)

    • % (modulo: remainder after division)

  • Comparison Operators

    • -eq (equal to)

    • -ne (not equal to)

    • -gt (greater than)

    • -lt (less than)

    • -ge (greater than or equal to)

    • -le (less than or equal to)

  • Logical Operators

    • ! (NOT)

    • && (AND)

    • || (OR)

  • File Test Operators

    • -e (file exists)

    • -d (directory exists)

    • -f (regular file exists)

    • -r (file is readable)

    • -w (file is writable)

  • String Operators

    • = (string equality)

    • != (string inequality)

    • -z (string is empty)

Example

A simple shell script to check if a file exists and is readable:

Bash

#!/bin/bash
filename="my_file.txt"

if [ -f $filename ] && [ -r $filename ]; then
    echo "The file exists and is readable."
else
    echo "The file does not exist or is not readable."
fi

Conclusion

In the realm of Linux, the command line is the gateway to a world of powerful functionalities. From managing files and processes to securing and diagnosing network systems, the knowledge of these basic commands is invaluable. Whether you're scripting a quick one-liner to find a subdomain or leveraging Netcat for complex network interactions, each command holds the potential to unlock a deeper understanding of the Linux operating system. As Linux continues to evolve and be adopted in various sectors, these commands serve as the foundational tools for anyone looking to harness the full potential of this open-source powerhouse.

PreviousLinux KernelNextShell Commands

Last updated 12 months ago

Was this helpful?