Advertisement
v1ral_ITS

<keep> Full Command Tutorial Never Forget cmds again

Apr 3rd, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.24 KB | None | 0 0
  1. Install ‘Keep’ On Linux
  2.  
  3. 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.
  4.  
  5. Pip can be installed on Arch Linux and its derivatives as shown below:
  6.  
  7. $ sudo pacman -S python-pip
  8.  
  9. On Debian, Ubuntu, Linux Mint:
  10.  
  11. $ sudo apt-get install python-pip
  12.  
  13. On RHEL, Fedora, CentOS:
  14.  
  15. Enable EPEL repository first.
  16.  
  17. $ sudo yum install epel-release
  18.  
  19. Or,
  20.  
  21. $ sudo dnf install epel-release
  22.  
  23. Then, install pip using command:
  24.  
  25. $ sudo yum install python-pip
  26.  
  27. Or,
  28.  
  29. $ sudo dnf install python-pip
  30.  
  31. On SUSE/openSUSE:
  32.  
  33. $ sudo zypper install python-pip
  34.  
  35. Once pip installed, run the following command to install ‘Keep’. The following command is same for all Linux distributions!
  36.  
  37. $ sudo pip install keep
  38.  
  39. Download – Free eBook: “Learning Linux Shell Scripting ($36 Value) FREE For a Limited Time”
  40. Save Commands In Terminal And Use Them On Demand Using ‘Keep’ Utility
  41.  
  42. ‘Keep’ usage is very simple. The typical syntax of ‘keep’ utility is:
  43.  
  44. $ keep [OPTIONS] COMMAND [ARGS]...
  45.  
  46. It’s time to see some practical examples. Look at the following command.
  47.  
  48. find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
  49.  
  50. This command will find and copy all files that ends with extension .txt. and save them in /home/sk/Downloads/ directory. I have very poor memory. After a few  weeks or months, I couldn’t remember this command. I bet some of you can’t remember this kind of lengthy commands after some time.
  51.  
  52. So, what I am going to do is just save this command in my Terminal using ‘keep’ utility.
  53.  
  54. First, we need to initialize the ‘keep’ environment.
  55.  
  56. To do so, run:
  57.  
  58. $ keep init
  59.  
  60. 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 choose to not register this time and later start the process by using keep register command. You can use Keep CLI without registering if you do not intend to use the server for storing or fetching your commands. It generates a 255 bit password for you. It is then stored inside your ~/.keep/.credentials file.
  61.  
  62. Sample output would be:
  63.  
  64. Initializing environment in ~/.keep directory
  65. ...OK
  66. Proceed to register? [Y/n]: y
  67. Your credentials will be saved in the ~/.keep directory.
  68. Email: admin@ostechnix.com
  69. Repeat for confirmation: admin@ostechnix.com
  70. Verifying with existing users...
  71. Generated password for admin@ostechnix.com
  72. Registering new user ...
  73. User successfully registered !
  74. hBxfwuw4HxoVDRONAVtz9mG6fTP1ck1vdkoGgoPk0Bx7ijEoHJX9imCUgTOidpGX4ZpSz0xBoAA1Dwoi6r2KHPR2rn9BWRRaLPHic6N8EAx05xLMHPZHUENg1etMdJRwGlRekWTt8xNsOv7c97wOwDtzON8tIlyphxt6gLhX8T4Hpo5r7T0jvJNG1CuAWxpXcPb1Q7HogVFjG1k0mjsmMWRI8TgnpNLs
  75. Credentials file saved at ~/.keep/.credentials.json
  76.  
  77. Save a new command
  78.  
  79. To save a new command, just run:
  80.  
  81. $ keep new
  82.  
  83. Enter the full command you’d like to save and hit ENTER. Then, provide the description of the command and press ENTER key.
  84.  
  85. Sample output:
  86.  
  87. Command: find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
  88. Description : find and copy all files that ends with extension .txt
  89.  
  90. Now, the command has been saved. Similarly, you can save any number of commands using ‘keep new’ command.
  91.  
  92. View the saved commands
  93.  
  94. To view all saved commands, just run:
  95.  
  96. $ keep list
  97.  
  98. This command will display the list of saved commands with description.
  99.  
  100. Sample output:
  101.  
  102. Command Description
  103. -------------------------------------------------------- -----------------------------------------------------
  104. $ find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \; find and copy all files that ends with extension .txt
  105.  
  106. Search for the saved commands
  107.  
  108. You can search any saved commands with its description. You don’t have to specify the complete description. Look at the following example.
  109.  
  110. $ keep grep "find and copy"
  111.  
  112. You will see saved commands matching to the search term. I got the following command for the above command.
  113.  
  114. $ find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \; :: find and copy all files that ends with extension .txt
  115.  
  116. Execute the saved commands
  117.  
  118. To execute the saved commands at any time, simply run with saved command’s description as shown below:
  119.  
  120. $ keep run "find and copy"
  121.  
  122. You will be asked whether to execute or not the command. Just press ‘Y’ to run the command:
  123.  
  124. Execute
  125.  
  126. find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
  127.  
  128. ? [Y/n]: y
  129.  
  130. Sync Saved commands with another system
  131.  
  132. If you have got 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.
  133.  
  134. $ keep pull
  135.  
  136. To store the commands on the remote server, use ‘keep push’ command.
  137.  
  138. Delete saved commands
  139.  
  140. To delete a saved command, simply run:
  141.  
  142. $ keep rm
  143.  
  144. Enter the command to remove and hit ENTER. The specified command will deleted from the Keep cache.
  145.  
  146. Command to remove: find -iname '*.txt' -exec cp {} /home/sk/Downloads/ \;
  147. Command successfully removed!
  148.  
  149. For more details, run:
  150.  
  151. $ keep --help
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement