wiki/cli.pacman.html

63 lines
22 KiB
HTML
Raw Permalink Normal View History

2022-07-29 15:41:17 +00:00
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Command line: pacman</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
MathJax = {
tex: {
inlineMath: [ [&#x27;$&#x27;,&#x27;$&#x27;], [&#x27;\(&#x27;,&#x27;\)&#x27;] ],
displayMath: [ [&#x27;$$&#x27;,&#x27;$$&#x27;], [&#x27;[&#x27;,&#x27;]&#x27;] ]
},
options = {
processHtmlClass = &quot;math&quot;
}
}
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Command line: pacman</h1><section class="post-metadata"><span>Date: <!-- -->2021-06-08 15:00:04 +08:00</span><span>Date modified: <!-- -->2021-11-06 12:12:06 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/cli.pacman#subcommands" class="toc-link toc-link-h1">Subcommands</a></li><li class="toc-item toc-item-h1"><a href="/wiki/cli.pacman#examples" class="toc-link toc-link-h1">Examples</a><ol class="toc-level toc-level-2"><li class="toc-item toc-item-h2"><a href="/wiki/cli.pacman#quickstart" class="toc-link toc-link-h2">Quickstart</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.pacman#package-search-selection" class="toc-link toc-link-h2">Package search selection</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.pacman#package-removal-selection" class="toc-link toc-link-h2">Package removal selection</a></li></ol></li><li class="toc-item toc-item-h1"><a href="/wiki/cli.pacman#related-notes" class="toc-link toc-link-h1">Related notes</a></li></ol></nav><p>The built-in package manager of Arch Linux (among others).
This note is based from <code class="inline-verbatim">pacman v6</code> and above.
</p><h1 id="subcommands">Subcommands</h1><p>Interestingly, pacman does not have subcommands with specific options.
Instead, they go with specific flags denoting a subcommand.
Practically, they&#x27;re just subcommands except appearing as options.
</p><pre class="src-block"><code class="language-shell"># Rather than &#x27;pacman install podman&#x27; or something similar.
pacman -S podman
</code></pre><p>Here&#x27;s what you can do with the package manager:
</p><ul><li><p><code class="inline-verbatim">-S</code> are concerned with syncing the local database to the remote databases.
</p><ul><li><p><code class="inline-verbatim">-y, --refresh</code> syncs the local database to the remote database; running with this flag alone is not recommended as the package manager will have problems.
</p></li><li><p><code class="inline-verbatim">-u, --sysupgrade</code> upgrades the local database; this should be used with <code class="inline-verbatim">-y</code> if you intend it for a proper operating system upgrade.
</p></li><li><p><code class="inline-verbatim">-g, --groups [GROUP]</code> prints what packages belong to the given group
</p></li></ul></li><li><p><code class="inline-verbatim">-Q</code> is primarily from querying information from your installed packages ranging from listing installed packages to listing all of the files owned by a certain package.
</p><ul><li><p><code class="inline-verbatim">-l, --list [PACKAGES...]</code> lists the files associated with the package.
</p></li><li><p><code class="inline-verbatim">-i, --info [PACKAGES...]</code> prints information about the package.
</p></li></ul></li><li><p><code class="inline-verbatim">-F [FILENAME]</code> are mostly query-related operations with the database.
It also prints which package owns the given file.
</p><ul><li><p><code class="inline-verbatim">-y, --refresh</code> refreshes the database.
</p></li></ul></li><li><p><code class="inline-verbatim">-R</code> removes installed packages.
</p><ul><li><p><code class="inline-verbatim">-n, --nosave</code> removes the configuration files associated with the package; this doesn&#x27;t remove files from the home directory, though.
</p></li><li><p><code class="inline-verbatim">-s, --recursive</code> will recursively removes dependencies that are not used anywhere else.
</p></li></ul></li></ul><p>You can see more of them in the &quot;Operations&quot; section of the manual page (i.e., <code class="inline-verbatim">pacman.1</code>).
</p><h1 id="examples">Examples</h1><p>Welp, this is what you came for so let&#x27;s go ahead.
</p><h2 id="quickstart">Quickstart</h2><p>It&#x27;s a package manager so it&#x27;s supposed to do basic package manager stuff.
All of the shown commands are in longform with the shortform just commented for practical purposes.
</p><pre class="src-block"><code class="language-shell"># Search for a pacakge
# pacman -Ss podman
pacman --sync --search podman
# Install a package
# pacman -S podman
pacman --sync podman
# Uninstall a package
# pacman -Rns podman
pacman --remove --no-save --recursive podman
# Upgrade the system
# pacman -Syu
pacman --sync --refresh --upgrade
</code></pre><h2 id="package-search-selection">Package search selection</h2><p>With everybody&#x27;s favorite fuzzy finder, <a href="/wiki/cli.fzf">fzf</a>.
</p><pre class="src-block"><code class="language-bash">pacman --sync --quiet --search pkg | fzf --prompt &quot;Package to install &gt; &quot; | xargs doas pacman --sync
</code></pre><p>You can also create a search selection with all of the packages with the following one-liner.
</p><pre class="src-block"><code class="language-bash">pacman -S --list --quiet \
| fzf --multi --prompt &quot;Install package(s) &gt; &quot; \
| xargs doas pacman -S --noconfirm
</code></pre><h2 id="package-removal-selection">Package removal selection</h2><p>Another interactive script with <a href="/wiki/cli.fzf">fzf</a>.
</p><pre class="src-block"><code class="language-bash">pacman -Q --native --quiet | fzf --multi --prompt &quot;Remove installed package(s) &gt; &quot; | xargs doas pacman -Rns --noconfirm
</code></pre><h1 id="related-notes">Related notes</h1><ul><li><p>pacman does not have a way to query packages that are not installed;
for example, you cannot know what files are owned by the package unless it is installed (also you have <code class="inline-verbatim">pkgfile</code> for that)
</p></li><li><p>pacman also cannot view the PKGBUILD of packages that are not installed;
you can use the <code class="inline-verbatim">asp</code> tool for that (i.e., <code class="inline-code">asp show ${PACKAGE}</code>)
</p></li></ul><section><h2>Backlinks</h2><ul><li><a href="/wiki/linux.distros.arch">Arch Linux</a></li></ul></section></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"\"2021-06-08 15:00:04 +08:00\"","date_modified":"\"2021-11-06 12:12:06 +08:00\"","language":"en","source":""},"title":"Command line: pacman","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.pacman#subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.pacman#examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"quickstart"},"children":[{"type":"text","value":"Quickstart"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.pacman#quickstart"},"children":[{"type":"text","value":"Quickstart"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"package-search-selection"},"children":[{"type":"text","value":"Package search selection"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.pacman#package-search-selection"},"children":[{"type":"text","value":"Package search selection"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"package-removal-selection"},"children":[{"type":"text","value":"Package removal selection"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.pacman#package-removal-selection"},"children":[{"type":"text","value":"Package removal selection"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"related-notes"},"children":[{"type":"text","value":"Related notes"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.pacman#related-notes"},"children":[{"type":"text","value":"Related notes"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The built-in package manager of Arch Linux (among others).\nThis note is based from "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pacman v6"}]},{"type":"text","value":" and above.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Interestingly, pacman does not have subcommands with specific options.\nInstead, they go with specific flags denoting a subcommand.\nPractically, they're just subcommands except appearing as options.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties"