• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

?"I Will Find You..." - Taken (Linux Edition)

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Hello again, Linux Learners!

I’m currently leveling up my Linux skills through a training course, and let’s be honest, sometimes the CLI can feel like a maze. But what if Liam Neeson from Taken were your mentor? ?

“I don’t know who you are... I don’t know what you want... But I will find you...”
In this article, we’re diving into four essential Linux commands. First, we’ll create the files and folders we need to practice. You'll be the hero, and your terminal is your weapon of choice. Let’s go full Bryan Mills on these commands. ??


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Table of Contents

  • Setting Up Your Taken-Inspired Practice Environment
  • Mission 1: The find Command
  • Mission 2: head & tail
  • Mission 3: wc
  • Final Mission: All Commands, One Operation
  • Final Words
⚙ Setting Up Your Taken-Inspired Practice Environment


Before we start running commands, let’s create a mission simulation in your home directory. We’ll generate files with:

  • Different names
  • Different sizes (small and large)
  • Different owners (optional)
  • Different folders

You’ll be ready to test find, head, tail, and wc like a real digital detective.

? Step 1: Create Directories


mkdir -p ~/taken_mission/{documents,secure,interrogation-room,kidnapper}
cd ~/taken_mission


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Step 2: Create Test Files

? 2.1 Regular Text Files


cd documents
echo "Secret USB Data" > usb_dump.txt
echo "clue file 1" > clue1.log
echo "clue file 2" > clue2.log
echo -e "We have your daughter.\nBring $5 million.\nNo police." > ../ransom_note.txt
echo -e "This is line 1\nThis is line 2\nThis is line 3" > suspicious_log.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? 2.2 Create Large Files


fallocate -l 120M largefile1.log
fallocate -l 200M largefile2.log


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




yes "Log Entry" | head -n 2000000 > verbose_log.log
⚠ Caution:

The command above writes "Log Entry" 2 million times to the verbose_log.log file.

? DO NOT open this file using cat, nano, or a graphical text editor, it could freeze your terminal or system.

✅ Instead, safely preview the file using:

head verbose_log.log
tail verbose_log.log
wc -l verbose_log.log


These commands let you inspect the beginning, end, or line count without overloading your system.
? 2.3 Simulate Different File Owners


sudo useradd kim
sudo chown kim:kim usb_dump.txt
ls -l usb_dump.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? 2.4 Add Files to Other Folders


cd ~/taken_mission/kidnapper
echo "Surveillance data" > cam_feed1.log
fallocate -l 150M cam_feed2.log
cd ~/taken_mission


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Mission 1: The `find` Command - Your Digital Bloodhound

? Syntax


find [path] [options] [actions]
?️‍♂ Common Options

OptionDescription
-nameSearch by name (case-sensitive)
-inameSearch by name (case-insensitive)
-size +100MFiles larger than 100MB
-user kimFiles owned by specific user
-type fFiles only
?️ Actions

ActionDescription
-exec cp {} /path \;Copy found files
-exec mv {} /path \;Move found files
-exec rm {} \;Delete found files
? Scenario: The USB Drive Mystery


find ~/taken_mission/documents -name "usb_dump.txt"
find ~/taken_mission/documents -size +100M
find ~/taken_mission/documents -name "usb_dump.txt" -exec cp {} ~/taken_mission/secure/ \;
find ~/taken_mission/documents -name "usb_dump.txt" -exec mv {} ~/taken_mission/interrogation-room/ \;
find ~/taken_mission/documents -name "usb_dump.txt" -exec rm {} \;


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



❗ usb_dump.txt still there?

Hmmm... ? take a look at the file permissions.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? I'll let you decide how to tackle the file removal...

I changed the owner to root and then ran the command again using sudo:


sudo find ~/taken_mission/documents -name "usb_dump.txt" -exec rm {} \;
? Mission 2: `head` & `tail` - Catch the Beginning or End of a File

? head


head -n 5 ~/taken_mission/documents/suspicious_log.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



OptionDescription
-n NShow the first N lines
-c NShow the first N bytes
-qSuppress headers for multiple files
? tail


tail -n 5 ~/taken_mission/documents/suspicious_log.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



OptionDescription
-n NShow the last N lines
-fFollow the file in real-time
-c NShow the last N bytes
? Mission 3: `wc` - Word Count for the Digital Detective


wc ~/taken_mission/ransom_note.txt
OptionDescription
-lLine count
-wWord count
-cByte count
-mCharacter count

wc -lwm ~/taken_mission/ransom_note.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Final Mission: All Commands, One Operation


find ~/taken_mission/documents -type f -name "*.log" -size +100M > ~/taken_mission/suspect_logs.txt

while read file; do
echo "==> $file <=="
tail -n 10 "$file"
wc -l "$file"
done < ~/taken_mission/suspect_logs.txt


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? I was curious why the verbose_log.log file wasn’t being picked up...

? Then it hit me — 2000000 bytes is only 2 MB, not 200 MB!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? Final Words


These Linux commands aren’t just useful for action movie heroes, they’re your go-to tools for file ops, log inspection, and automation. Whether you're tracking a villain or just managing your system, remember:

“Good luck...” — with your Linux journey!

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу