If you are a Linux user, there is no doubt you are using the command line to perform almost all the computer tasks. The command line is used to communicate with your computer and has its own set of commands. Some of the commands are commonly used by most of the users while some are used by a few and some are used by hardly anyone else.
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. It’s one of the world’s most widely used operating systems. Linux/Unix based working environment provides an interface that operates in a command line environment.
Today, we are here with some of the top 5 linux command line tricks that you can use in the day – to – day life.
We will present a few examples for each of these commands and let you know some practical use cases. So, without further ado, let’s check out these top 5 linux commands you should know!
The first one is the Touch Command.
This command allows you to modify access and modification times on any file in Linux Operating System.
The syntax for this command is as follows:
In this example, we will be using our ‘test’ file to demonstrate this command.
To begin with, touch will check whether our ‘test’ file exists or not. If it does not exist, then it will create a zero-length file with the same name as that of specified filename.ext in the current working directory (working directory is the location where you are currently present).
No more messy up arrow
If you’ve worked with the command line for a while, odds are you’ve had to endure using the up arrow to scroll through your history. You can use the Ctrl+R combination instead to search for the command.
Use the pwd (present working directory) command to see what directory you’re in at any time.
grep is a search utility that will search the given files or strings for lines that contain a matching pattern.
grep word file.txt
Find Duplicate Files Using ‘fdupes’
Fdupes is a great tool to find duplicate files in your home directory. With this tool installed, you can easily find duplicates and then clean them up.
View All Log Files
If you want to view all your log files in a single place, use the following command:
$ less /var/log/*.log
This will display each log file in less, which is useful for when you want to search or scroll through them.
Tricks with Pipes
The pipe “|” symbol can be used to take the output of command on the left side and pipe it as input for the command on the right side. We call this process as piping.
Here is the simple example of using pipes:
command1 | command2
command1 is taking input from standard input (stdin) and sending output to standard output (stdout). Thus, if we send data into stdin, then it will be passed to command2 as input.
Login to remote computer
Use ssh to directly connect to a remote computer. This is super useful for debugging or getting into a broken server.