Write Your Own Bash Scripts for Automation [Tutorial]

Тәжірибелік нұсқаулар және стиль

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
    @zephyrus72583 жыл бұрын

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

  • @djvincon

    @djvincon

    3 жыл бұрын

    Pissed my pants lol

  • @rikkertkuklinski4410

    @rikkertkuklinski4410

    3 жыл бұрын

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

  • @rikkertkuklinski4410

    @rikkertkuklinski4410

    3 жыл бұрын

    @Badger anti R? Which programming language is that?

  • @aminechei8509

    @aminechei8509

    3 жыл бұрын

    @@rikkertkuklinski4410 R is the language

  • @rikkertkuklinski4410

    @rikkertkuklinski4410

    3 жыл бұрын

    @@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 Жыл бұрын

    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
    @jasonpitts83953 жыл бұрын

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

  • @KangJangkrik

    @KangJangkrik

    3 жыл бұрын

    Oh wow false alarm for 911 Good luck at trials bro

  • @kingseekerbackup3085

    @kingseekerbackup3085

    2 жыл бұрын

    @@KangJangkrik It was a joke.

  • @KangJangkrik

    @KangJangkrik

    2 жыл бұрын

    @@kingseekerbackup3085 I know

  • @sprBEAST211

    @sprBEAST211

    2 жыл бұрын

    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

  • @sebastiansimon7557
    @sebastiansimon75572 жыл бұрын

    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

    Жыл бұрын

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

  • @DavidConnerCodeaholic

    @DavidConnerCodeaholic

    Ай бұрын

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

  • @DavidConnerCodeaholic

    @DavidConnerCodeaholic

    Ай бұрын

    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)

  • @user-hy2ry3if8h
    @user-hy2ry3if8h2 жыл бұрын

    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_delaney8 ай бұрын

    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.

  • @AmbushEveryone
    @AmbushEveryone2 жыл бұрын

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

  • @garcand
    @garcand3 жыл бұрын

    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

  • @druzod1496
    @druzod14963 жыл бұрын

    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!

  • @Neodeejay0500
    @Neodeejay05003 жыл бұрын

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

  • @ramgopalvarma5949
    @ramgopalvarma59493 жыл бұрын

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

  • @jonyboi21
    @jonyboi213 жыл бұрын

    This guy explains it better than my professor did last week

  • @cyberrock9018

    @cyberrock9018

    3 жыл бұрын

    Are you taking computer science? Or IT

  • @bachokiro2866

    @bachokiro2866

    3 жыл бұрын

    Lmaoo thx I will never go to university

  • @arghosinha1424

    @arghosinha1424

    3 жыл бұрын

    I feel thee!!

  • @Rahul-lg1nw

    @Rahul-lg1nw

    3 жыл бұрын

    Mine tooooo😅

  • @hutchson7410

    @hutchson7410

    3 жыл бұрын

    @@cyberrock9018 which are you in?

  • @chffguy
    @chffguy Жыл бұрын

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

  • @rodrigito78
    @rodrigito783 жыл бұрын

    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.

  • @danlule1
    @danlule110 ай бұрын

    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.

  • @tamirmaidani
    @tamirmaidani3 жыл бұрын

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

  • @AstroDenny
    @AstroDenny3 жыл бұрын

    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.

  • @RicondaRacing
    @RicondaRacing3 жыл бұрын

    Studying for my Linux+, this is gold

  • @OmarImrharn
    @OmarImrharn Жыл бұрын

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

  • @Alex-uc3ye
    @Alex-uc3ye3 жыл бұрын

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

  • @charlesmagno28

    @charlesmagno28

    Жыл бұрын

    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

  • @oxycodin2253
    @oxycodin22532 жыл бұрын

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

  • @AadilAnsari-ee3ds
    @AadilAnsari-ee3ds Жыл бұрын

    Amazing. Actually the advance commands was awesome

  • @kuldeepsingh2983
    @kuldeepsingh29833 жыл бұрын

    I was looking exactly for this. Very nice content.

  • @ondregonzalez
    @ondregonzalez3 жыл бұрын

    Awesome presentation! Thanks for the clarification.

  • @codygaudet8071
    @codygaudet80713 жыл бұрын

    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 жыл бұрын

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

  • @jpablosaavedrag

    @jpablosaavedrag

    3 жыл бұрын

    @@sachinmaurya3259 I was going to type this too haha

  • @jpablosaavedrag

    @jpablosaavedrag

    3 жыл бұрын

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

  • @codygaudet8071

    @codygaudet8071

    3 жыл бұрын

    ​@@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 жыл бұрын

    @@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.

  • @frantiseksmrha992
    @frantiseksmrha992 Жыл бұрын

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

  • @DavidLindes
    @DavidLindes2 жыл бұрын

    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 ].

  • @dogbyte7875
    @dogbyte78752 жыл бұрын

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

  • @HikikomoriDev
    @HikikomoriDev3 жыл бұрын

    A lot of power to the user. Very useful.

  • @jpedithe2171
    @jpedithe21712 жыл бұрын

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

  • @novikovPrinciple
    @novikovPrinciple3 жыл бұрын

    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

  • @Anandhpt
    @Anandhpt3 жыл бұрын

    Last task was awesome..thnx man

  • @elitetechnicalspecialists6170
    @elitetechnicalspecialists61703 жыл бұрын

    Great work man 😀 love your videos 👍

  • @mojo3318
    @mojo33182 жыл бұрын

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

  • @Clean_Slate
    @Clean_Slate3 жыл бұрын

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

  • @worldboy9684
    @worldboy9684 Жыл бұрын

    Nice trick using a subprocess in an alias! Thanks

  • @theazza
    @theazza3 жыл бұрын

    Thanks dude, great description.

  • @tusharmotka1583
    @tusharmotka15833 жыл бұрын

    Need more parts of it. 😍

  • @zexsen85
    @zexsen852 жыл бұрын

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

  • @moth5005
    @moth50053 жыл бұрын

    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!

  • @seratonyn
    @seratonyn3 жыл бұрын

    Nice~♡ dig the first ifconfig 🤣

  • @ashpakpinjari9214
    @ashpakpinjari92143 жыл бұрын

    Please continue this bash series.

  • @jackfletch2001
    @jackfletch20012 жыл бұрын

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

  • @1ukastesar
    @1ukastesar Жыл бұрын

    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 ай бұрын

    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

  • @chickenpotthighs9387
    @chickenpotthighs93873 жыл бұрын

    Thank you so so much for this tutorial.

  • @tomigoe376
    @tomigoe3763 жыл бұрын

    Amazing video. Ty Nullbytes

  • @BurningtunaDC
    @BurningtunaDC3 жыл бұрын

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

  • @Ben12312312
    @Ben123123123 жыл бұрын

    “Oops this isn’t python” hahah

  • @imrharnomar9099
    @imrharnomar9099 Жыл бұрын

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

  • @vikramnanda2833
    @vikramnanda2833 Жыл бұрын

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

  • @jeanelkhoury8077
    @jeanelkhoury80773 жыл бұрын

    great video wish we could have more of

  • @davidabba7663
    @davidabba76632 жыл бұрын

    well this was fun and educational thanks!

  • @ggsap
    @ggsap2 жыл бұрын

    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

  • @diegoleon1144
    @diegoleon11443 жыл бұрын

    This guy teach like a master.

  • @Jose_T131
    @Jose_T1312 жыл бұрын

    Excellent video brother

  • @naeem8434
    @naeem84343 жыл бұрын

    AMazing video sir for beginners.

  • @cryptonservices9749
    @cryptonservices97493 жыл бұрын

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

  • @pcampbell-edu8508
    @pcampbell-edu85083 жыл бұрын

    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

  • @vk-chinni
    @vk-chinni3 жыл бұрын

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

  • @imagreatguy1250
    @imagreatguy1250 Жыл бұрын

    This is good stuff mate 🧠👍

  • @Shaddymaze
    @Shaddymaze3 жыл бұрын

    Well made! Thank you 😁

  • @charbelalam2648
    @charbelalam26482 жыл бұрын

    He stares the information into my soul.

  • @anaghr1252
    @anaghr1252 Жыл бұрын

    Thank you man for sharing this stuff

  • @mathematicalninja2756
    @mathematicalninja27563 жыл бұрын

    I swear this is what I wanted

  • @cryptolicious3738
    @cryptolicious37383 жыл бұрын

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

  • @lollubrick
    @lollubrick3 жыл бұрын

    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.

  • @GeneralBlorp
    @GeneralBlorp3 жыл бұрын

    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 жыл бұрын

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

  • @justinc4782

    @justinc4782

    3 жыл бұрын

    @@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?

  • @nevorchi
    @nevorchi2 жыл бұрын

    Greatly appreciated sir!

  • @Ms.Robot.
    @Ms.Robot.3 жыл бұрын

    This term, Linux, good timing❤️💋

  • @Romanslost
    @Romanslost3 жыл бұрын

    Great timing 😁

  • @ruszomalkuko
    @ruszomalkuko3 жыл бұрын

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

  • @The_Digital_Samurai
    @The_Digital_Samurai3 жыл бұрын

    Bash scripting in the new Windows Terminal is very useful.

  • @amnakhan1741
    @amnakhan1741 Жыл бұрын

    Cool You really help me Well done!

  • @bzero7857
    @bzero78573 жыл бұрын

    Your videos are perfect to learn

  • @ben9262
    @ben92627 ай бұрын

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

  • @terrencegivens9032
    @terrencegivens90322 жыл бұрын

    Very well explained

  • @albertsnow7111
    @albertsnow71112 жыл бұрын

    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?

  • @ovokteb9671
    @ovokteb96712 ай бұрын

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

  • @hackstarcool
    @hackstarcool3 жыл бұрын

    You made my life so much easier

  • @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.

  • @davegcomedy1267
    @davegcomedy1267 Жыл бұрын

    Great video, thanks for sharing

  • @ianp6742
    @ianp67423 жыл бұрын

    Good info, thank you.

  • @jelos6397
    @jelos63972 жыл бұрын

    That's very cool thanks!

  • @nergalactic2275
    @nergalactic22753 жыл бұрын

    Thanks for this video!

  • @alliedeena1141
    @alliedeena11413 жыл бұрын

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

  • @FrankieTheOne
    @FrankieTheOne Жыл бұрын

    didnt know th alias command. Thanks

  • @jeremymesloh1981
    @jeremymesloh19813 жыл бұрын

    You could also do ifconfig | awk '/broadcast/ {print $2}' which would let awk grep and parse column.

  • @analactica

    @analactica

    3 жыл бұрын

    Yeah that's definitely WAAAAY ahead my level atm , i didn't understand a thing , hopefully within a year I would 🤣🤦🏻‍♂️

  • @rodrigito78

    @rodrigito78

    3 жыл бұрын

    # hostname -I (uppercase i)

  • @analactica

    @analactica

    3 жыл бұрын

    @Learn Linux im starting to get the idea actually , my issue is the way i learn , unlike most people i need the bigger picture first , then the break down , not the other way around , sooo ya lol

  • @EdwardVarner
    @EdwardVarner2 жыл бұрын

    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?

  • @TraceursMonkey
    @TraceursMonkey3 жыл бұрын

    Do all the scripts you make using "alias" are stored in bin/bash ? Thank you very much for the video , it fit like a puzzle piece for me .

  • @jonathanverret6872

    @jonathanverret6872

    3 жыл бұрын

    If you use the alias command in a live terminal, the alias is stored for that session only. Once you exit the terminal, the alias is lost. To save and store your own aliases, you need to edit your bashrc file, which is a configuration file that stores the settings for your shell. There are two copies of this file, one in /etc/bashrc that holds system-wide configuration (any user on the system will inherit these configurations), and one in /home/$USER/.bashrc that affects your user profile only. In most cases, you will want to edit the version of the file in /home/$USER/bashrc. Open the file with nano or vim and add your alias command to the file. You could add your command pretty much anywhere, but it's probably easiest to just add it to the end of the file. Once you save the file, the alias command you added will execute every time you open a shell. You can also edit the .bashrc file to change environment variables such as your $PATH.

  • @TraceursMonkey

    @TraceursMonkey

    3 жыл бұрын

    @@jonathanverret6872 Thank you very much for taking your time to explain :D Haw an awsome weekend !

  • @nickt423
    @nickt4232 жыл бұрын

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

  • @jpdominator
    @jpdominator3 жыл бұрын

    I wouldn’t recommend using aliases like that. Make them little scripts. Aliases are part of bash expansion. Using grep with your alias… womp womp. Gotta single tick it. Aliases for obscure references. Scripts for other stuff, not piped commands.

  • @temudjin1155
    @temudjin11553 жыл бұрын

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

  • @lxtwin
    @lxtwin Жыл бұрын

    To make a script portable say RHEL 6, 7, 8 and 9 you can use #!/usr/bin/env bash instead of #!/bin/bash

  • @surajmishra5661
    @surajmishra56613 жыл бұрын

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

  • @pianochannel100
    @pianochannel1003 жыл бұрын

    The no-blink guy is back!

  • @jaeger809

    @jaeger809

    3 жыл бұрын

    Lol

  • @marvinmckay4356
    @marvinmckay43562 жыл бұрын

    Wow!!! Thank you!

  • @krotizmultika
    @krotizmultika3 жыл бұрын

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

  • @ritvikdayal3735
    @ritvikdayal37353 жыл бұрын

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

  • @smithwill9952
    @smithwill9952 Жыл бұрын

    Industrious intelligent geek. Awesome!

  • @pavithraprajwal3838
    @pavithraprajwal38382 жыл бұрын

    Sir i want a program or software that when i enter 'enter' button on keyboard that automatically enter tab 2 times & enter 2 in monitor can u plz help mee

Келесі