mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 01:57:54 +00:00
63 lines
22 KiB
HTML
63 lines
22 KiB
HTML
<!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: [ ['$','$'], ['\(','\)'] ],
|
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
|
},
|
|
options = {
|
|
processHtmlClass = "math"
|
|
}
|
|
}
|
|
</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're just subcommands except appearing as options.
|
|
</p><pre class="src-block"><code class="language-shell"># Rather than 'pacman install podman' or something similar.
|
|
pacman -S podman
|
|
</code></pre><p>Here'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'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 "Operations" 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's go ahead.
|
|
</p><h2 id="quickstart">Quickstart</h2><p>It's a package manager so it'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'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 "Package to install > " | 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 "Install package(s) > " \
|
|
| 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 "Remove installed package(s) > " | 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":{"className":["language-shell"]},"children":[{"type":"text","value":"# Rather than 'pacman install podman' or something similar.\npacman -S podman\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's what you can do with the package manager:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-S"}]},{"type":"text","value":" are concerned with syncing the local database to the remote databases.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-y, --refresh"}]},{"type":"text","value":" syncs the local database to the remote database; running with this flag alone is not recommended as the package manager will have problems.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-u, --sysupgrade"}]},{"type":"text","value":" upgrades the local database; this should be used with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-y"}]},{"type":"text","value":" if you intend it for a proper operating system upgrade.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-g, --groups [GROUP]"}]},{"type":"text","value":" prints what packages belong to the given group\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-Q"}]},{"type":"text","value":" 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.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-l, --list [PACKAGES...]"}]},{"type":"text","value":" lists the files associated with the package.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-i, --info [PACKAGES...]"}]},{"type":"text","value":" prints information about the package.\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-F [FILENAME]"}]},{"type":"text","value":" are mostly query-related operations with the database.\n It also prints which package owns the given file.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-y, --refresh"}]},{"type":"text","value":" refreshes the database.\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-R"}]},{"type":"text","value":" removes installed packages.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-n, --nosave"}]},{"type":"text","value":" removes the configuration files associated with the package; this doesn't remove files from the home directory, though.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"-s, --recursive"}]},{"type":"text","value":" will recursively removes dependencies that are not used anywhere else.\n"}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can see more of them in the \"Operations\" section of the manual page (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pacman.1"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Welp, this is what you came for so let's go ahead.\n"}]},{"type":"element","tagName":"h2","properties":{"id":"quickstart"},"children":[{"type":"text","value":"Quickstart"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It's a package manager so it's supposed to do basic package manager stuff.\nAll of the shown commands are in longform with the shortform just commented for practical purposes.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"# Search for a pacakge\n# pacman -Ss podman\npacman --sync --search podman\n\n# Install a package\n# pacman -S podman\npacman --sync podman\n\n# Uninstall a package\n# pacman -Rns podman\npacman --remove --no-save --recursive podman\n\n# Upgrade the system\n# pacman -Syu\npacman --sync --refresh --upgrade\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"package-search-selection"},"children":[{"type":"text","value":"Package search selection"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With everybody's favorite fuzzy finder, "},{"type":"element","tagName":"a","properties":{"href":"/cli.fzf"},"children":[{"type":"text","value":"fzf"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"pacman --sync --quiet --search pkg | fzf --prompt \"Package to install \u003e \" | xargs doas pacman --sync\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can also create a search selection with all of the packages with the following one-liner.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"pacman -S --list --quiet \\\n | fzf --multi --prompt \"Install package(s) \u003e \" \\\n | xargs doas pacman -S --noconfirm\n"}]}]},{"type":"element","tagName":"h2","properties":{"id":"package-removal-selection"},"children":[{"type":"text","value":"Package removal selection"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Another interactive script with "},{"type":"element","tagName":"a","properties":{"href":"/cli.fzf"},"children":[{"type":"text","value":"fzf"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"pacman -Q --native --quiet | fzf --multi --prompt \"Remove installed package(s) \u003e \" | xargs doas pacman -Rns --noconfirm\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"related-notes"},"children":[{"type":"text","value":"Related notes"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"pacman does not have a way to query packages that are not installed;\n for example, you cannot know what files are owned by the package unless it is installed (also you have "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"pkgfile"}]},{"type":"text","value":" for that)\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"pacman also cannot view the PKGBUILD of packages that are not installed;\n you can use the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"asp"}]},{"type":"text","value":" tool for that (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"asp show ${PACKAGE}"}]},{"type":"text","value":")\n"}]}]}]}]},"backlinks":[{"path":"/linux.distros.arch","title":"Arch Linux"}]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["cli.pacman"]},"buildId":"Ie9t5zutrXP6Of75Cb5xF","assetPrefix":"/wiki","nextExport":false,"isFallback":false,"gsp":true}</script><script nomodule="" src="/wiki/_next/static/chunks/polyfills-99d808df29361cf7ffb1.js"></script><script src="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" async=""></script><script src="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" async=""></script><script src="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" async=""></script><script src="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" async=""></script><script src="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" async=""></script><script src="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" async=""></script><script src="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_buildManifest.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_ssgManifest.js" async=""></script></body></html> |