loader image

Antivirus (Debian/Ubuntu/Xubuntu) Free

What makes us different from other similar websites? Forums Tech Antivirus (Debian/Ubuntu/Xubuntu) Free

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1935
    thumbtak
    Moderator

    If you need an antivirus for Linux, which most users do not, then run the following command in Terminal Emulator.

    sudo apt install clamav clamtk

    #6789
    thumbtak
    Moderator

    How to do a full system scan with ClamTK. Note: It is unlikely that you will have viruses outside your home folder, as that would require root. Also, note that viruses are less common with Linux, when compared to other operating systems.

    1. Open ClamTK.

    #7052
    thumbtak
    Moderator

    How to scan the system with terminal emulator

    Install antivirus
    $ sudo apt install clamav

    Update database
    $ sudo freshclam

    Scan the whole system with information being displayed
    $ clamscan -r -v --bell -i --exclude-dir="/sys" /

    #7159
    thumbtak
    Moderator

    If you want to create a full system log (and have it save a text file with the results), you can run the following command. Note, this will scan the whole system (with no indication it is running besides your fans might ramp up, if you have any) and create a text file for viewing any infected files, if any are found.

    $ clamscan -r -v --bell -i --exclude-dir="/sys" / > clamscan-results.txt

    Another command you could run is …
    $ clamscan -r / --log=scan_results.txt

    Do not open the txt file before it is complete. I would open it in an advanced text editor like sublime (https://www.sublimetext.com/) and search for the word FOUND. This will show you which files it found. You may also run the following command below to have terminal show you any files it finds that are infected.

    $ grep "FOUND" scan_results.txt

    • This reply was modified 11 months, 3 weeks ago by thumbtak. Reason: Added another command and more info
    • This reply was modified 11 months, 3 weeks ago by thumbtak. Reason: Updated grep command
    • This reply was modified 5 months, 2 weeks ago by thumbtak. Reason: Fixed forum code
    #8013
    thumbtak
    Moderator

    You can also use these commands:

    This displays the txt after saving it.
    $ sudo clamscan -r / --bell --exclude-dir="/sys" | tee clamscan-results.log

    This command only shows anything it finds.
    $ sudo clamscan -r / --bell --exclude-dir="/sys" | grep "found" > clamscan-results.txt

    #8165
    thumbtak
    Moderator

    If you want a percentage with an output (txt) with info about the infected files, run the following:

    Install:

    $ sudo apt update
    $ sudo apt install pv

    Mask a bash script with the code below:

    #!/bin/bash
    
    # --- Configuration ---
    SCAN_DIR="/" # Directory to scan (root in this case)
    EXCLUDE_DIR="/sys" # Directory to exclude from scan
    RESULTS_FILE="clamscan-results.txt" # File to save results to
    
    # --- Check for pv (Pipe Viewer) ---
    if ! command -v pv &> /dev/null
    then
    echo "Error: 'pv' (Pipe Viewer) is not installed."
    echo "Please install it first: sudo apt install pv"
    exit 1
    fi
    
    echo "--- Starting ClamAV Scan with Progress ---"
    echo "This might take a while, especially the initial file counting phase."
    
    # --- Step 1: Count the total number of files to be scanned ---
    # We use -xdev to stay on the same filesystem (avoiding mounted network drives, etc.)
    # We exclude /sys from the count as clamscan will also exclude it.
    # 2>/dev/null suppresses permission errors from find.
    echo "Counting files to scan... (this may take a few minutes)"
    TOTAL_FILES=$(sudo find "$SCAN_DIR" -xdev -type f -print 2>/dev/null | grep -v "$EXCLUDE_DIR/" | wc -l)
    
    if [ "$TOTAL_FILES" -eq 0 ]; then
    echo "No files found to scan in $SCAN_DIR (excluding $EXCLUDE_DIR). Exiting."
    exit 0
    fi
    
    echo "Found $TOTAL_FILES files to scan. Starting ClamAV scan..."
    
    # --- Step 2: Run clamscan with pv progress bar and save results ---
    # Create a temporary file for the full scan log
    TEMP_SCAN_LOG=$(mktemp)
    
    # Use find to list files, pipe to xargs to run clamscan, then pipe to pv for progress.
    # The full clamscan output goes to the temporary log file.
    # pv's progress bar goes to stderr (your terminal screen).
    sudo find "$SCAN_DIR" -xdev -type f -print 2>/dev/null | grep -v "$EXCLUDE_DIR/" | \
    xargs -d '\n' sudo clamscan --bell --exclude-dir="$EXCLUDE_DIR" --stdout --no-summary | \
    pv -l -s "$TOTAL_FILES" 2> /dev/stderr > "$TEMP_SCAN_LOG"
    
    # --- Step 3: Filter "found" results from the temporary log to the final results file ---
    echo "" # Add a newline after the progress bar finishes
    echo "Scan complete. Filtering results..."
    grep "found" "$TEMP_SCAN_LOG" > "$RESULTS_FILE"
    
    # --- Step 4: Display a summary and clean up ---
    echo "Infected files (if any) are listed in: $RESULTS_FILE"
    echo "Full scan log is temporarily in: $TEMP_SCAN_LOG (will be removed)"
    
    # Clean up the temporary log file
    rm "$TEMP_SCAN_LOG"
    
    echo "Done."
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
TAKs Shack