Home Linux Commands How To Save Linux Commands And Use Them On Demand

How To Save Linux Commands And Use Them On Demand

By sk
Published: Updated: 29.5K views

Let us say you're searching for a particular command to solve a specific issue on your Linux system. After a bit of web search, you found the solution to fix the issue. After a few weeks or months, you encountered with the same issue on another Linux system. You remember solving the same issue a few weeks ago, but you completely forgot the full command. You do reverse search on your Terminal by pressing 'CTRL+R' from the Terminal, and you search through your browser history. But your mind has completely gone blank and you couldn't recall the exact command. I don't know if it ever happened to you, but I have faced this issue a few times. Every time, I had to spend a lot of time on the web to search for commands. Not any more! Say hello to 'Keep', a personal shell command keeper to save Linux commands and use them whenever you want.

What is Keep?

As the name says, the 'Keep' utility allows you to keep the most frequently used and most important Linux commands and you can use them later without having to search on websites or man pages. Also, you don't need to memorize the lengthy and complex commands. Keep utility will save your important and frequently used commands in Terminal itself. You can retrieve and execute them at any time. More importantly, you can sync the saved commands across multiple systems and also save all commands on a remote system.

To put this simply, 'Keep' utility,

  • can keep all your commands with brief description,
  • allows you to search the saved commands using powerful patterns,
  • allows you to sync saved commands on multiple systems on the network,
  • allows you to save commands on any remote server on the network.

In this brief guide, I will show you how to install and use 'Keep' in Linux and Unix-like systems.

Install 'Keep' On Linux

The easiest and official way to install 'Keep' is by using Pip. Pip is a package manager that allows you to install applications written using Python programming language.

Pip can be installed on Arch Linux and its derivatives as shown below:

$ sudo pacman -S python3-pip

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install python3-pip

On RHEL, Fedora, CentOS:

Enable EPEL repository first.

$ sudo yum install epel-release


$ sudo dnf install epel-release

Then, install pip using command:

$ sudo yum install python3-pip


$ sudo dnf install python3-pip


$ sudo zypper install python3-pip

Once pip installed, run the following command to install 'Keep'. The following command is same for all Linux distributions!

$ sudo pip3 install keep

Save Linux Commands In Terminal And Use Them On Demand Using 'Keep' Utility

'Keep' usage is very simple. The typical syntax of 'keep' utility is:


Let me show you a few practical examples.

Have a look at the following command:

$ find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;

This command will find and copy all files that ends with extension .txt and save them in "/home/sk/Downloads/" directory. I am very poor at remembering things. After a couple days, I might forget this command. I bet some of you can't remember this kind of lengthy commands after some time.

So, what I am going to do is just save this command in my Terminal using 'keep' utility.

First, we need to initialize the 'keep' environment.

To do so, run:

$ keep init

The above command will ask you to enter your Email. It is the unique username to you.  You can input anything unique to you. You can also choose not to register this time and later start the process by using keep register command. If you do not intend to use the server for storing or fetching your commands, just ignore the registration. It generates a 255 bit password for you. It is then stored inside your ~/.keep/.credentials file.

Sample output would be:

Initializing environment in ~/.keep directory
Proceed to register? [Y/n]: y
Your credentials will be saved in the ~/.keep directory.
Email: admin@ostechnix.com
Repeat for confirmation: admin@ostechnix.com
Verifying with existing users...
Generated password for admin@ostechnix.com
Registering new user ...
User successfully registered !
Credentials file saved at ~/.keep/.credentials.json

Save a new command

To save a new command, just run:

$ keep new

Enter the full command you'd like to save and hit ENTER. Then, provide the description of the command and press ENTER key.

Sample output:

Command: find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
Description : find and copy all files that ends with extension .txt

Now, the command has been saved. Similarly, you can save any number of commands using 'keep new' command.

View the saved commands

To view all saved commands, just run:

$ keep list

This command will display the list of saved commands with description.

Sample output:

Command Description
-------------------------------------------------------- -----------------------------------------------------
$ find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \; find and copy all files that ends with extension .txt

Search for the saved commands

You can search any saved commands with its description. You don't have to specify the complete description. Look at the following example.

$ keep grep "find and copy"

You will see the saved commands matching to the search term. I got the following command output when running the above command:

$ find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \; :: find and copy all files that ends with extension .txt

Execute the saved commands

To execute the saved commands at any time, simply run with saved command's description as shown below:

$ keep run "find and copy"

You will be asked whether to execute or not the command. Just press 'Y' to run the command:


find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;

? [Y/n]: y

Sync Saved commands with another system

If you have another system, install 'keep' on it as I described in the "Install Keep" section. Then, run "keep init" (without quotes, of course) command and skip registration. Copy your ~/.keep/.credentials file over to the target computer in the same location. Finally, run the following command to retrieve all the saved commands.

$ keep pull

To store the commands on the remote server, use 'keep push' command.

Delete saved commands

To delete a saved command, simply run:

$ keep rm

Enter the command to remove and hit ENTER. The specified command will be deleted from the Keep cache.

Command to remove: find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
Command successfully removed!

For more details, run:

$ keep --help

Suggested Read:


'Keep' utility is really useful when it comes to dealing with numerous commands everyday. It is quite difficult to remember all commands. In such cases, Keep utility might be useful.


You May Also Like


Mahmoud F.Elshazly March 7, 2017 - 7:37 pm

Great, Thanks.

EDA March 8, 2017 - 9:06 am

Great article. Nicely done. Thanks!

Mr. Mxyzptlk March 13, 2017 - 5:56 pm

Sorry, what’s wrong with ‘alias’ again? It’s not multi-server, but how exactly does server 2 grab directly from server 1, or is there an intermediary to hold all of your accidentally stored passwords? And heck: does it take args?

Basically I’ll do alias for simple commands, a local bin/ for more complex scripts, and I’ll sync them all together myself with tar/cp/rsync. Thanks anyway though; you reinvented the wheel nicely.

SK March 13, 2017 - 8:57 pm

There is nothing wrong with ‘alias’. This is just another way to save the commands. If you have any ideas to improve it, just ping the developer via GitHub. Thanks for the comment.

Mk July 20, 2018 - 2:31 pm

Omg. There is built in history already. Also you can use history and fzf.

Victor Stadnichenko October 23, 2019 - 7:37 pm

Cool! Thank you!

Aaron February 25, 2020 - 10:21 pm

Any similar tool on Windows that anyone knows of?

chris August 24, 2020 - 12:08 am

This is just what I needed, thanks!


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More