Write Your Own Bash Scripts for Automation [Tutorial]

Поделиться
HTML-код
  • Опубликовано: 7 июн 2024
  • Get Our Premium Ethical Hacking Bundle (90% Off): nulb.app/cwlshop
    Make Custom Bash Scripts to Automate Linux Tasks
    Full Tutorial: nulb.app/x6vu9
    Subscribe to Null Byte: goo.gl/J6wEnH
    Kody's Twitter: / kodykinzie
    Cyber Weapons Lab, Episode 209
    Bash is a simple scripting language that's useful for chaining together various Linux tools without requiring you to learn any programming. In this episode of Cyber Weapons Lab, we'll use aliasing to call programs and then use Bash to automate tasks.
    To learn more, check out the full article on Null Byte: nulb.app/x6vu9
    Automate remote SSH with Expect scripts: • Automate Remote SSH Co...
    Automate recon with Bash scripts: • Automate Recon with Yo...
    Follow Null Byte on:
    Twitter: / nullbyte
    Flipboard: flip.it/3.Gf_0
    Website: null-byte.com
    Vimeo: vimeo.com/channels/nullbyte
  • ХоббиХобби

Комментарии • 454

  • @zephyrus7258
    @zephyrus7258 3 года назад +842

    This is my kind of guy. His eyes tell me he's wasted no more than 3 hours sleeping since birth.

    • @djvincon
      @djvincon 3 года назад +28

      Pissed my pants lol

    • @rikkertkuklinski4410
      @rikkertkuklinski4410 3 года назад +14

      he's an EXPERT at what he does, and i like it.

    • @rikkertkuklinski4410
      @rikkertkuklinski4410 3 года назад +2

      @Badger anti R? Which programming language is that?

    • @aminechei8509
      @aminechei8509 3 года назад +1

      @@rikkertkuklinski4410 R is the language

    • @rikkertkuklinski4410
      @rikkertkuklinski4410 3 года назад +8

      @@aminechei8509 just be carefull. Dont piss the guy off. He might hack you while you're taking a dump and staring into your phone ...

  • @nickopop77
    @nickopop77 Год назад +23

    I’ve watched a lot of technical training videos with 20 years in the industry.
    You do a great job explaining things included with real live demos! Thank you for sharing what you do! Helping others learn too. 🙌🏼

  • @jasonpitts8395
    @jasonpitts8395 3 года назад +142

    Dude where have you been? I was about to call 911 and report you as missing. Glad you are back.

    • @KangJangkrik
      @KangJangkrik 3 года назад +1

      Oh wow false alarm for 911
      Good luck at trials bro

    • @kingseekerbackup3085
      @kingseekerbackup3085 2 года назад +2

      @@KangJangkrik It was a joke.

    • @KangJangkrik
      @KangJangkrik 2 года назад

      @@kingseekerbackup3085 I know

    • @sprBEAST211
      @sprBEAST211 2 года назад +1

      The grim reaper pulled him into a dimension between space and time, to see who would blink first in exchange for his soul. Cody clearly won 👏👏👏

    • @bitonic589
      @bitonic589 2 года назад

      @@sprBEAST211 lmao

  • @user-hy2ry3if8h
    @user-hy2ry3if8h 2 года назад +5

    Great video. Exactly what a bash nab (me) needs to start up, see how to make a basic one then build on it, then add more and more and bit of polish ... brilliant.

  • @kevin_delaney
    @kevin_delaney 8 месяцев назад +4

    I shortened that alias and implemented it into all my servers immediately (in my home) because it is simple and brilliant. I know them anyway because they are static, but I love the simplicity of it.

  • @garcand
    @garcand 3 года назад +6

    Just what I needed. I was literally just thinking about this! Thumbs up

    • @whitedaniel53
      @whitedaniel53 3 года назад

      Same bro, thought the algorithms recent update was to read my mind xD

  • @AmbushEveryone
    @AmbushEveryone 2 года назад +3

    just getting started with Linux Mint on a VM. This video just taught me so much. thank you :)

  • @Neodeejay0500
    @Neodeejay0500 3 года назад +2

    thanks from France!! I can't wait for the next video about bash scripting ! :)

  • @druzod1496
    @druzod1496 3 года назад +21

    I love your videos, can't thank you enough for what you do out here, and thanks for taking the time to "give us" this knowledge. Keep. Up the good work!

  • @RicondaRacing
    @RicondaRacing 3 года назад +4

    Studying for my Linux+, this is gold

  • @sebastiansimon7557
    @sebastiansimon7557 2 года назад +131

    You didn’t need the `echo $(`…`)` at the end, you just needed to escape the `$` so it doesn’t get expanded in the string: `alias ipaddress="ifconfig | grep broadcast | awk '{print \$2}'"`.

    • @RajivBandaru
      @RajivBandaru Год назад +3

      Thanks for this tip. It is more short and useful.

    • @DavidConnerCodeaholic
      @DavidConnerCodeaholic 25 дней назад

      Phew I’m glad I’m not the only one that caught this. 😅😅

    • @DavidConnerCodeaholic
      @DavidConnerCodeaholic 25 дней назад +1

      Fortunately for the civilized jq users among us, there is now “ip -json addr show | jq …”
      No more ifconfig (I guess? Honestly I never got the ip tools memo, so this has been very confusing for me)

  • @Alex-uc3ye
    @Alex-uc3ye 3 года назад +35

    Writing bash scripts has saved me thousands of hours over the years. Thank you for the video, this is incredibly useful.

    • @charlesmagno28
      @charlesmagno28 Год назад +4

      any real world sample you can share? thanks

    • @bald_agent_smith
      @bald_agent_smith 2 месяца назад

      @@charlesmagno28I got the same situation. For example - it really helps handle server apps, particularly deploy updates (or configs, patches), do system tasks

  • @ramgopalvarma5949
    @ramgopalvarma5949 3 года назад +1

    Thank you for showing the error you ran into and the work arounds in the video.

  • @danlule1
    @danlule1 9 месяцев назад

    Thanks a lot, this is very well explained. It is the best explanation I have come across unlike many scripting/programming videos where the narrator often spends a lot of time even hours talking to themselves in vain because they are so badly explained.

  • @AstroDenny
    @AstroDenny 3 года назад +7

    Cool video- There is a lot of content like this on youtube but your style makes this easy to ingest for beginners. Couple if things though- You don't have to have .sh at the end of it and it you're going to run it with `bash ` you don't need the shebang either. Also, why did you have to fuzz the ifconfig command?
    I hope you continue this series- bash offers some much more advanced capabilities.

  • @rodrigito78
    @rodrigito78 3 года назад +6

    Nice bash intro.
    Half the battle when writing bash is knowing which command and arguments (flags) to pass to it;
    # hostname -I
    Returns the system primary IP address. Type hostname --help for details.
    Of course, I understand the exercise was to demonstrate pipping capabilities of bash. But the less pipping the faster your script will run.
    Also, this is much better than without the curly brackets.
    # echo "${STRING}"
    Excellent job.

  • @codygaudet8071
    @codygaudet8071 3 года назад +32

    You guys are reading my mind! This is EXACTLY the video I was looking for. This video is gold. More like this.

    • @sachinmaurya3259
      @sachinmaurya3259 3 года назад +5

      this is what i was gonna type in comment .....lol

    • @jpablosaavedrag
      @jpablosaavedrag 3 года назад +4

      @@sachinmaurya3259 I was going to type this too haha

    • @jpablosaavedrag
      @jpablosaavedrag 3 года назад +1

      @@dawidsadzak8137 sad u.u but great they made this video

    • @codygaudet8071
      @codygaudet8071 3 года назад +1

      ​@@dawidsadzak8137Way to devalue for the video for others my guy. If you don't get excited about this, you're in the wrong place.

    • @jpablosaavedrag
      @jpablosaavedrag 3 года назад +2

      @@dawidsadzak8137 True. I've seen a few. But it was a nice coincidence to watch this video today. I know how the world works, still, i think it's a great short video about things you can do with bash scripting.

  • @chffguy
    @chffguy Год назад

    Been trying to execute a bash file forever! First resource that actually helped!

  • @jonyboi21
    @jonyboi21 3 года назад +136

    This guy explains it better than my professor did last week

  • @tamirmaidani
    @tamirmaidani 3 года назад +1

    Amaizing ,i did this tutorial on termux(android) , works like magic! Thanx alot!

  • @OmarImrharn
    @OmarImrharn Год назад

    I ENJOY your helpful interventions and your professional knowlege. TANK'S TOO MUCH.

  • @kuldeepsingh2983
    @kuldeepsingh2983 3 года назад +3

    I was looking exactly for this. Very nice content.

  • @AadilAnsari-ee3ds
    @AadilAnsari-ee3ds Год назад

    Amazing. Actually the advance commands was awesome

  • @oxycodin2253
    @oxycodin2253 2 года назад +1

    I taught my self this exact thing for batch scripting, time to learn bash!

  • @dogbyte7875
    @dogbyte7875 2 года назад +1

    Hey Kody, Thank you for your time and for your video

  • @elitetechnicalspecialists6170
    @elitetechnicalspecialists6170 3 года назад +1

    Great work man 😀 love your videos 👍

  • @DavidLindes
    @DavidLindes 2 года назад

    Thanks for sharing.
    A minor correction, re 2:17 - the .sh extension is not actually necessary.
    And just a note re 12:55, while some folks do call those "curly brackets", a less-confusing name for them would be "braces" -- { and } -- whereas "brackets" (or "square brackets") would be [ and ].

  • @ondregonzalez
    @ondregonzalez 3 года назад +1

    Awesome presentation! Thanks for the clarification.

  • @mojo3318
    @mojo3318 2 года назад +2

    My dad had me watch this video for a class I'm going to take. This looks interesting. I like coding.

  • @frantiseksmrha992
    @frantiseksmrha992 Год назад

    Thanks man, you helped me a lot. I appreciate your work.

  • @Anandhpt
    @Anandhpt 3 года назад

    Last task was awesome..thnx man

  • @HikikomoriDev
    @HikikomoriDev 3 года назад +1

    A lot of power to the user. Very useful.

  • @theazza
    @theazza 3 года назад

    Thanks dude, great description.

  • @ashpakpinjari9214
    @ashpakpinjari9214 3 года назад

    Please continue this bash series.

  • @tusharmotka1583
    @tusharmotka1583 3 года назад +1

    Need more parts of it. 😍

  • @jpedithe2171
    @jpedithe2171 2 года назад +1

    Hello , très interessant ce tuto de découverte . J'ai apprécié vos explications et vous dis un grand merci pour ce partage .

  • @worldboy9684
    @worldboy9684 Год назад

    Nice trick using a subprocess in an alias! Thanks

  • @moth5005
    @moth5005 3 года назад

    sick video , the alias thing is really cool.

    • @gedeonducloitre-delavarenn8106
      @gedeonducloitre-delavarenn8106 3 года назад

      From man bash: For almost every purpose, aliases are superseded by shell functions.
      So no, aliases are not cool (apart maybe for just one command, but it gets crazy when you want to put more than one command with quotes; and also they can't handle arguments). Functions are cool!

  • @zexsen85
    @zexsen85 2 года назад

    woooow, Vibrasphere - Sweet september music on the beging.... I am delighted... :)

  • @jackfletch2001
    @jackfletch2001 2 года назад +1

    Holy crap, I'm shocked I actually know almost all of this. I was genuinely nervous thinking I forgot a lot of this stuff.

  • @tomigoe376
    @tomigoe376 3 года назад

    Amazing video. Ty Nullbytes

  • @cryptonservices9749
    @cryptonservices9749 3 года назад +1

    Yay I'm early - I love your videos man ❤

  • @Clean_Slate
    @Clean_Slate 3 года назад +3

    Even though it's quite a simple quide, it's great!
    Thank you!

  • @Jose_T131
    @Jose_T131 2 года назад

    Excellent video brother

  • @seratonyn
    @seratonyn 3 года назад +2

    Nice~♡ dig the first ifconfig 🤣

  • @imagreatguy1250
    @imagreatguy1250 Год назад

    This is good stuff mate 🧠👍

  • @Ben12312312
    @Ben12312312 3 года назад +122

    “Oops this isn’t python” hahah

  • @BurningtunaDC
    @BurningtunaDC 3 года назад

    "Kody"? Jackie is the punk. Thanks for shooting and sharing such a great tutorial.

  • @chickenpotthighs9387
    @chickenpotthighs9387 3 года назад +1

    Thank you so so much for this tutorial.

  • @novikovPrinciple
    @novikovPrinciple 3 года назад +22

    Intermediate Tip: Use "man bash" to learn the semantic differences of: "&" (ampersand), "&&" (double ampersand), "|" (bar), and ";" (semi-colon).
    Most of my aliased commands use these punctuations, with one being "firefox & discord &" and another being "git fetch ; git status ;".
    GL, HF

  • @imrharnomar9099
    @imrharnomar9099 Год назад

    I enjoy your support. your work is very benefit. TANK'S.

  • @davidabba7663
    @davidabba7663 2 года назад

    well this was fun and educational thanks!

  • @Shaddymaze
    @Shaddymaze 3 года назад

    Well made! Thank you 😁

  • @charbelalam2648
    @charbelalam2648 2 года назад

    He stares the information into my soul.

  • @diegoleon1144
    @diegoleon1144 3 года назад +1

    This guy teach like a master.

  • @naeem8434
    @naeem8434 3 года назад

    AMazing video sir for beginners.

  • @anaghr1252
    @anaghr1252 Год назад

    Thank you man for sharing this stuff

  • @vikramnanda2833
    @vikramnanda2833 Год назад

    Thanks for the video
    Please do make more videos for daily task automation

  • @1ukastesar
    @1ukastesar Год назад +10

    In the case of shebang, it's better to use `/usr/bin/env bash` instead of the exact shell location so it can be ram on different machines without changing a single line.

    • @zeta_eclipse
      @zeta_eclipse 10 месяцев назад

      thank you :D

    • @zuberkariye2299
      @zuberkariye2299 8 месяцев назад +2

      thats neat and smart tip, if i was to write malware on my linux machine and wanted to transfer to a remote machine somewhere else that might be using different shell. It could in cases like that then

  • @ggsap
    @ggsap 2 года назад +3

    Actually to find out the shell you are currently using you need to execute which $SHELL since most of the time you want your current shell to interpret your script

  • @jeanelkhoury8077
    @jeanelkhoury8077 3 года назад

    great video wish we could have more of

  • @cryptolicious3738
    @cryptolicious3738 3 года назад +6

    Argumentative bash script! hilarious :D
    that cracked me up bro

  • @nevorchi
    @nevorchi 2 года назад

    Greatly appreciated sir!

  • @amnakhan1741
    @amnakhan1741 Год назад

    Cool You really help me Well done!

  • @Romanslost
    @Romanslost 3 года назад +2

    Great timing 😁

  • @mathematicalninja2756
    @mathematicalninja2756 3 года назад +1

    I swear this is what I wanted

  • @vk-chinni
    @vk-chinni 3 года назад +1

    @Null Byte what that "Codes" book behind you?

  • @The_Digital_Samurai
    @The_Digital_Samurai 3 года назад +1

    Bash scripting in the new Windows Terminal is very useful.

  • @sirprancealott2003
    @sirprancealott2003 Год назад

    Great work Mate. Keep Staring

  • @terrencegivens9032
    @terrencegivens9032 2 года назад

    Very well explained

  • @bzero7857
    @bzero7857 3 года назад

    Your videos are perfect to learn

  • @jelos6397
    @jelos6397 2 года назад

    That's very cool thanks!

  • @davegcomedy1267
    @davegcomedy1267 Год назад

    Great video, thanks for sharing

  • @albertsnow7111
    @albertsnow7111 2 года назад

    hello . 0:40 It's get my attention that black blanket on the wall. The blanket surface is like the equipment on the voice lab to eliminate external sound effect. Am I right?

  • @ianp6742
    @ianp6742 3 года назад

    Good info, thank you.

  • @nergalactic2275
    @nergalactic2275 3 года назад

    Thanks for this video!

  • @ruszomalkuko
    @ruszomalkuko 3 года назад +1

    That's sweet! You can put target IP in $IP and bash scripting enumeration easily now

  • @hackstarcool
    @hackstarcool 3 года назад

    You made my life so much easier

  • @Ms.Robot.
    @Ms.Robot. 3 года назад +1

    This term, Linux, good timing❤️💋

  • @maurolimaok
    @maurolimaok Год назад

    I've been searching for a tutorial to make my terminal look like this, old green monitor, for a long time.
    Do you have any tutorial for that?
    I'm a complete newbie here in Brazil, learning Linux and Terminal prior to learn coding itself.
    Thanks for the video.

  • @FrankieTheOne
    @FrankieTheOne Год назад

    didnt know th alias command. Thanks

  • @ben9262
    @ben9262 7 месяцев назад

    do we have to edit with nano or is it cool to create the .sh files with vim?

  • @pianochannel100
    @pianochannel100 3 года назад +3

    The no-blink guy is back!

  • @GeneralBlorp
    @GeneralBlorp 3 года назад +5

    Bash was my entry point into coding!
    I just wanted to save time on repetitive tasks and chill more while at work; upside was that I learned I could annoy my supervisor by being such a TryHard.

    • @pianochannel100
      @pianochannel100 3 года назад +3

      See but now they'll just give you more work if you prove yourself to be so efficient.

    • @justinc4782
      @justinc4782 3 года назад +2

      @@pianochannel100 yes if you ever make these kind of tweaks keep it to yourself and dont brag about it! :)

    • @derpoblizist9076
      @derpoblizist9076 Год назад

      @@justinc4782 it depends where you want to go, to have a cushiony job with few working hours, then just quietly do your part.
      If you want to be more successful and have a job that recognizes this effort, then ask for more work.

    • @wasssuuuppp
      @wasssuuuppp Год назад

      Any book recommendations to learn it more advanced?

  • @lollubrick
    @lollubrick 3 года назад +1

    I was going to comment to bash you for using nano but then I realized that I started doing anything on the *nix command line using nano instead of vi so I can't really say stuff; but vi is the best thing to learn.

  • @marvinmckay4356
    @marvinmckay4356 2 года назад

    Wow!!! Thank you!

  • @smithwill9952
    @smithwill9952 Год назад

    Industrious intelligent geek. Awesome!

  • @D3M0320
    @D3M0320 3 года назад

    Would you do a similar video but with powershell?

  • @YannMetalhead
    @YannMetalhead 2 месяца назад

    Good video!

  • @ritvikdayal3735
    @ritvikdayal3735 3 года назад

    A person talking to his code is a brother. 😍😍😍

  • @krotizmultika
    @krotizmultika 3 года назад +3

    "belive"... Great video, as always, though.

  • @alliedeena1141
    @alliedeena1141 3 года назад +1

    Really cool! Thank you so much, Please make more cool videos like this...

  • @skverskk
    @skverskk 2 года назад

    Very informative

  • @nickt423
    @nickt423 2 года назад

    Can you have windows scheduler run a shell file as an admin? If so, how would you do that?

  • @ovokteb9671
    @ovokteb9671 Месяц назад

    Really helpful video . Do you have any course on Udemy that I can purchase ?

  • @edsonp.e6811
    @edsonp.e6811 3 года назад

    Tks, Man!! pt-br!!

  • @EdwardVarner
    @EdwardVarner 2 года назад

    Why would I put a command (like whoami) into echo to get it to appear when I can just put whoami on a line in the script and it does the same thing?

  • @surajmishra5661
    @surajmishra5661 3 года назад +1

    Can you make a script for making post on social media as planed per user and on given time

  • @temudjin1155
    @temudjin1155 3 года назад +1

    Hi and thank you. You should make a complete serie on that

  • @pcampbell-edu8508
    @pcampbell-edu8508 3 года назад +26

    Good habits put in a "header" with the date, your name and purpose of the script.
    Also keep upper case vars for env vars.
    ^^^ being kind to your future self