Difference between revisions of "Terminal cheat sheet"

From postmarketOS
Jump to navigation Jump to search
(links to pkgs.postmarketos/alpine: make them shorter; remove "as both repositories are added to postmarketOS installations", it's slightly inaccurate (more than two repos) and should be self explaining in this context)
(talk about "apk fix")
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
  
 
<source lang="shell-session">
 
<source lang="shell-session">
$ apk add vim
+
$ sudo apk add neovim
 
</source>
 
</source>
  
Line 16: Line 16:
  
 
<source lang="shell-session">
 
<source lang="shell-session">
$ apk del vim
+
$ sudo apk del neovim
 
</source>
 
</source>
  
Line 22: Line 22:
  
 
<source lang="shell-session">
 
<source lang="shell-session">
$ apk upgrade -a
+
$ sudo apk upgrade -a
 +
</source>
 +
 
 +
Run various package repair strategies, e.g. running failed installation scripts again:
 +
 
 +
<source lang="shell-session">
 +
$ sudo apk fix
 +
$ sudo apk fix name-of-package  # will also reinstall name-of-package
 
</source>
 
</source>
  
Line 29: Line 36:
 
<source lang="shell-session">
 
<source lang="shell-session">
 
$ apk info -vv
 
$ apk info -vv
 +
</source>
 +
 +
Installing build dependencies:
 +
 +
<source lang="shell-session">
 +
$ sudo apk add build-base install-makedepends
 +
$ install-makedepends neovim
 
</source>
 
</source>
  
Line 39: Line 53:
 
<source lang="shell-session">
 
<source lang="shell-session">
 
$ service networkmanager status
 
$ service networkmanager status
$ service networkmanager start
+
$ sudo service networkmanager start
$ service networkmanager stop
+
$ sudo service networkmanager stop
$ service networkmanager restart
+
$ sudo service networkmanager restart
 
</source>
 
</source>
  
Line 62: Line 76:
  
 
Start NetworkManager on boot (in the default runlevel)
 
Start NetworkManager on boot (in the default runlevel)
$ rc-update add networkmanager default
+
$ sudo rc-update add networkmanager default
  
 
Stop NetworkManager starting on boot
 
Stop NetworkManager starting on boot
$ rc-update del networkmanager default
+
$ sudo rc-update del networkmanager default
 
</source>
 
</source>
  
Line 82: Line 96:
 
the man-pages package will add the pages for core software like chmod but also linux headers
 
the man-pages package will add the pages for core software like chmod but also linux headers
 
the docs package is a metapackage that pulls in the -doc package for everything you install
 
the docs package is a metapackage that pulls in the -doc package for everything you install
$ apk add mandoc man-apropos man-pages docs
+
$ sudo apk add mandoc mandoc-apropos man-pages docs
$ man vim
+
$ man nvim
 
</source>
 
</source>
  
Line 92: Line 106:
 
<source lang="shell-session">
 
<source lang="shell-session">
 
pick your favorite shell
 
pick your favorite shell
$ apk add bash zsh fish dash yash oksh elvish
+
$ sudo apk add bash zsh fish dash yash oksh elvish
  
 
set your login shell
 
set your login shell
Line 98: Line 112:
  
 
some config distributions are packaged
 
some config distributions are packaged
$ apk add grml-zsh-config oh-my-zsh
+
$ sudo apk add grml-zsh-config oh-my-zsh
 
</source>
 
</source>

Latest revision as of 20:26, 8 September 2021

Here's a small reference for working with postmarketOS/Alpine Linux.

Package management

The package manager in postmarketOS is called apk, the Alpine Package Keeper. The list of packages can be found at pkgs.alpinelinux.org and pkgs.postmarketos.org.

Installing a package

$ sudo apk add neovim

Uninstalling a package

$ sudo apk del neovim

Upgrading the system. The -a option allows downgrading packages to what's available in the repository. This is sometimes needed when packages are moved from a git version to a stable release.

$ sudo apk upgrade -a

Run various package repair strategies, e.g. running failed installation scripts again:

$ sudo apk fix
$ sudo apk fix name-of-package  # will also reinstall name-of-package

Listing installed package versions (add | grep package-name to filter for a specific package):

$ apk info -vv

Installing build dependencies:

$ sudo apk add build-base install-makedepends
$ install-makedepends neovim

The repositories are stored in /etc/apk/repositories as one repository url per line. There's also /etc/apk/world which is a list of packages that are explicitly installed. It's possible to add/remove packages from this list and then running apk fix to apply those changes. The Alpine Linux wiki has a page comparing apk to other popular distros, with many helpful examples.

Service management

The service manager in postmarketOS is OpenRC. The basic service management is done with the familiar service command.

$ service networkmanager status
$ sudo service networkmanager start
$ sudo service networkmanager stop
$ sudo service networkmanager restart

To enable or disable services on boot you use the rc-update command.

List the services that are added to a runlevel
$ rc-update
             bootmisc | boot                                   
              chronyd |      default                           
                 dbus |      default                           
                devfs |                                 sysinit
                dmesg |                                 sysinit
                  gdm |      default                           
              haveged |      default                           
             hostname | boot                                   
              hwclock | boot                                   
            killprocs |                        shutdown        


Start NetworkManager on boot (in the default runlevel)
$ sudo rc-update add networkmanager default

Stop NetworkManager starting on boot
$ sudo rc-update del networkmanager default

Log files

By default postmarketOS uses the busybox logging daemon for the syslog and it's configured to log to memory only. The logread command is used to read the in-memory log. Writing standard output and standard error of a system service to the filesystem can be achieved by setting output_log and error_log to file paths in its service script, as described in the manual page openrc-run.

Man pages

Man pages are not installed by default and are seperate from the normal packages. The docs package is a metapackage that will pull in all the documentation for the software you have installed. You can also install only the documentation you need by not installing the docs package but installing the specific documentation subpackage. For example for vim documentation you can install vim-doc

the mandoc package is the man page reader itself
the man-apropos adds the apropos manpage search tool
the man-pages package will add the pages for core software like chmod but also linux headers
the docs package is a metapackage that pulls in the -doc package for everything you install
$ sudo apk add mandoc mandoc-apropos man-pages docs
$ man nvim

Changing your shell

Since the pmos installations are based on busybox the default shell is ash, which is comparible to sh. There are multiple shells packaged in Alpine if you want something better:

pick your favorite shell
$ sudo apk add bash zsh fish dash yash oksh elvish

set your login shell
$ chsh -s /bin/zsh

some config distributions are packaged
$ sudo apk add grml-zsh-config oh-my-zsh