Skip to main content

Command Palette

Search for a command to run...

Essential Linux commands for CTF players

Published
3 min read
Essential Linux commands for CTF players
M

A passionate learner, who loves to learn new things in this tech world.

Some essential Linux commands you should learn to navigate, investigate, and manipulate files effectively for Capture The Flag (CTF) challenges:

1. Basic Navigation and File Management

  • ls: List files and directories.

  • ls -la: List all files, including hidden files, with detailed info.

  • cd: Change directory.

  • pwd: Show the current directory.

  • cp <source> <destination>: Copy files or directories.

  • mv <source> <destination>: Move or rename files.

  • rm <file>: Delete a file.

  • rm -r <directory>: Remove a directory and its contents.

2. File Viewing and Searching

  • cat <file>: Display file contents.

  • less <file>: View large files page by page.

  • head -n <number> <file>: Show the first few lines of a file.

  • tail -n <number> <file>: Show the last few lines of a file.

  • grep <pattern> <file>: Search for text patterns within files.

  • grep -r <pattern> <directory>: Recursively search for a pattern.

  • find <directory> -name <filename>: Locate files by name.

  • find / -perm 4000 2>/dev/null: Find files with the SUID bit set, which may have special permissions (useful in privilege escalation).

3. Network Commands

  • ping <host>: Test connectivity to a host.

  • ifconfig / ip a: Show network interfaces and IP addresses.

  • netstat -tuln: List open ports and associated services.

  • curl <url>: Fetch data from URLs (useful for web-based CTFs).

  • wget <url>: Download files from the web.

  • nmap <target>: Network scanning tool for identifying open ports and services.

4. Permissions and User Information

  • chmod <permissions> <file>: Change file permissions.

  • chown <user>:<group> <file>: Change file owner.

  • whoami: Show current user.

  • id: Show the current user’s ID and groups.

  • sudo -l: List commands you can run as sudo (helpful in privilege escalation).

5. System Information

  • uname -a: Display system information.

  • ps aux: List running processes.

  • top or htop: Real-time process monitoring.

  • df -h: Show disk usage.

  • du -sh <directory>: Check directory size.

  • env: List all environment variables.

6. Text Manipulation

  • echo <text>: Print text to the screen (can be redirected to files).

  • awk '{print $1}' <file>: Extract specific columns from text.

  • cut -d '<delimiter>' -f <field> <file>: Extract specific fields based on a delimiter.

  • sed 's/<old>/<new>/g' <file>: Replace text in files using regular expressions.

7. File Compression and Archiving

  • tar -xvf <file>.tar: Extract .tar archives.

  • tar -xzvf <file>.tar.gz: Extract .tar.gz archives.

  • zip <file>.zip <file> and unzip <file>.zip: Compress or decompress .zip files.

8. Cryptography and Encoding

  • base64 <file>: Encode or decode base64 files.

  • base64 -d <file>: Decode base64.

  • md5sum <file> and sha1sum <file>: Generate checksums for files, useful for hash cracking.

9. Scripting and Automation

  • bash <script>.sh: Run shell scripts.

  • chmod +x <script>.sh: Make a script executable.

  • for, while, if-else, and case statements: These can automate repetitive tasks.

10. File Permissions and Privilege Escalation Checks

  • ls -l <file>: Check permissions of files.

  • sudo -l: Identify sudo permissions for privilege escalation.

  • strings <file>: Display readable strings in binary files (useful for finding hidden information).

11. Binary Analysis and Reverse Engineering

  • strings <file>: Show strings in binary files.

  • file <file>: Identify file types (especially useful if the file type is unknown).

  • hexdump -C <file>: Show a file in hexadecimal format.

  • lsof: List open files and processes (useful for seeing what's in use).

12. Useful Tools

  • nc: Netcat is used to network and transfer data.

  • ssh: Secure shell access to remote servers.

  • gdb <binary>: GNU debugger, helpful in reverse engineering.

These commands cover a solid foundation for CTF challenges. Familiarizing yourself with these basics will help you move confidently across different types of CTF tasks.

More from this blog

PDCA cycle for Continuous improvement in our life

Continuous improvement এর জন্য PDCA (Plan-Do-Check-Act) cycle টি আমাদের জীবনের যেকোনো লক্ষ্য বা জীবনের উন্নতির ক্ষেত্রে অত্যন্ত গুরুত্বপূর্ণ। এর মাধ্যমে আমরা ধারাবাহিকভাবে সমস্যা সমাধান, লক্ষ্য অর্জন এবং কার্যক্ষমতা বৃদ্ধি করতে পারি। এই প্রক্রিয়াটির ...

Nov 10, 20242 min read
PDCA  cycle for Continuous improvement   in our life

Masum Kazi

5 posts