In this post I will show you a few simple tips and tricks to increase your productivity using the terminal in linux. Try to memorize these tips and tricks as you will need them as a webdeveloper.
1. Use autocompletion
The linux terminal has a very nice autocompletion feature. To use it, just type the first few letters of the command or directory and then press tab. If there are multiple options, the terminal will show you what it found. Just type the next letter to narrow the list.
2. Run last command as sudo
Don’t you hate it when you type a long command for which you need root permissions and you forgot to type sudo infront of it? Don’t worry, here’s a useful tip for you! Just type sudo !! to execute the last command you entered as with sudo.
Bonus tip: If you just want to repeat the last command, because for example you want to view the contents of a changed file again, just type !!. This will repeat the last command.
3. Searching for text in a file
When working with large log files, it can be really tedious to find that one exception or log entry among the huge amount of text. Not to worry! Just type the following command: cat YOURFILE | grep "THE TEXT TO SEARCH FOR" when you run this command you’ll only receive the lines of the log file that contain the text you search for. Really useful!
4. Return to home
After a hard day at work we all want to return to home. If it only were as easy as in linux. In linux you can just type cd ~ and you’ll be taken straight to your home directory. Can’t get any easier!
5. Return to the previous directory
If you’re switching around directory all the time, it can be really annoting having to type ../ all the time. To combat this you can switch between two directories really fast by typing cd -.
Do you have more productivity tips? Share them in the comments!