Hello, all penguins what’s going on in this article I show you the best way to use Linux terminal and some of its tips and tricks, So that, making you much much faster on the Linux terminal or shell. As a Linux beginner or a Linux system administrator. You a programmer and you use Linux a DevOps engineer whatever the title is gonna spend a huge chunk of your time working in a shell environment.
In other words, investing some time and getting really fast things. That I found ways the most time are things like tables while you’re typing forgetting to pre-penned something at the beginning of a command and the kind of surprising one was poor navigation through log files. I didn’t know how quickly you can get around a log file until I saw somebody was much better than me doing it.
As a beginner, If you don’t know the basics of moving around so if you don’t know the pre rex like navigating beginning or end of line limited words into commands searching backward through your shell history as you type you don’t know those just implement these tips and tricks into your daily work and you’ll get a good speed on Linux terminal. Then let’s start using terminal like a pro.
Using tab for auto-completion
Typing in long directory and file names is a big boring pain and nobody likes doing it. One way you can avoid typing that big boring pain. Is to use tab completion. It works pretty much the same as tab completion for commands has your typing a command or file path just hit the tab key. If you’ve typed enough to distinguish a single commander single file the show will automatically be completed. Otherwise, it’ll go beep. And then if you press tab again it’ll list all the possible completions that you’ve typed experience show users you tap completion all the time. Almost without thinking about it try it out. You can actually use it to navigate all around the directory structure without ever using CD at all.
For instance, I want to go Document directory so I type cd D and press tab once then nothing happens but when I press tab twice it will show me all possibilities which start with D and if type Doc and press tab it will autocomplete the name of Document folder.
Run Multiple Command at same time
Whenever you want to combined command, for example, I want to use the LS command and I also want to know the present working directory so I’m going to use pwd command and in between, I have used this separator (;) sign. And this is going to combine these commands. And then it is going to show us the output.
On the above output, we can see I ran two commands at the same time and it will see the result of both commands. You can run as many commands with separators.
Run multiple commands only if the first command is executed.
On the other hand, firstly we use this separator(;) to run multiple commands. Now we use the ampersand (&) sign to run multiple commands at the same time.
Command will run like this first command && second command and so on.
In the above instance, I ran three commands together. First, I move file1 to Document directory then I changed to that directory after that I list that directory content.
Run command Like a Hacker.
Every time when you run a command that will go in history. But you want that it will not go to history like the hacker. You’ll notice here when you run any command like date command then type history you see that those, commands are in the history.
But if I put a space before the command. That command Not going to be in history. You can run any command like this and that will not store in history.
Open an editor to run Command
open an editor to run a command so this is great if you want to compose a big command you don’t want to do it all in one line. You can open a quick editor while you write in the terminal so the command is to open an editor control+x+e. This will open an editor. From here you can type your command, of course, it could be multiple lines and when you are done writing. you save it and exit from the editor. That will run that command.
Exit terminal without killing its background process.
The problem of terminals is if they terminate or if you close them the terminal receives a hangup signal it then takes that hang up signal and sends it to all the child processes effectively killing them in my case it wouldn’t kill them is if the process caught hang up signals and ignore them or if it was started with the no hub, command which makes it so it doesn’t receive a hangup signal but by doing disowned you detach from the terminal and then it will not receive a hangup so disown -a && exit basically disowns all the processes that terminal opened and then you simply exit.
Deleting text with Keyboard IN Terminal.
That is cutting and pasting it or uncut it’s super useful you’ll use it all the time because a lot of the time if you’re navigating around a file.
Use ctrl+u to delete the text before the cursor. The best example to use this, assume you log in to your Linux system and you put your password. and in Linux you type password it will not show. you type your password incorrect and now you hit backspace toy delete the password. But how can you know that is all your password you type in delete. so just press ctrl+u to delete all your typed password just in once.
Repeating your argument
This is really useful little thing and that I actually just recently discovered if you’re for example ping 220.127.116.11 just for instance here. And then you want to do some other stuff I mean that’s often we’re like exploring a host or we are kind poking and prodding it you’re running Nmap you’re running paying you’re trying to tell that to something into maybe doing and Netcat or something who knows you’re doing something repeatedly different things. You’re doing a bunch of different things to kind of work on one resource like a host One of the things that’s really useful is the alt period command.
For instance, I create a blank file with the touch command. like touch file2, now to open with the text editor I just type my favorite editor and press alt+ period and that will repeat my argument which is the file name file2.
Creating your Own Command with an alias.
The alias command allows you to create your own version of the command.
For instance, assume you run ls command but you want ls -lrth so you can alias this to ls. In terminal just type alias ls=”ls -lrth” and hit enter. Now every time when you run ls it will run the full command ls -lrth.
How to see the content of the compressed file.
Many times we compressed a file or a folder to save the disk space. Meanwhile now we want to see that compressed file content again but without uncompress that folder. if we use a simple cat then it will show encrypt the file content.
So here z command is very useful it allows us to see compressed file content and we can see the content of the file.
SO we can use zcat to see file content without uncompressing the file.
So in this article, we learn how to use Linux terminal like a pro and its tips and tricks. let me know in the comment how many tricks you know before. in this article, I discussed tricks you can run on almost every Linux distribution. If you know any trick then let me know in the comment and help other penguins.
I hope you enjoy my article. please subscribe to our newsletter to read my articles and please share with all your penguins’ friends to grow. To Improve this article if you find anything incorrect so please comment below and I will update.