Linux Programming

TTY Terminal

How to set the keyboard layout

In a tty terminal, there isn’t a typical xorg xserver or wayland server to interpret inputs to the keyboard. Typically, in xorg, you would set this with setxkbmap, or just use a gui tool looking for region & language or just languages in the settings. But with tty you would use loadkeys. Since I touch type dvorak I would use the following command to load dvorak into the tty terminal:

sudo loadkeys dvorak

Linux Command Line

kill

When sending a signal to a prossess telling it to suspend and then a continue signal the process will then be running in the background if the process was running in a terminal.

If you know that there is only one process by the name that you are interested in you can use the following:

kill -s SIGTSTP $(pgrep <process-name>)
kill -s SIGCONT $(pgrep <process-name>)

Otherwise you will need to get the process id with pgrep or ps -Fe (=== ps aux)

Then the running process will need to be brought to the foreground of the terminal in order to send the typical CTRL-C interrupt signal to the process, terminating it. Or you can send a SIGINT are SIGTERM to the process itself with the kill command.

readelf

Displays useful information about ELF (executable) files.

  • --sections - This will display the sections found in the executable.
  • -w - Displays the contents of the DWARF debug sections in the file, if any are present.
  • -W - Don’t wrap output at 80 columns.
  • --notes - Displays the contents of the NOTE segments and/or sections, if any. (Build ID is stored here.)

strip

Discards symbols and other data from object files.

objcopy

Copy and translate object files.

Procedure for stripping out debug symbols

--only-keep-debug a.out a.out.dbg
--add-gnu-debug-link=a.out.dbg a.out

# simpler
cp a.out a.out.dbg && strip a.out

Linux Kernel

APIs

Kernel

io_uring

io_uring is an in-kernel, Linux kernel interface for providing submission and completion queue rings, which are shared between the kernel and userspace to avoid copies. It was merged in kernel version 5.1. The liburing userspace library can be used to interact with the kernel interface.