kb-the best command line knowledge base manager

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off

Have you ever found yourself many times when you want to access files, test programs, cheat sheets, payloads, guides and notes? Have you ever wished to have a tool that can include all the notes you need when you need it? These are very important problems encountered by administrators, developers, and penetration testers, especially when they encounter a problem that has been solved before and somehow forget the way to solve the problem. This guide is open to all developers, administrators, testers and designers who welcome kb.

KB is a text-oriented minimalist command-line knowledge base manager. kb can be thought of as a quick note collection and access tool for software developers, penetration testers, hackers, students, or people who must collect and organize notes in a clean way. Although kb is mainly for text-based note collection, it also supports non-text files (such as images, pdfs, videos, and other files).

The kb developers found themselves spending too much time trying to quickly search through a specific payload list, or spending too much time trying to find a specific guide/cheat sheet for the tools they needed. KB attempts to solve this problem by providing you with a quick and intuitive way to access knowledge. Basically, kb provides a clean text-based way to organize your knowledge.

Features of KB Knowledge Base Manager

Using kb, users can quickly and efficiently perform the following operations:

  • Collect items containing notes, guides, procedures, and cheat sheets into an organized knowledge base;
  • Filter the knowledge base according to different metadata: title, category, tag and others;
  • Use (or not use) syntax highlighting to highlight items in the knowledge base;
  • Grep uses regular expressions to traverse the knowledge base;
  • Import/export the entire knowledge base;

To install kb in a Linux system, you need the following

  • Python 3.6 and higher

If you are interested in using this tool to manage notes and cheat sheets, this guide will proceed with the installation and explain how to use it. Just follow the steps below.

Step 1: Update the system

Make sure your computer’s operating system is up to date

####Debian-Based###
sudo apt update && sudo apt upgrade


####RHEL-Based####

sudo yum update

Step 2: Install Python 3

Since kb is the main package that Python depends on, if you don’t have Python, let’s continue to install it and follow the steps below

Install Python 3.6+ on Ubuntu

If you are using Ubuntu 16.10 or higher, you can easily install Python 3.6 with the following command:

sudo apt-get update
sudo apt-get install python3 -y

If you are using another version of Ubuntu (such as the latest LTS version), or you want to use the latest Python, it is recommended that you install Python 3.8 using Deadsnakes PPA:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.8 -y

Install Python 3.6+ on CentOS

If you are using CentOS 7 or 8, you need to run the following command to install Python 3.

sudo yum install -y python3

Step 3: Install kb via pip

To install the latest stable version of kb, just type:

$ sudo pip3 install -U kb-manager

Collecting kb-manager
  Downloading https://files.pythonhosted.org/packages/62/58/6d4ade9e89510816bfda4ffe33967b4ed2d923dedf41300b1e851d4f7ee3/kb_manager-0.1.5-py2.py3-none-any.whl (55kB)
    100% |████████████████████████████████| 61kB 28kB/s
Collecting colored (from kb-manager)

Developers recommend the following kb bash aliases for GNU/Linux and MacOS users, so as to provide them with a better user experience

cat <<EOF > ~/.kb_alias
alias kbl="kb list"
alias kbe="kb edit"
alias kba="kb add"
alias kbv="kb view"
alias kbd="kb delete --id"
alias kbg="kb grep"
alias kbt="kb list --tags"
EOF

After completion, run the following commands to submit them.

echo "source ~/.kb_alias" >> ~/.bashrc
source ~/.kb_alias

To upgrade kb, please run the following commands frequently to get the latest stable code and patches

sudo pip3 install -U kb-manager

Homemade installation

You can also install kb in Homebrew. To do this, run the following command:

brew tap gnebbia/kb https://github.com/gnebbia/kb.git
brew install gnebbia/kb/kb

And use homemade software to upgrade:

brew update
brew upgrade gnebbia/kb/kb

Installation on Arch Linux | Wan Jia Lang

For Arch users, don’t worry or feel frustrated, you can also get kb by running the following command. Make sure you have Yay AUR assistant.

sudo pacman -S python3
yay -S python-kb

Step 4: Use kb knowledge base management tool

