Official command-line interface for Obsidian (v1.12+)
The CLI binary file is
obsidian-cliinside the app, but it registers and is invoked asobsidian. The Setup section below covers both ways.
Prerequisites
- Obsidian 1.12+ (1.12.7+ recommended)
- Obsidian app must be running when using CLI commands
- Enable CLI: Settings → General → Command line interface → Toggle ON
Setup
When you toggle the CLI on in Settings → General, Obsidian registers the CLI for your platform. Restart your terminal after enabling.
macOS
Registration creates a symlink at /usr/local/bin/obsidian → /Applications/Obsidian.app/Contents/MacOS/obsidian-cli. Requires admin privileges.
Verify the symlink:
ls -l /usr/local/bin/obsidian
If missing, create it manually:
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian
⚠️ Pitfall: The CLI binary changes between Obsidian versions. After updating Obsidian, the existing symlink may break or point to a stale binary. Two ways to fix:
- Re-create the symlink manually (fastest):
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian
- Toggle CLI off → on in Settings → General to let Obsidian re-register.
A simple post-update alias to put in
~/.zshrc:alias obsidian-refresh='sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian'
Alternative without a symlink — add the MacOS dir to PATH and call the binary directly:
export PATH="$PATH:/Applications/Obsidian.app/Contents/MacOS"
obsidian-cli version # works without /usr/local/bin symlink
Cleanup: older versions added # Added by Obsidian lines to ~/.zprofile. Safe to delete after re-registering with the current version.
Linux
Binary copied to ~/.local/bin/obsidian. Make sure ~/.local/bin is in your PATH:
export PATH="$PATH:$HOME/.local/bin"
Verify:
ls -l ~/.local/bin/obsidian
If missing, copy it manually:
cp /path/to/Obsidian/obsidian-cli ~/.local/bin/obsidian
chmod 755 ~/.local/bin/obsidian
Windows
Registration creates Obsidian.com (a terminal redirector for stdin/stdout) in the install folder and adds it to your PATH. Restart your terminal for PATH changes to take effect.
Verify:
Test-Path "$env:LOCALAPPDATA\Obsidian\Obsidian.com"
Test
obsidian version
Syntax
- Top-level option:
vault=<name>must come first (e.g.obsidian vault="My Vault" daily) - Parameters:
name=valueorname="value with spaces" - Flags: bare name, e.g.
overwrite,newtab,inline,permanent,case - Newlines / tabs: use
\nand\tinside content strings - Target file:
file=<name>— wikilink-style (resolves by basename, no.md)path=<folder/note.md>— exact path
- Default to active file: most commands default to the active file when
file/pathis omitted - Output formats: many list commands accept
format=text|json|tsv|csv|md|paths(default varies; checkobsidian-cli help <cmd>)
Common Commands (with examples)
Daily Notes
obsidian daily # Open today's daily note
obsidian daily:append content="- [ ] Buy milk" # Add to today's note
obsidian daily:prepend content="# Important" # Add to top of today's note
obsidian daily:read # Print today's content
obsidian daily:path # Print today's file path
Files
obsidian create name="Note" content="# Hello" # Create a note
obsidian create name="Note" template=Meeting # Create from a template
obsidian read file="Note" # Read note contents
obsidian append file="Note" content="More text" # Append to note
obsidian prepend file="Note" content="Top text" # Prepend to note
obsidian move file="Note" to="Archive/Note.md" # Move note
obsidian rename file="Note" name="New Name" # Rename note
obsidian delete file="Note" permanent # Delete (skip trash)
obsidian open file="Note" newtab # Open note in new tab
Search
obsidian search query="meeting notes" # List matching files
obsidian search:context query="TODO" # Show matching lines
obsidian search:open query="project" # Open search view
Tasks
obsidian tasks daily todo # Incomplete tasks in daily note
obsidian tasks todo # All incomplete tasks
obsidian task daily line=3 toggle # Toggle task at line 3
obsidian task ref="Note.md:5" done # Mark a specific task done
Tags & Properties
obsidian tags counts # List tags with counts
obsidian tags counts sort=count # Sort by frequency
obsidian tag name="#status" verbose # Files containing a tag
obsidian property:set name="status" value="done" file="Note"
obsidian property:read name="status" file="Note"
obsidian property:remove name="status" file="Note"
obsidian properties file="Note" # List all properties
Links
obsidian backlinks file="Note" # Incoming links
obsidian links file="Note" # Outgoing links
obsidian orphans # Files with no incoming links
obsidian deadends # Files with no outgoing links
obsidian unresolved # Broken links
Developer
obsidian devtools # Toggle Electron dev tools
obsidian eval code="app.vault.getFiles().length" # Run JavaScript in app context
obsidian dev:screenshot path=screenshot.png # Take a screenshot
obsidian dev:console limit=20 level=error # Show captured console messages
obsidian dev:errors # Show captured errors
obsidian dev:dom selector=".workspace" # Query DOM
obsidian dev:css selector=".mod-header" # Inspect CSS source
obsidian dev:cdp method="Page.reload" # Run a CDP command
obsidian plugin:reload id=my-plugin # Reload a plugin
All Commands (95 total)
Verified against
obsidian-cli helpoutput. Plugin-specific commands (Sync, Publish, etc.) only appear when those plugins are enabled — runobsidian-cli helpagain after enabling a plugin to see its commands.
General (4)
help- Show help / help for a specific commandversion- Show Obsidian versionreload- Reload the vaultrestart- Restart the app
Daily Notes (5)
daily- Open daily notedaily:path- Get daily note pathdaily:read- Read daily note contentsdaily:append- Append content to daily notedaily:prepend- Prepend content to daily note
Files & Folders (12)
file- Show file infofiles- List files in vaultfolder- Show folder infofolders- List folders in vaultopen- Open a filecreate- Create a new fileread- Read file contentsappend- Append content to a fileprepend- Prepend content to a filemove- Move or rename a filerename- Rename a filedelete- Delete a file
Search (3)
search- Search vault for textsearch:context- Search with matching line contextsearch:open- Open search view
Tasks (2)
tasks- List tasks in the vaulttask- Show or update a task
Tags (2)
tags- List tags in the vaulttag- Get tag info
Properties (4)
properties- List properties in the vaultproperty:set- Set a property on a fileproperty:remove- Remove a property from a fileproperty:read- Read a property value
Aliases (1)
aliases- List aliases in the vault
Links (5)
backlinks- List backlinks to a filelinks- List outgoing links from a fileunresolved- List unresolved linksorphans- Files with no incoming linksdeadends- Files with no outgoing links
Outline (1)
outline- Show headings for a file
Bookmarks (2)
bookmarks- List bookmarksbookmark- Add a bookmark
Bases / Database (4)
bases- List all base filesbase:views- List views in a basebase:create- Create a new item in a basebase:query- Query a base and return results
Templates (3)
templates- List templatestemplate:read- Read template contenttemplate:insert- Insert template into active file
Commands & Hotkeys (4)
commands- List available command IDscommand- Execute an Obsidian command by IDhotkeys- List hotkeyshotkey- Get hotkey for a command
Tabs & Workspace (3)
tabs- List open tabstab:open- Open a new tabworkspace- Show workspace tree
File History & Diff (6)
diff- List or diff local/sync versionshistory- List file history versionshistory:list- List files with historyhistory:read- Read a file history versionhistory:restore- Restore a file history versionhistory:open- Open file recovery
Recents (1)
recents- List recently opened files
Word Count (1)
wordcount- Count words and characters
Random Notes (2)
random- Open a random noterandom:read- Read a random note
Vault (2)
vault- Show vault infovaults- List known vaults
Themes & Snippets (9)
themes- List installed themestheme- Show active theme or get infotheme:set- Set active themetheme:install- Install a community themetheme:uninstall- Uninstall a themesnippets- List installed CSS snippetssnippets:enabled- List enabled CSS snippetssnippet:enable- Enable a CSS snippetsnippet:disable- Disable a CSS snippet
Plugins (9)
plugins- List installed pluginsplugins:enabled- List enabled pluginsplugins:restrict- Toggle or check restricted modeplugin- Get plugin infoplugin:enable- Enable a pluginplugin:disable- Disable a pluginplugin:install- Install a community pluginplugin:uninstall- Uninstall a community pluginplugin:reload- Reload a plugin
Developer (10)
devtools- Toggle Electron dev toolseval- Execute JavaScript and return resultdev:screenshot- Take a screenshotdev:console- Show captured console messagesdev:errors- Show captured errorsdev:css- Inspect CSS with source locationsdev:dom- Query DOM elementsdev:cdp- Run a Chrome DevTools Protocol commanddev:debug- Attach/detach Chrome DevTools Protocol debuggerdev:mobile- Toggle mobile emulation
Troubleshooting
"Cannot connect to Obsidian"
- Ensure Obsidian is running
- Enable CLI in Settings → General → Command line interface
"Command not found: obsidian"
- Follow Setup above for your platform
- Verify the symlink:
- macOS:
ls -l /usr/local/bin/obsidian - Linux:
ls -l ~/.local/bin/obsidian
- macOS:
Commands broke right after an Obsidian update
- The CLI binary changes between releases — re-create the symlink:
Or toggle CLI off → on in Settings → General to let Obsidian re-register.sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidian
"File not found"
file=Nameresolves like wikilinks (no path, no.md)path=folder/file.mdfor exact paths
Chinese description
Prerequisites
- Obsidian 1.12+ (1.12.7+ recommended)
- Obsidian must be running
- Enable CLI: Settings → General → Command line interface
Platform configuration
macOS: CLI registration will create a symlink at /usr/local/bin/obsidian pointing to /Applications/Obsidian.app/Contents/MacOS/obsidian-cli。
⚠️ Pitfall: the symlink will become invalid after upgrading Obsidian. The binary file changes with every version update. The fastest fix:
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/obsidian-cli /usr/local/bin/obsidianOr go to Settings → General, turn CLI off and on again to let Obsidian re-register.
Windows: Registration will place Obsidian.com(terminal redirector) into the installation directory and add it to PATH; it requiresrestarting the terminalto take effect.
Linux: Copy the binary to ~/.local/bin/obsidian, and make sure that directory is in PATH.
Common commands
obsidian daily # 打开今日日记
obsidian create name="笔记" # 创建笔记
obsidian search query="关键词" # 搜索,只显示文件名
obsidian search:context query="关键词" # 搜索,显示文件名以及内容所在的行
obsidian tasks daily todo # 列出未完成任务
obsidian tags counts # 列出标签