Filtering .log files, with cat, grep, cut, sort, and uniq

Filtering .log files, with cat, grep, cut, sort, and uniq

Hackpens

4 года назад

89,748 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@vadivelan4228
@vadivelan4228 - 01.10.2022 06:00

I was searching for all command combinations in reading logs to extract an info. this video is great.

Ответить
@ben-cb5er
@ben-cb5er - 02.10.2022 05:25

Awesome video! Please don’t stop making Linux, bash, ethical hacking related videos. Thank you. Subscribed!! 😊

Ответить
@TECHLEAKSforINDIA
@TECHLEAKSforINDIA - 07.10.2022 10:56

One word.……….…………$Π¶€®

Ответить
@hameedazeem
@hameedazeem - 17.10.2022 04:15

thank you so much for this tutorial it helped me a lot with understanding of cat, grep and sort.
Are you able to tell me what this command would do "cat -rf ~/syslog | sort | grep -iaE -A 5 'cpu[1-7].*(7[0-9]|8[0-9]|100)' | tee cpu.txt" specifically the numbers after cpu which seem to me like it's a time stamp

Ответить
@muzamilabbasi
@muzamilabbasi - 29.11.2022 00:50

thank you this is very helpful

Ответить
@brahimayoada2657
@brahimayoada2657 - 03.12.2022 10:49

16 th field from experience still blow away

Ответить
@Arbnor93
@Arbnor93 - 14.12.2022 03:07

You sir are incredible at teaching

Ответить
@dune4095
@dune4095 - 15.12.2022 09:11

Awesome tutorial on cat and grep, Thanks...

Ответить
@sirprancealott2003
@sirprancealott2003 - 20.12.2022 15:59

Great info and an enjoyable watch 👍👏

Ответить
@varunt6846
@varunt6846 - 13.01.2023 23:32

Hi Sir, I have a log file which I cannot see after the command cd /var/log Please give me some suggestions thank you

Ответить
@pjj7466
@pjj7466 - 26.01.2023 06:20

Gold sir 🔥

Ответить
@kasthurishravankumarhpc
@kasthurishravankumarhpc - 12.02.2023 13:09

Good

Ответить
@yash1152
@yash1152 - 10.03.2023 21:30

From description: > "I show you how to filter information from a .log file, and you find out just how important strong passwords really are."

i always wondered that pattern matching has smth to do with password security, but then i thought, you have to have passwords to apply pattern matching on 'em right? 'cz the password input field of a site doesn't accept regex, and generating exhaustive strings from regex doesn't help either...

so, what are scenario we are imagining for talking about regex in context of secure passwords?

Ответить
@richardazu7445
@richardazu7445 - 19.03.2023 02:33

Simple and straightforward ❤

Ответить
@geetabasker7127
@geetabasker7127 - 20.03.2023 00:42

Concept explained well in a short video.

Ответить
@ansellroman6620
@ansellroman6620 - 02.04.2023 19:29

from the ip addres can you find out their location ?

Ответить
@fredflintstone505
@fredflintstone505 - 25.05.2023 16:56

Thanks! That was informative. The only thing I would have done differently is flip the order of uniq -d and sort. Less items to sort after uniq filters them out.

Ответить
@msnraju97
@msnraju97 - 12.06.2023 13:41

I am checking this video 3year after upload. The video tutorial is on point and clear.

Ответить
@yosefberger6259
@yosefberger6259 - 20.06.2023 08:04

Great introduction to the topic, a few things that i think are worth mentioning, once people have learned the commands that were being demonstrated:
If the logs your using have a variable amount of spaces between columns (to make things look nice), that can mess up using cut, to get around that you can use `sed 's/ */ /g` to replace any n spaces in a row with a single space. You can also use awk to replace the sed/cut combo, but that's a whole different topic.

uniq also has the extremely useful -c flag which will add a count of how many instances of each item there were.

And as an aside if people wanted to cut down on the number of commands used you can do things like `grep expression filepath` or `sort -u` (on a new enough system), but in the context of this video it is probably better that people learn about the existence of the stand alone utilities, which can be more versatile.

Once you're confident in using the tools mentioned in the video, but you still find that you need more granularity than the grep/grep -v combo, you can use globbing, which involves special characters that represent concepts like "the start of a line"(^) or the wildcard "any thing"(*) (for example `grep "^Hello*World"` means any line that starts with Hello, and at some point also contains World, with anything or nothing in-between/after). If that still isn't enough you might want to look into using regular expressions with grep, but they can be even harder to wrap your mind around if you've never used them before. (If you don't understand globbing or re really are just from reading this that's fine, I'm just trying to give you the right terms to Google, because once you know something's name it becomes infinitely easier to find resources on them)

Ответить
@paaao
@paaao - 13.07.2023 04:25

Now dump all the unique IPs into a text file, and run nslookup on each one. $50 says they all are located in China or Russia. At least %98-99 of them. At least that's what I always end up finding.

Ответить
@EdHatesNoobTubers
@EdHatesNoobTubers - 01.09.2023 07:49

😊 great videos 👍 thank you!!!

Ответить
@erbenton07
@erbenton07 - 02.09.2023 16:42

you don't need cat, just use grep "string" auth.log also, you instead of cut, just use awk '{print $11}'

Ответить
@genghismike6186
@genghismike6186 - 07.10.2023 18:39

Thanks.. very helpful and will be using this as a reference from now on

Ответить
@beyremrjeybi9978
@beyremrjeybi9978 - 22.11.2023 17:06

nice , except cut -d " " -f x not working for me , i will dig durther to figure out why..

Ответить
@gustavotobias7681
@gustavotobias7681 - 24.11.2023 21:59

Muy buen video, gracias por compartir, saludos desde México

Ответить
@MAX-nv6yj
@MAX-nv6yj - 17.12.2023 14:44

thanks for the amazing video
love it <3

Ответить
@messileo919
@messileo919 - 10.01.2024 09:25

Thankyou this video was exactly what i needed

Ответить
@cainanashton
@cainanashton - 01.02.2024 22:48

Good vid, thank you

Ответить
@ВиталийОвчаренко-т7й
@ВиталийОвчаренко-т7й - 18.02.2024 17:51

To filter .log files using cat, grep, cut, sort, and uniq commands, follow these steps:

1. First, open your terminal or command prompt.

2. Navigate to the directory containing the .log files you want to filter. You can use the 'cd' command followed by the directory path. For example:

```bash
cd /path/to/your/log/files
```

3. Use the 'cat' command to concatenate and display the contents of a .log file. For instance:

```bash
cat your_log_file.log
```

4. To search for specific lines in the .log file, use the 'grep' command. For example, if you want to find all lines containing the word 'error', you can use:

```bash
grep 'error' your_log_file.log
```

5. If you want to extract specific columns from the output, use the 'cut' command. The format is 'cut -d delimiter -f fields'. For example, if your log file has columns separated by a space and you want to extract the first column, use:

```bash
cut -d ' ' -f1
```

6. To sort the lines alphabetically or numerically, use the 'sort' command. For example:

```bash
sort your_log_file.log
```

7. Finally, to remove duplicate lines from the sorted output, use the 'uniq' command. For example:

```bash
uniq your_log_file.log
```

By combining these commands, you can create a pipeline to filter .log files effectively. For instance:

```bash
cat your_log_file.log | grep 'error' | cut -d ' ' -f1 | sort | uniq
```

This command will display unique first columns from lines containing the word 'error' in your_log_file.log.

Ответить
@PEDERSTEENBERG-d5h
@PEDERSTEENBERG-d5h - 22.03.2024 00:45

hOW CAN I SEE ALL FILES ON HARD DRIVE OR USB ? AND HOW COULD DECRYPTED FILES BE ERASED OR OVERWRITE WITH SUDO SHRED ?

Ответить
@heli0s359
@heli0s359 - 18.04.2024 19:55

genius

Ответить
@makopafruit
@makopafruit - 14.05.2024 05:05

Thank you!

Ответить
@TrendyTales-ep9yq
@TrendyTales-ep9yq - 05.06.2024 19:26

sir can we use awk instead of cut?

Ответить
@AbdoTawdy
@AbdoTawdy - 30.06.2024 15:35

For compressed files, zcat zgrep

Ответить
@dodokwak
@dodokwak - 14.07.2024 00:26

Thx. Very helpful.

Ответить
@dodokwak
@dodokwak - 14.07.2024 00:27

You could configure fail2ban not only for sshd but also for nginx requests to catch 400-404 errors.

Ответить
@potatochannel1948
@potatochannel1948 - 21.08.2024 10:01

this one is one of the most helpful tutorials out there that show how powerful grep and pipe are. Thanks for sharing that and I hope you make more cool stuff.

Ответить
@guths
@guths - 23.08.2024 04:38

awesome video

Ответить
@mahendra.l861
@mahendra.l861 - 18.09.2024 12:21

Without changing directory how can we do

Ответить
@Monana666
@Monana666 - 20.09.2024 10:11

this is exactly what I was looking for and even more! thank you so much!

Ответить
@quarylaniel
@quarylaniel - 30.09.2024 03:03

REALLY HELPED THANK YOU SO MUCH

Ответить
@derekberthiaume5367
@derekberthiaume5367 - 17.10.2024 03:32

If I wanted to count the number of times that each unique instance showed up. What would I do for that? Would I do the unique and then do the word count for each instance by using grep for that specific phrase?

Ответить
@firozshaikh3739
@firozshaikh3739 - 20.10.2024 08:26

hi do you know how to copy log file from cowrie honeypot is on?

Ответить
@skrunkly688
@skrunkly688 - 29.10.2024 06:07

I’m on windows and I’m currently tasked with finding stuff for a log file they gave me

Ответить
@albinbabu4846
@albinbabu4846 - 01.01.2025 10:13

Thanks for this one. Helped a lot

Ответить
@tonyferns
@tonyferns - 09.01.2025 19:18

One of the best video walkthroughs of all time.

Ответить
@lerentia8123
@lerentia8123 - 19.01.2025 13:53

Thank you for making learning for my university studies much easier!

Ответить
@m.laraibali3266
@m.laraibali3266 - 29.01.2025 21:00

You try to access his server you will have your public ip posted on internet

Ответить