wiki/cards/linux.org
2021-05-12 14:29:55 +08:00

4.4 KiB

Anki: Linux

Finding devices

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

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

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

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 Nix and Guix package manager. Here's how to integrate installed Nix packages into the desktop.

XDG_DATA_DIRS=$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}

Flatpak permissions

Front

What permissions does user-installed Flatpak apps have by default?

Back

By default, they have none. 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.

# 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}

The basics of Flatpak apps

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

Front

How to change user shell in most Linux distros?

Back

chsh

Printing a list

Front

Give some ways to print a list.

Back

# 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 ;;"
foo
bar
baz ;;
foo
bar
baz ;;
foo
bar
baz ;;

systemd timestamp example

Front

What is *-*-8/4 in systemd calendar format?

Back

Every 4 days, starting from the 8th of the month.

Assuming this was executed on 2021-05-12.

systemd-analyze calendar *-*-8/4
  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