Posted: . At: 11:01 AM. This was 11 months ago. Post ID: 18095
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


View the most accessed pages on your website by parsing the Apache log.


Viewing the most accessed page on your Apache web server is very easy. This one-liner will allow a site administrator to view a list of the most viewed pages on a website. This is the easiest way to see how your website is doing and the most popular content on your website. This is using uniq -c to only view unique entries and then print a count of how many times the entry occurs in the list. This is pretty simple, but it works a treat. And you do not need to use cat to pipe to awk, it can read the command by itself. And using sort with a reverse numeric sort.

┗━━━━━━━━━━┓ john@localhost ~/Downloads
           ┗━━━━━━━━━━━━━╾ ╍▷ awk '{print $7}' securitronlinux.com-ssl_log-May-2023 | grep "/bejiitaswrath/" | sort | uniq -c | sort -rn | head -n 10
   1323 /bejiitaswrath/filter-for-a-specific-time-frame-in-wireshark/
   1204 /bejiitaswrath/how-to-use-xrdp-on-linux-mint-15-to-allow-remote-desktop-connections-from-windows-8/embed/
   1199 /bejiitaswrath/how-to-use-vnc-to-connect-to-a-remote-linux-machine-and-administer-it-with-the-graphical-desktop/embed/
   1198 /bejiitaswrath/how-to-open-an-rdp-connection-to-windows-from-linux-using-the-remote-desktop-utility-for-gnome/embed/
   1103 /bejiitaswrath/how-to-use-ublock-origin-to-block-a-certain-annoying-javascript-easily/
   1044 /bejiitaswrath/a-very-nice-chatgpt-4-jailbreak-this-works-very-well/embed/
   1044 /bejiitaswrath/another-chatgpt-jailbreak-allows-the-ai-to-use-harsh-language/embed/
    978 /bejiitaswrath/how-to-create-keys-with-easy-rsa-without-a-password-prompt/
    906 /bejiitaswrath/how-to-list-all-mac-addresses-on-a-network-with-tcpdump/
    797 /bejiitaswrath/how-to-toggle-the-caps-lock-key-with-the-command-line-in-linux-mint/

This is a very simple solution to this problem.

awk '{print $7}' securitronlinux.com-ssl_log-May-2023 | grep "/bejiitaswrath/" | sort | uniq -c | sort -rn | head -n 30

Better than messing around with complicated solutions, just use this instead. This is very simple to use.

Or as a shell script like this. Just pass arguments to add the logfile filename and the blog tag.

logs.sh
1
2
3
#!/bin/bash
 
awk '{print $7}' $1 | grep "/$2/" | sort | uniq -c | sort -rn | head -n 30

Below we can see how well this works. This is great for parsing the Apache log from a WordPress website.

┗━━━━━━━━━━┓ john@localhost ~/Documents
           ┗━━━━━━━━━━━━━╾ ╍▷ ./logs.sh ../Downloads/securitronlinux.com-ssl_log-May-2023 bejiitaswrath
   1323 /bejiitaswrath/filter-for-a-specific-time-frame-in-wireshark/
   1204 /bejiitaswrath/how-to-use-xrdp-on-linux-mint-15-to-allow-remote-desktop-connections-from-windows-8/embed/
   1199 /bejiitaswrath/how-to-use-vnc-to-connect-to-a-remote-linux-machine-and-administer-it-with-the-graphical-desktop/embed/
   1198 /bejiitaswrath/how-to-open-an-rdp-connection-to-windows-from-linux-using-the-remote-desktop-utility-for-gnome/embed/
   1103 /bejiitaswrath/how-to-use-ublock-origin-to-block-a-certain-annoying-javascript-easily/
   1044 /bejiitaswrath/a-very-nice-chatgpt-4-jailbreak-this-works-very-well/embed/
   1044 /bejiitaswrath/another-chatgpt-jailbreak-allows-the-ai-to-use-harsh-language/embed/
    978 /bejiitaswrath/how-to-create-keys-with-easy-rsa-without-a-password-prompt/
    906 /bejiitaswrath/how-to-list-all-mac-addresses-on-a-network-with-tcpdump/
    797 /bejiitaswrath/how-to-toggle-the-caps-lock-key-with-the-command-line-in-linux-mint/
    709 /bejiitaswrath/useful-filters-for-4chanx-these-are-very-good-to-have/
    700 /bejiitaswrath/how-to-crack-a-sha512-linux-password-hash-with-oclhashcat-on-linux/
    698 /bejiitaswrath/an-alternative-to-the-wget-command-for-linux-how-to-use-curl-to-download-files/
    654 /bejiitaswrath/hyprland-is-a-very-nice-new-wayland-compositor-for-linux/
    654 /bejiitaswrath/enable-copy-and-paste-vmware-kali-linux/
    631 /bejiitaswrath/how-to-use-the-git-clone-command-through-a-http-proxy/
    628 /bejiitaswrath/how-to-use-ffmpeg-to-merge-multiple-videos-side-by-side/
    618 /bejiitaswrath/install-a-very-useful-youtube-app-on-linux-and-watch-youtube-without-a-browser/
    590 /bejiitaswrath/cracking-linux-user-passwords-on-linux-using-hashcat/
    561 /bejiitaswrath/how-to-convert-binary-numbers-to-decimal-using-the-bash-shell/
    550 /bejiitaswrath/very-nice-c-code-to-generate-a-random-string-and-some-other-useful-info/
    548 /bejiitaswrath/list-files-by-modification-date-with-the-ls-command-on-linux/
    525 /bejiitaswrath/how-to-read-http-cookies-with-wireshark-and-some-other-useful-tips/
    513 /bejiitaswrath/how-to-type-extended-ascii-characters-on-ubuntu-and-linux-mint-with-the-keyboard/
    510 /bejiitaswrath/4chan-depicted-in-a-tv-show-and-they-get-it-so-wrong/
    501 /bejiitaswrath/how-to-make-the-title-bars-in-gnome-shell-much-thinner-than-the-default/
    499 /bejiitaswrath/nvidia-cards-on-linux-are-still-a-problem-as-far-as-fan-speed-goes/embed/
    499 /bejiitaswrath/how-to-search-a-file-with-grep-for-certain-hexadecimal-values/
    472 /bejiitaswrath/a-few-ways-to-list-disk-information-in-linux-mint/
    450 /bejiitaswrath/samsung-dex-in-windows-11-is-awesome-control-a-samsung-phone-from-your-windows-pc/

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.