هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
الهدف
قبل أن تبدأ
- Make test data:
mkdir -p ~/lab3/data/{a,b,c} for i in {1..30}; do head -c $((i * 40000)) /dev/urandom > ~/lab3/data/a/file$i.bin; done touch -d '40 days ago' ~/lab3/data/a/file{1..5}.bin printf '%s\n' "2026-11-08 10:01 LOGIN ok user=ana ip=10.0.0.5" "2026-11-08 10:02 LOGIN fail user=root ip=203.0.113.9" "2026-11-08 10:03 LOGIN fail user=admin ip=203.0.113.9" "2026-11-08 10:04 LOGIN ok user=ben ip=10.0.0.7" "2026-11-08 10:05 LOGIN fail user=test ip=198.51.100.4" > ~/lab3/auth.log
المهام
ضع علامة على المهمة عندما تنتهي منها. متصفحك فقط يتذكر ذلك.
- List all files in
~/lab3/databigger than 1 MB, with their size, biggest first. - Find the files not changed for more than 30 days and compress them with
gzipin one pipeline that also works with spaces in names. - Make a compressed archive
~/lab3/data-YYYY-MM-DD.tar.gz(today's date in the name) of~/lab3/data, then list its contents without extracting. - Copy
~/lab3/datato~/lab3/backupwithrsync. Delete one file in the source, then sync again so the backup is the same as the source. Show what would be deleted first. - From
~/lab3/auth.log: print only the failed logins, then count failures per IP address (most first). - Change the date format in the log from
2026-11-08to08.11.2026withsed, without changing the file. - Print a table with
printf: the column titlesIPandFAILS, and one line per IP, aligned.
تحقّق من عملك
تلميحات
اعرض التلميحات
find -size +1M,du -h,sort -hr.find -mtime +30 -print0 | xargs -0 gzip.$(date +%F)gives the date asYYYY-MM-DD;tar czfmakes,tar tzflists.rsync -av --delete -nis a dry run.grep -Eo 'ip=[0-9.]+', thensort | uniq -c | sort -rn.- Back references in sed:
\(…\)and\1.
الحل
اعرض الحل
- Big files, biggest first.
- Compress old files safely.
- Archive with the date and list it.
- Sync, delete, dry run, sync again.
- Failed logins and the count per IP.
- Change the date format.
sed 's/^\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)/\3.\2.\1/' ~/lab3/auth.log - Print an aligned table.
ملاحظاتي
لا توجد ملاحظات بعد.