UnixDroid

Beginner · 7 missions

Reading & searching text — Linux terminal practice

Read big files the smart way: head, tail, wc and grep on a real-looking server log.

student@unixdroid: ~

Missions in this track

Badi files aur logs ko head, tail, wc aur grep se padhna seekho.

  1. 1

    First lines

    Show the first 5 lines of /var/log/auth.log.

    Show the command
    head -n 5 /var/log/auth.log

    auth.log records every login attempt on a Linux server.

  2. 2

    Last lines

    Show the last 3 lines of the same log.

    Show the command
    tail -n 3 /var/log/auth.log

    tail -f file keeps following a log live — used daily by SOC analysts.

  3. 3

    Count lines

    Count how many lines the log has.

    Show the command
    wc -l /var/log/auth.log

    wc -l counts lines, -w words, -c bytes.

  4. 4

    Search

    Show only the lines that contain Failed password.

    Show the command
    grep "Failed password" /var/log/auth.log

    grep is the most used command in log analysis.

  5. 5

    How many?

    Count the failed password lines, then submit the number.

    Show the command
    grep -c "Failed password" /var/log/auth.log

    Many failed logins in a short time = a brute-force attack.

  6. 6

    Ignore case

    Search for invalid user ignoring upper/lower case, with line numbers.

    Show the command
    grep -in "invalid user" /var/log/auth.log

    "Invalid user" means someone guessed a username that does not even exist.

  7. 7

    Check a setting

    In /etc/ssh/sshd_config, find the PermitRootLogin setting and submit its value.

    Show the command
    grep PermitRootLogin /etc/ssh/sshd_config

    PermitRootLogin yes is a classic weakness — attackers can brute-force root directly.