kb - ArchWiki

Jump to content

# kb

From ArchWiki

This article or section is a candidate for merging with List of applications.

Notes: The content is copied from https://github.com/gnebbia/kb/blob/main/README.md. (Discuss in Talk:Kb)

Related articles

- List of applications

kb is a minimalist terminal-based knowledge manager.

## Installation

Install the kbAUR or kb-gitAUR package.

## Purpose

kb is a text-oriented minimalist command line knowledge base manager. kb can be considered a quick note collection and access tool oriented toward software developers, penetration testers, hackers, students or whoever has to collect and organize notes in a clean way. Although kb is mainly targeted on text-based note collection, it supports non-text files as well (e.g., images, pdf, videos and others).

In few words kb allows a user to quickly and efficiently:

- collect items containing notes,guides,procedures, cheatsheets into an organized knowledge base;
- filter the knowledge base on different metadata: title, category, tags and others;
- visualize items within the knowledge base with (or without) syntax highlighting;
- grep through the knowledge base using regexes;
- import/export an entire knowledge base;

It is strongly suggested to add some kb aliases to really take advantage of the kb workflow.

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

## Usage

### List artifacts

#### List all artifacts contained in the kb knowledge base

    kb list

or if aliases are used:

    kbl

#### List all artifacts containing the string “zip”

    kb list zip

or if aliases are used:

    kbl zip

#### List all artifacts belonging to the category “cheatsheet”

    kb list --category cheatsheet

or

    kb list -c cheatsheet

or if aliases are used:

    kbl -c cheatsheet

#### List all the artifacts having the tags “web” or “pentest”

    kb list --tags "web;pentest"

or if aliases are used:

    kbl --tags "web;pentest"

#### List using “verbose mode”

    kb list -v

or if aliases are used:

    kbl -v

### Add artifacts

#### Add a file to the collection of artifacts

    kb add ~/Notes/cheatsheets/pytest

or if aliases are used:

    kba ~/Notes/cheatsheets/pytest

#### Add a file to the artifacts

    kb add ~/ssh_tunnels --title pentest_ssh --category "procedure" \
       --tags "pentest;network" --author "gnc" --status "draft"

#### Add all files contained in a directory to kb

    kb add ~/Notes/cheatsheets/general/* --category "cheatsheet"

#### Create a new artifact from scratch

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

a text editor ($EDITOR) will be launched for editing

### Delete artifacts

#### Delete an artifact by ID

    kb delete --id 2

or if aliases are used:

    kbd 2

#### Delete multiple artifacts by ID

    kb delete --id 2 3 4

or if aliases are used:

    kbd 2 3 4

#### Delete an artifact by name

    kb delete --title zap --category cheatsheet

### View artifacts

#### View an artifact by id

    kb view --id 3

or

    kb view -i 3

or if aliases are used:

    kbv 3

#### View an artifact by name

    kb view --title "gobuster"

or

    kb view -t "gobuster"

#### View an artifact without colors

    kb view -t dirb -n

#### View an artifact within a text-editor

    kb view -i 2 -e

or if aliases are used:

kbv 2 -e

### Edit artifacts

Editing artifacts involves opening a text editor. Hence, binary files cannot be edited by kb.

The editor can be set by the “EDITOR” environment variable.

#### Edit an artifact by id

    kb edit --id 13

or if aliases are used:

    kbe 13

#### Edit an artifact by name

    kb edit --title "git" --category "cheatsheet"

or

    kb edit -t "git" -c "cheatsheet"

### Grep through artifacts

#### Grep through the knowledge base

    kb grep "[bg]zip"

    # or if aliases are used:
    kbg "[bg]zip"

#### Grep (case-insensitive) through the knowledge base

    kb grep -i "[BG]ZIP"

#### Grep in “verbose mode” through the knowledge base

    kb grep -v "[bg]zip"

### Import/Export/Erase a knowledge base

#### Export the current knowledge base

To export the current knowledge base:

    kb export

This will generate a .kb.tar.gz archive that can be later be imported by kb.

If you want to export only data (so that it can be used in other software):

    kb export --only-data

This will export a directory containing a subdirectory for each category and within these subdirectories we will have all the artifacts belonging to that specific category.

#### Import a knowledge base

    kb import archive.kb.tar.gz

NOTE: Importing a knowledge base erases all the previous data. Basically it erases everything and imports the new knowledge base.

#### Erase the entire knowledge base

To erase the entire knowledge base just do:

    kb erase

## Reporting issues

Please report any issue here.

Category:

- Synchronization

Hidden category:

- Pages or sections flagged with Template:Merge