⚡Power of LINUX⚡
Even though you might haven’t used Linux till now, I am pretty sure that you might have heard this phrase “Linux is so powerful” or a related one.
Have you ever wondered that what makes Linux so powerful?
Well, Linux is powerful in terms of the control that it provides in the hands of the user using it. Now, Control over what? Control over the hardware on which you are using Linux. Before going into the depth of the features that Linux provides, first lets understand what Linux actually is.
Linux is not an Operating system. Surprised? Yes its right.
Linux is the Kernel of the GNU OS. The kernel is core component of the Operating System that acts as a bridge between applications and the hardware. Now the question arises, What is the need of Kernel? Why can’t we let the applications directly communicate with the hardware.
Well you might have heard of this famous dialogue- “With great power comes great responsibility” and since the hardware is unimaginably powerful it would not be wise to let the the applications directly communicate with it.
So Linux is not an Operating System. It is the kernel of the GNU Operating system which is an open source Operating System. It makes me really happy whenever I see anyone using the term “GNU/Linux” instead of just “Linux” because the GNU open source community deserves as much credit as Linux , for the amazing job(providing free OS to the world)that they did.
So that’s just an overview of What Linux is. To have an in depth understanding of Linux & GNU OS ,
visit the official websites: LINUX , GNU
Enough of talking. Now let’s have a look at some of the powerful features that Linux provides to its users
- Brace Expansion : It is a really powerful feature of Linux. Let us understand its power with the help of an
Example : Suppose you wanted to create a folder that has 100 folders(folder 1, folder 2….folder 100) and each of those 100 folders have 100 files in them. How are you going to do it?.
Well, doing it using in Graphical way seems horrific right?
Worry not, your friend- The Terminal is there to help you.
Solution :
Move inside the folder where you want to create that 100 folders
(using cd <folder-name>). Now once you are inside that folder type the following commands :
mkdir folder{1..100}
/*mkdir command is for creating directory*/
touch folder{1..100}/file{1..100}
/*touch command is used for creating files*/
BOOM!! That’s it.
Let’s understand what we did.
In the first command we used brace({}) expansion to create folders from ‘folder 1’, ‘folder 2’ … ‘folder 100’.
In the second command we created 100 files in each of those 100 folders.
2. Automation using Scripts : We can use the crontab to automate our tasks on Linux so that we need not to type the commands or execute the scripts(Linux programs) every time we want to perform a task.
To do this, the user needs to create a crontab file (using the crontab -e command which is also used to edit a crontab file). Inside this crontab file the user can specify the commands or the scripts along with the date & time details.
The crontab file has 6 columns that needs to be filled(5 columns contain information about the date & time and the 6th column contains the command or the path to the script that needs to be run)
The script at /usr/bin/example will execute at 10:30 am on 29th of July(7th month) if that day is a Thursday(4th day).
3. Piping & Redirection : With pipes and redirection, you can “chain” multiple programs to become extremely powerful commands. Most programs on the command-line accept different modes of operation. Many can read and write to files for data, and most can accept standard input or output. This means that you can direct the output of one program as input to another program. You can then take the output of the second program and redirect it as input to yet another program, or redirect the output to a file.
Every program(command) we run on the command line automatically has three data streams connected to it.
- STDIN (0) — Standard input (data fed into the program)
- STDOUT (1) — Standard output (data printed by the program, defaults to the terminal)
- STDERR (2) — Standard error (for error messages, also defaults to the terminal)
In Linux, the pipe
command lets you sends the output of one command to another. Piping, as the term suggests, can redirect the standard output, input, or error of one process to another for further processing.
Syntax: Command-1 | Command-2 | …| Command-N.
Stream Redirection: Linux includes redirection commands for each stream. These commands write standard output to a file. If a non-existent file is targetted (either by a single-bracket or double-bracket command), a new file with that name will be created prior to writing.
Overwrite
- > — standard output
- < — standard input
- 2> — standard error
Commands with a double bracket do not overwrite the destination’s existing contents.
Append
- >> — standard output
- << — standard input
- 2>> — standard error
Congratulations!! You now know some powerful features of Linux.
Hope you enjoyed it :)
If you want to learn more about Linux, then there is a great course on Udemy
Click here to view it : Linux Course