LINUX COMMAND LINE CHAINING⛓️:
In this thread I will you how to use the Linux command line in a more productive, professional and creative way.
🧵A thread ↓
#Linux #infosec #CyberSecurity #Security
In this thread I will you how to use the Linux command line in a more productive, professional and creative way.
🧵A thread ↓
#Linux #infosec #CyberSecurity #Security
WHAT IS COMMAND LINE CHAINING?
First things first, let's define what Linux command line chaining is?
First things first, let's define what Linux command line chaining is?
Linux command chaining is a technique of merging (or joining) several commands such that each of them can execute in sequence depending on the operator that separates them and these operators decide how the commands will get executed.
It allows us to run multiple commands in succession (one after the other) or simultaneously (at the same time). It’s like short one line shell scripts that can be executed through the terminal directly.
They're several operators or simples we use in chaining commands, here is a list of them:
&, &&, ||, |, ; {}, (), \, >>, >, and !. Now you know what command line chaining is? Let's dive into some practical examples.
&, &&, ||, |, ; {}, (), \, >>, >, and !. Now you know what command line chaining is? Let's dive into some practical examples.
The first command `echo "command line chaining is awesome" > xtremepentest.txt` creates a file with the name `xtremepentest.txt` (The redirection operator `> `allows us to give the output of the `echo` command as an input to `xtremepentest.txt` file, if the file doesn't exists
it will be created else if it does all the contents of the file will be replaced with text `command line chaining is awesome`.) while the second `wc -c -l < xtremepentest.txt` command will print the character count and line count in xtremepentest.txt.
In the first case, if the first command is successful then the second will get executed but the third command will not execute. But in the second case, the third command will get executed as the precedence is set using the `()` operator.
In the first case, hello will always get printed. If the file exists then the command will get executed as it is preceding the && operator. If we want to execute both second and third commands only if the file exists, then we use {} operators to combine the commands.
Congrats🥳🥂 you made it to the end. That's it for today's thread! Thanks for reading🥂 If you enjoyed this thread , RT the first tweet and follow me @xtremepentest for more future Linux, Networking and Cybersecurity content.
Loading suggestions...