Blog links

Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Tricks and tips For Linux



The commands that we have typed in the terminal is stored in the Linux system in the hidden file called .bash_history. You can view the hidden file from the terminal itself using the editor. You can also see the latest histories in the terminal itself. You search the pattern in the history, execute the history with the help of number and clear all the history. As, we already know by pressing down and up arrow we you can access the previously typed commands.

To view the command history.

Go to terminal and type:
history
For page wise view, type:
history | more
history1 Linux History command  tricks and tips

Searching specific command history:

You can search the specific command in history using grep command. To master in grep command, see grep command with example. To search for the ls command only, I would type:
history | grep ls
historysearch Linux History command  tricks and tips

Deleting all the history:

You can clear all the history data. Go to terminal and type:
history -c
deletehistory Linux History command  tricks and tips

Searching using keyword using Ctrl+R:

Press Ctrl+R and type the keyboard and hit enter.historysearchusingkeyword Linux History command  tricks and tips

Executing specific command from history:

The command in the history are listed by numbers. To execute the command type:
!20015
20015 here is the command number.
executehistory Linux History command  tricks and tips


Read more

How to run multiple linux command at same time


 How to run multiple linux command at same timeThe multiple number of commands can be executed at once in Linux terminal using two different ways. Both the ways are too simple. The one way among the two introduce us to theShell Scripting. Yes, I have been talking a lot about shell scripting. Well, it starts now! Let’s focus on how to run multiple command at same time. I recommend, if you are not familiar with the Linux commands see our other various tutorials which will make you familiar with the various Linux commands. Also, see the cool things that you can do in the terminal like watching games, playing movies and all.

Way 1:

This one is very simple. You just need to separate the commands which semi colon. After you are done, hit enter and all your commands will execute. The syntax is:
command; command; command; command
multiplecommands How to run multiple linux command at same time
The commands ls, cat hello and ls -l are executed. The first command “ls” listed all the directories, “cat hello” read the file hell0 and “ls -l” commands listed all the files and directories in detail with permission. See, the various things you can do with ls command and cat command.

Way 2:

Instead of executing the command from terminal we will first store the commands in a text file and later execute that file. This is called shell script. Shell simply refers to terminal and script means command that do something. Thus, shell script is nothing just a bunch of commands written in  a text file.
First let us create a file using cat utility with commands in that file:
createfileusingcat How to run multiple linux command at same time
We created a text file called shscriptexample and put three commands in that file. This file is now called script file.
How to execute script file:
The syntax for executing script file is:
sh filename
executescriptfile How to run multiple linux command at same timeAs you can see, the result is same. The shell script makes the Linux shell more powerful. To perform specific task, you can create your own script file and execute that file. I am going to cover more tutorials on shell scripting.

Read more
2leep.com