LinuxCommandLibrary

llm

Run local Large Language Models

TLDR

Set up an OpenAI API Key

$ llm keys set openai
copy

Run a prompt
$ llm "[Ten fun names for a pet pelican]"
copy

Run a system prompt against a file
$ cat [path/to/file.py] | llm [[-s|--system]] "[Explain this code]"
copy

Install packages from PyPI into the same environment as LLM
$ llm install [package1 package2 ...]
copy

Download and run a prompt against a model
$ llm [[-m|--model]] [orca-mini-3b-gguf2-q4_0] "[What is the capital of France?]"
copy

Create a system prompt and save it with a template name
$ llm [[-s|--system]] '[You are a sentient cheesecake]' --save [sentient_cheesecake]
copy

Have an interactive chat with a specific model using a specific template
$ llm chat [[-m|--model]] [chatgpt] [[-t|--template]] [sentient_cheesecake]
copy

SYNOPSIS

llm [OPTION]... [FILE]...

(Internally often resolves to: ls -l [OPTION]... [FILE]... | more)

PARAMETERS

-a, --all
    Do not ignore entries starting with '.' (hidden files).

-h, --human-readable
    With -l, print sizes in human-readable format (e.g., 1K, 234M, 2G).

-r, --reverse
    Reverse order while sorting.

-t
    Sort by modification time, newest first.

-S
    Sort by file size, largest first.

-R, --recursive
    List subdirectories recursively.

-d
    List directories themselves, not their contents.

-i, --inode
    Print the index number (inode) of each file.

-F, --classify
    Append indicator (one of */=>@|) to entries.

--color=WHEN
    Colorize the output. WHEN can be 'auto', 'always', or 'never'. Often implicitly used in llm aliases.

DESCRIPTION

The command llm is not a standard Linux binary, but rather a widely adopted alias or shell function that typically executes the ls command with the -l (long format) option, often combined with a pager like more or less for large outputs.

The primary purpose of llm (via ls -l) is to provide a detailed listing of files and directories, showing permissions, number of hard links, owner, group, size, last modification time, and the filename itself. The addition of a pager makes it particularly useful for viewing contents of directories with many files, preventing the output from scrolling off the screen.

While the exact definition of llm can vary between users and distributions (e.g., it might also include -a for all files, or --color=auto), its core utility lies in presenting comprehensive file information in an easily digestible, paginated format.

CAVEATS

llm is not a standard executable. Its behavior is entirely dependent on how it is defined as an alias or shell function in the user's shell configuration files (e.g., ~/.bashrc, ~/.zshrc). Therefore, its exact functionality and available options can vary across different systems and user setups. Users should check their shell configuration for the precise definition of llm if it's not behaving as expected.

OUTPUT COLUMNS

When using ls -l (and thus llm), the output is typically displayed in several columns:
1. Permissions: File type and permissions (e.g., -rwxr-xr-x).
2. Links: Number of hard links to the file.
3. Owner: Username of the file's owner.
4. Group: Group name of the file's group.
5. Size: Size of the file in bytes (or human-readable format with -h).
6. Modification Date: Date and time of the last modification.
7. Name: The filename or directory name.

ALIAS CONFIGURATION

To define the llm alias, you would typically add a line like the following to your shell's configuration file (e.g., ~/.bashrc for Bash, ~/.zshrc for Zsh):
alias llm='ls -l --color=auto | more'
After adding or modifying the alias, you need to either restart your shell or source the configuration file (e.g., source ~/.bashrc) for the changes to take effect.

HISTORY

The ls command itself is one of the oldest and most fundamental utilities in Unix-like operating systems, dating back to the earliest versions of Unix. The -l (long format) option has been a standard part of ls for decades, providing detailed file information.

The emergence of aliases like ll (for ls -l) and la (for ls -la) became popular as a convenience for users to quickly access these frequently used options. The llm alias is a natural extension of this trend, adding a pager to the ls -l output to handle large directories more effectively, reflecting a common user need for better output management in interactive shell sessions.

SEE ALSO

ls(1), more(1), less(1), find(1), stat(1), alias(1)

Copied to clipboard