Essential Linux Commands for Beginners

Jul 31, 2024

Essential Linux Commands for Cyber Security

Introduction

  • Presenter: Neilson Networking
  • Topic: Essential Linux commands and their special flags
  • Target Audience: Beginners in ethical hacking and cybersecurity
  • Advanced Topics: Metasploit, Nmap, Hydra (covered in other videos)

Navigating the Linux File System

  • Methods: GUI vs. Terminal
    • GUI: File Explorer, Nautilus
    • Terminal (preferred method)

Commands

  1. ls (List Directory Contents)
    • ls: Basic listing
    • ls -l: Long listing
      • Details Provided: Links, permissions, owner, group, size, modification date
    • ls -a: Show hidden files
    • ls -t: Sort by modification time
    • ls -h: Human-readable sizes
    • Combining Flags: ls -lath
  2. cd (Change Directory)
    • cd [directory]: Navigate to a directory
    • cd -: Return to the previous directory
    • cd ..: Go up one level
    • cd ~: Go to home directory
    • Tab Completion: Use Tab key to auto-complete paths
  3. pwd (Print Working Directory)
    • pwd: Shows the current directory
  4. clear
    • clear: Clears the terminal screen

Manipulating Files and Directories

  1. touch (Create Empty Files)
    • touch [filename]: Create an empty file
  2. mkdir (Make Directory)
    • mkdir [directory_name]: Create a single directory
    • mkdir -p [directory_tree]: Create nested directories
    • mkdir -m 777 [directory_name]: Create directory with specific permissions
  3. cp (Copy Files and Directories)
    • cp [source] [destination]: Copy files
    • cp -r [directory] [destination]: Copy directories recursively
  4. rm (Remove Files and Directories)
    • rm [filename]: Remove a file
    • rm -r [directory]: Remove a directory recursively
    • rm [pattern*]: Remove files with a specific pattern
  5. mv (Move/Rename Files and Directories)
    • mv [source] [destination]: Move or rename files/directories

Viewing Disk Usage

  1. du (Disk Usage)
    • du: Shows disk usage of directories
    • du -h: Human-readable format
    • du -s: Summary of usage

File Permissions and Ownership

  1. chmod (Change Mode/Permissions)
    • chmod [u|g|o]+/-[r|w|x] [file]: Modify permissions
    • chmod 777 [file]: Numeric method for setting permissions
  2. chown (Change Ownership)
    • chown [user]:[group] [file]: Change file owner and group

Viewing and Combining File Contents

  1. cat (Concatenate and Display Files)
    • cat [file]: Display file contents
    • cat [file1] [file2] > [newfile]: Combine files
    • echo [text] > [file]: Write text to a file
  2. tail (Display End of File)
    • tail [file]: Display last 10 lines
    • tail -n [number] [file]: Display last n lines
    • tail -f [file]: Follow file changes
  3. head (Display Start of File)
    • head [file]: Display first 10 lines
    • head -n [number] [file]: Display first n lines
  4. less & more (Page Through Files)
    • less [file]: View file one page at a time
    • more [file]: Similar to less, but less feature-rich

Text Editors

  1. vi/vim
    • vi [file]: Open file in vi editor
    • Edit Mode: i (Insert)
    • Command Mode: : (colon), followed by commands like w (write), q (quit)
  2. nano
    • nano [file]: Open file in nano editor
    • User-Friendly: Easier for beginners

Process Management

  1. ps (Process Status)
    • ps: Shows processes for current user
    • ps aux: Detailed process listing
  2. top (Real-Time Process Overview)
    • top: Real-time process monitoring
    • top -u [username]: Filter by user
  3. kill (Terminate Process)
    • kill [PID]: Terminate process by PID
    • kill -9 [PID]: Forcefully terminate process
  4. jobs (Background Jobs)
    • jobs: List background jobs
    • bg: Resume a job in background
    • fg: Bring job to foreground

Networking Commands

  1. ifconfig (Network Interface Configuration)
    • ifconfig: Deprecated but shows network configuration
  2. ip (Newer Network Configuration Tool)
    • ip addr: Show IP addresses
    • ip route: Show routing table
    • ip addr add [IP] dev [interface]: Add IP address to interface
  3. netstat (Network Statistics)
    • netstat -l: Show listening ports
  4. ss (Socket Statistics)
    • ss -t: Show TCP sockets
    • ss -u: Show UDP sockets
    • ss -p: Show processes using sockets
  5. ssh (Secure Shell)
    • ssh [user]@[host]: Connect to remote machine
  6. scp (Secure Copy)
    • scp [local_file] [user]@[host]:[remote_file]: Copy file to remote machine
  7. rsync (Remote Sync)
    • rsync [options] [source] [destination]: Sync files and directories

System Information

  1. uname (System Information)
    • uname -a: Detailed system information
  2. df (Disk Free)
    • df -h: Shows disk space usage in human-readable format

Searching Files

  1. find (Search for Files)
    • find [path] -name [pattern]: Find files by name
    • find [path] -size +1M: Find files larger than 1MB
    • find [path] -mtime -30: Find files modified in the last 30 days
  2. grep (Search Within Files)
    • grep [pattern] [file]: Search for pattern in file
    • grep -r [pattern] [directory]: Recursively search in directory

Archiving and Compressing Files

  1. tar (Tape Archive)
    • tar czf [archive.tar.gz] [files]: Create compressed archive
    • tar xzf [archive.tar.gz]: Extract compressed archive
  2. gzip (Compress Files)
    • gzip [file]: Compress file
    • gunzip [file.gz]: Decompress file

User Management

  1. useradd (Add User)
    • useradd [username]: Add new user
    • useradd -m [username]: Add user with home directory
    • useradd -g [group] [username]: Add user to specific group
    • useradd -e [date] [username]: Add user with expiration date
  2. userdel (Delete User)
    • userdel [username]: Delete user
    • userdel -r [username]: Delete user and home directory
  3. groupadd (Add Group)
    • groupadd [groupname]: Add new group
  4. groupdel (Delete Group)
    • groupdel [groupname]: Delete group

Conclusion

  • Goal: Provide essential Linux commands necessary for cybersecurity beginners
  • Further Learning: Advanced tools and commands like Metasploit, Nmap, Hydra in other videos
  • Call to Action: Like, subscribe, and stay tuned for more content