Premium Issue: 5 Command Line Tricks For Linux
As a regular user of the Linux command line, I have discovered several shortcuts that have saved me time. In this blog post, I will share 5 key command line tricks that have proven to be helpful.
Here’s What You Will Learn
As a regular user of the Linux command line, I have found several efficient shortcuts that have greatly optimised my workflow and saved me time. In this blog post, I will share 5 key command line tricks that have proven to be helpful in my everyday tasks.
1) cd -: Switch Between Directories
One handy shortcut I use is the 'cd -' command, which allows me to quickly switch between the current and previous directories.
$ cd /home/user/documents
$ cd /var/www/html
$ cd -
The last command takes me back to the /home/user/documents directory. This is especially helpful when I'm working with files in different directories.
2) !test: Run Commands With A Specific Prefix
The '!' operator has been a game changer for me. It lets me re-execute a previous command that starts with a given prefix, saving me the time of typing the entire line again.
$ test-command-1
$ test-command-2
$ !test
The last command re-executes the most recent command that starts with 'test', in this case, 'test-command-2'.
3) !!: Re-execute The Previous Command
When I need to run the same command multiple times in a row, the '!!' shortcut is a lifesaver. It enables me to re-execute the previous command with ease.