Posted by : Bijesh Debbarma Friday, 1 January 2016

Here we bring to you five strong command line shortcuts that can strength your already powerful Linux. 

Linux, open source, Linux tools, Linux command line, Linux command, Command line shortcuts, Linux command line shortcut, Command bash shortcut, Linux bash commands, Linux commandsThose who are deep into Linux know how powerful the command line is and once you get used to it, nothing is as easy as doing stuff from command line. So if you are someone who spends most of their time on command line, here we bring to you some handy short cuts which will not only save your time but will also make your interaction with the Linux command line much more interesting. 

1. Use pipe |

The standard output of a command can be piped to some other command using pipe |.

For example:



In the example above, the output of ls command is piped as input to grep command. Using this input, the grep command finds and displays all the file names that have the string "micro" in them.
2. Use * and ?

The wild-card character * is used to match against any number of characters while the character '?' is used to match against a single character. Infact both * and ? can be used together as well

For example:







3. Run multiple commands together

If you are working on something that requires execution of 2-3 commands repeatedly, then this can be done by either using a script or by using ; on command line.

For example:



In the example above we executed both ls and cat command back to back and the corresponding output was produced.
4. Jump to last working directory

There can be times where while working on command line you are required to jump between two separate directories. Using the standard cd command followed by the complete path can be a bit time taking. For these situations you can use the 'cd -' command.

For example:



So as you see first we went inside the desktop folder. Then we moved to Images. And on executing command cd - the working directory was switched back to Deskop. So like this you can use the cd - command to switch between two directories without wasting time.
5. Use !! and !

Double and single exclamation marks make interesting short cuts on Linux command line. While double exclamations represent the last command that was run, single exclamations can be used to either display or run any command whose name is mentioned along with the exclamation mark.

Here is the example of double exclamations:



In the example above, the whoami command was run first. Next, when the !! was run as a command, the last command (whoami) was run again. This confirms that !! represents the last run command. Now, these double exclamations can be used in situations where it is desired to add something to the last run command.

For example:



In the example above, the output of the ls command was piped to grep without even writing ls again (we know ls sounds small but you can actually use this with all the long commands)

Next, single exclamations are also extremely useful. A single exclamation can be used with a command-name to either show or run the last used command that used the command-name.

For example:



![command-name]:p displays the last run command that used [command-name]
![command-name] actually re-runs the last run command that used [command-name]

So that's how !! and ! are of great use when used as Linux command line short cuts. 

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

- Copyright © Indian Blackhats