Find the 30 most recently modified files
One way to find the 10 most recently modified files on Debian-based systems is to use find. Run this command in a terminal:
find . -type f -exec stat -c '%Y %n' {} + | sort -n -r | head -n 30Find files by a pattern
On Debian or another Linux distribution, use find to search for files matching a pattern. To find every file matching files.mail*, run:
find / -type f -name 'files.mail*'Copy a file from a server
To copy a file from a remote server to your local computer over SSH, run this command in a Windows terminal:
scp root@name.server:/var/backup/dir/dir_2023_01_01/name_2023_01_01.tar.gz d:/scp root@name.server:/var/backup/db/db_2023_01_01/dbname_2023_01_01.sql.gz d:/Find the 10 most frequent IP addresses in access.log
To find the 10 most frequent IP addresses in access.log, use awk together with sort and uniq on a Unix command line. For example:
awk '{print $1}' access.log | sort | uniq -c | sort -nr | head -n 10Find and display the 50 most frequent IP addresses from the last 10 minutes and prepare a blocking list
#!/bin/bash
# Установите временной диапазон
ten_minutes_ago=$(date -d "10 minutes ago" +"%d/%b/%Y:%H:%M:%S")
count=50
echo "========== $count =========="
# Фильтруем логи за последние 10 минут и обрабатываем их
awk -v time="$ten_minutes_ago" '$0 > time {print $1}' sitename.access.log | sort | uniq -c | sort -nr | head -n "$count"
echo "========== $count =========="
# Фильтруем логи за последние 10 минут, обрабатываем их и преобразуем в нужный формат
awk -v time="$ten_minutes_ago" '$0 > time {print $1}' sitename.access.log | sort | uniq -c | sort -nr | head -n "$count" | awk '{split($2, a, "."); print "deny " a[1]"."a[2]"."a[3]".0/24;"}' | sort -uDirectory size in gigabytes
du -sh --block-size=1G /var/www/projects/name