:PROPERTIES: :ID: b3049366-b5ce-4caa-881f-e76663df2e12 :END: #+title: Anki: Linux #+date: "2021-05-01 20:20:25 +08:00" #+date_modified: "2021-05-12 14:28:29 +08:00" #+language: en #+property: anki_deck Linux * Finding devices :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1619878728534 :END: ** Front How to list devices information? (I mean all sorts of devices.) ** Back - ~lspci~ lists PCI devices. - ~lsusb~ list USB-connected devices. - ~lsblk~ list the block devices which usually includes storage drives and such. * ~$PATH~ environment :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1619878774321 :END: ** Front How does a shell find the binaries? ** Back Most shell searches through the ~$PATH~ variable, a colon-delimited list of paths containing the binaries. * Testing systemd timestamps :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1619878774617 :END: ** Front How to test out systemd timestamps? ** Back ~systemd-analyze {calendar,timestamp,timespan}~ To know how the format (i.e., calendar, timestamp, and timespan) looks like, you can refer to ~man systemd.time.5~. * Enabling desktop integration :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620296263978 :END: ** Front How to make desktop environments recognize the desktop files? ** Back Most of the desktop environments and certain applications like Rofi refers to the ~XDG_DATA_DIRS~ environment variable, a list of colon-delimited paths similar to ~PATH~. This enables desktop integration with certain tools like [[https://nixos.org/][Nix]] and [[https://guix.gnu.org/][Guix]] package manager. Here's how to integrate installed Nix packages into the desktop. #+begin_src shell XDG_DATA_DIRS=$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share} #+end_src * Flatpak permissions :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620296265390 :END: ** Front What permissions does user-installed Flatpak apps have by default? ** Back By default, they have none. [[https://docs.flatpak.org/en/latest/sandbox-permissions.html][Among the default limitations]]: - They can only access their own runtime folder =$HOME/.var/app/${FLATPAK_APP_ID}=. - They cannot access the network. Some apps are installed with the request to allow the following permissions enabled (e.g., Zotero). If left with no permissions, you'll see in certain situations like a file browser dialog that the permissions is in effect. Below are some of the examples interacting with the permissions of an app. #+begin_src shell # Show the permissions of an app. flatpak permission-show ${FLATPAK_APP_ID} # Let the user-installed Flatpak app access the home directory. flatpak override --user --filesystem=home ${FLATPAK_APP_ID} #+end_src * The basics of Flatpak apps :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620296265848 :END: ** Front What is a Flatpak package? Does it have its own form of managing dependencies? ** Back A Flatpak package can either be a runtime or a standalone app. Runtimes are the basic dependencies of an application. Only select packages available as a runtime (e.g., Qt, GTK). Flatpak has its set of runtimes composed of system libraries to be used with the applications. Thus, it stays out of its way with the operating system's libraries. The developer can also bundle its own set of libraries. * Changing user shell :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620793135173 :END: ** Front How to change user shell in most Linux distros? ** Back ~chsh~ * Printing a list :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620793135476 :END: ** Front Give some ways to print a list. ** Back #+begin_src shell # Format the string. printf "%s\n" foo bar 'baz ;;' # Echo the string as-is. echo "foo bar baz ;;" # Print with escaped newlines. echo -e "foo\nbar\nbaz ;;" #+end_src #+results: : foo : bar : baz ;; : foo : bar : baz ;; : foo : bar : baz ;; * systemd timestamp example :PROPERTIES: :ANKI_NOTE_TYPE: Styled cards :ANKI_NOTE_ID: 1620793135853 :END: ** Front What is ~*-*-8/4~ in systemd calendar format? ** Back :PROPERTIES: :ID: a118fdec-8026-433b-9a58-b738183be7a2 :END: Every 4 days, starting from the 8th of the month. Assuming this was executed on 2021-05-12. #+begin_src shell systemd-analyze calendar *-*-8/4 #+end_src #+results: : Original form: *-*-8/4 : Normalized form: *-*-08/4 00:00:00 : Next elapse: Sun 2021-05-16 00:00:00 PST : (in UTC): Sat 2021-05-15 16:00:00 UTC : From now: 3 days left