Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Wiki Markup
{scrollbar}

Anchor
top
top

4.1. Console and Commands

Overview

Karaf provides a powerful console and a set of commands that can be used to perform various tasks. Commands can be located in the root shell or in a sub-shell. A sub-shell is a group of related commands, like commands related to the OSGi framework or the log system.

The following shells are available out-of-the-box, but the console can be easily extended:

...

help

The help method is one of the most usefull method to get you started. Without any parameters, the command will display the list of available commands.
You can also access the help from a subshell by launching help osgi for example.
You can access the help from a command by launching help clear or for a sub-shell command: help osgi/list or osgi/list --help.

exit

If ran from the local console, Karaf will be stopped. If ran from a remote console, the remote shell will be terminated, but the Karaf remote instance will not be terminated.

..

When inside a subshell, the .. command will exit this subshell and go back to the parent shell.

For example:

Code Block

smx@root:/> log
smx@root:log> help
Available commands:
  display            Display log entries.
  display-exception  Display the last exception from the log.
  get                Show log level.
  set                Set log level.
  d                  Link to: log/display
  de                 Link to: log/display-exception
smx@root:log> ..
smx@root:/> 

info

This command displays a bunch of information relative to the Karaf and the JVM. These informations are also available from the JMX console included in the JRE.

Admin shell

Admin shell

This shell is described extensively in section 4.7. Administration.

Config shell

This shell is described extensively in section 4.8. Configuration.

Features shell

The features shell contains a few commands to provision entire applications easily.
More information is available on the chapter 4.6. Provisioning.

Log shell

The log shell contains a few commands to display the log entries, retrieve or change the log levels:

Command

...

Description

display

Display log entries.

display-exception

Display the last exception from the log.

get

Show log level.

set

Set log level.

See the documentation on the logging system for more informations.

OBR shell

OBR (OSGi Bundle Repository) is a proposed specification that defines an xml format for repositories of OSGi bundles and an associated service to access it. Karaf proposes a number of commands that can be used to deal with such repositories.

Note that this feature is not installed by default. To install it, you must run the following command:

Code Block
smx@rootkaraf@root:/> features/:install obr

Command

...

Description

addUrl

Add a list of repository URLs to the repository service

deploy

Deploy

info

Display the meta-data for the specified bundles.

list

List

listUrl

Display the repository URLs currently associated with the repository service.

removeUrl

Remove a list of repository URLs from the repository service

source

Source

start

Start

OSGi shell

The OSGi sub-shell provides commands for managing the OSGi framework: listing OSGi bundles, services, managing bundle lifecycles.
Look at the online help (launch osgi help command) for more informations.

Command

Code Block

smx@root:/> help osgi

Available commands in osgi:
  bundle-level          Get or set the start level of a given bundle
  headers               Display headers
  install               Install bundle
  list                  List bundles
  ls                    List services
  refresh               Refresh bundle
  update                Update bundle
  resolve               Resolve bundle
  shutdown              Shutdown
  start                 Start bundle
  start-level           Get or set the start level
  stop                  Stop bundle
  uninstall             Uninstall bundle

Remote shell

...

Description

bundle-level

Get or set the start level of a given bundle

headers

Display headers

install

Install bundle

list

List bundles

ls

List services

refresh

Refresh bundle

update

Update bundle

resolve

Resolve bundle

shutdown

Shutdown

start

Start bundle

start-level

Get or set the start level

stop

Stop bundle

uninstall

Uninstall bundle

Package shell

Command

Description

imports

Display imported packages

exports

Display exported packages

Shell shell

Command

Description

cat

Displays the content of a file or url

echo

Echoes or prints arguments to STDOUT

exec

Executes system processes

grep

Prints lines matching the given pattern

info

Prints system informations

java

Execute a Java standard application

printf

Format and print arguments

sleep

Sleeps for a bit then wakes up

sort

Write sorted concatenation of all files to standard output.

tac

Captures the STDIN and returns it as a string. Optionally writes the content to a file

Examples:

Code Block
cat mvn:org.apache.servicemix/servicemix/3.2.1/pom

or

Code Block
ldlog:display | grep error

SSH shell

Command

Description

ssh

Connects to a remote SSH server

sshd

Creates a SSH server

Wrapper shell

Note that this feature is not installed by default. To install it, you must run the following command:

Code Block

karaf@root:/> features:install wrapper

Command

Description

install

Install the container as a system service in the OS.

#top4.1. Commands

Wiki Markup
{scrollbar}