Here are some of the operations you can use kb.

Create a new artifact

To start using kb, we need to create new artifacts/comments from scratch. To create one, the following command will open a text editor that has been mapped to the $EDITOR environment variable. Mine will open the vi editor.

kb add --title "sftp" --category "notes" --tags "protocol;network"

On the editor, you can add comments freely, as shown below:

#To run the sftp command, the following is the syntax ftp [email protected]

List artifacts

After adding artifacts, you can list all artifacts as shown below

$ kb list

   [ ID ]  Title                Category             Tags
 - [  0 ]  sftp                 notes                protocol;network 

Add files to the artifact collection

If you have a file with procedures and comments, you can add it directly to kb. There is a file in my home directory, I add it to kb. You can do it too.

$ ls ~
Install-and-Use-kb.txt

Add the file to kb in the default category, as shown below:

kb add ~/Install-and-Use-kb.txt

List added files

$ kb list
   [ ID ]  Title                  Category             Tags

 - [  0 ]  Install-and-Use-kb.txt default       
 - [  1 ]  sftp                   notes                protocol;network 

kb-the best command line knowledge base manager

If you wish to specify another category, please do the following:

$ kb add ~/Install-and-Use-kb.txt --title install_guide --category "procedure" 
    --tags "kb;install" --author "tech" --status "draft"

List added kb files

   [ ID ]  Title                  Category             Tags

 - [  0 ]  Install-and-Use-kb.txt default
 - [  1 ]  install_guide          procedure            kb;install
 - [  2 ]  sftp                   notes                protocol;network    

kb-the best command line knowledge base manager

Delete artifact

After adding an artifact, you want to remove it from the list, you can delete the artifact. When listing artifacts, you can see an ID in the first column. This identifier can be used to delete artifacts as follows:

kb delete --id 2

Or, if using aliases:

kbd 2

You can delete multiple artifacts by ID and the following ways

kb delete --id 2 3 4

Delete artifacts by name

If you prefer the name to the ID, you can use the name of the artifact to delete it:

Let us list our artifacts to get the artifacts you want to delete

$ kb list

   [ ID ]  Title                  Category             Tags

 - [  0 ]  Install-and-Use-kb.txt default
 - [  1 ]  Test                   test                 protocol;network    
 - [  2 ]  install_guide          procedure            kb;install
 - [  3 ]  sftp                   notes                protocol;network 

Let’s delete the test title

kb delete --title Test --category test

View artifact

We have added artifacts, so how do we view them? Well, viewing notes is very easy. You can use id or name just like deleting artifacts.List all artifacts, then view one of your selected artifacts by ID

   [ ID ]  Title                  Category             Tags

 - [  0 ]  Install-and-Use-kb.txt default
 - [  1 ]  install_guide          procedure            kb;install
 - [  2 ]  sftp                   notes                protocol;network 

Let’s look at the sftp comment with ID 2.

$ kb view -i 2

#To run sftp command, the following is the Syntax
sftp [email protected]

You have noticed that viewing artifacts in this way can be achieved by displaying the artifacts on the output terminal. It is wise to view it in the editor as follows:

kb view -i 2 -e

This will open the note with the default editor, and you can edit it as needed.

Grep through artifacts

You can also learn Grep through your knowledge base! Look at the Hits column, which shows the number of times your word was found in each artifact.

$ kb grep "sftp"

   [ ID ]  Title                  Category             Hits Tags

   [  0 ]  Install-and-Use-kb.txt default              4
   [  1 ]  install_guide          procedure            4    kb;install
   [  2 ]  sftp                   notes                2    protocol;network   

Concluding remarks

KB is an invaluable tool. Without your arsenal, you cannot do it. If you rely on notes like me, kb will provide you with great service when you need it and save a lot of time, especially when you can’t access your precious Git repository. Install kb now and see if you can’t afford a smile. Finally, we thank the kb developers and contributors and you staying on the page till the end. Thank you for your continued support.

For a better guide, see the following:

Use Drush command line shell to manage Drupal CMS

How to use the oc command to display the log of an OpenShift node

How to use the Linux chown command in the example

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatturn off

Sidebar