Category: Linux

How to enter ASCII control characters with your keyboard

close photo of a macbook pro keyboard

How to enter ASCII control characters?

Entering ASCII control characters depends on the specific keyboard layout and operating system you are using. Here’s a general guide for Linux, Windows, and macOS:

Linux

In most Linux terminals, you can enter ASCII control characters using the keys Ctrl + Shift + u in combination with a letter or symbol. For example:

  • Ctrl + Shift + u and then 0 + 1: ASCII code 0x01 (Start of Heading)
  • Ctrl + Shift + u and then 0 + 2: ASCII code 0x02 (Start of Text)
  • Ctrl + Shift + u and then 0 + 3: ASCII code 0x03 (End of Text)
  • And so on…

Windows

In the Windows operating system, you can use the following steps:

  1. For characters with ASCII values 0 to 31, you can typically enter them using the Alt key and the numeric keypad. For example, to enter ASCII 0x01, press Alt + 0 + 0 + 1.
  2. For some characters, you can use the Windows Character Map utility. Press the Win key + R to open the Run dialog, type charmap, and press Enter. Select the desired character and copy/paste it.

macOS

On macOS, you can use the following steps:

  1. Character Viewer: Press Control + Command + Space to open the Character Viewer. Search for the desired control character and insert it into your document.

Note that you may have to go to the dots menu at top left and select Customize to add the Unicode category. The Unicode category is under Code Tables.

Note: The availability of these methods may vary depending on your keyboard layout and the specific software you are using. If you’re using a specific text editor or terminal, it might have its own way of entering control characters.

What are ASCII control characters?

ASCII control characters are special characters in the ASCII (American Standard Code for Information Interchange) character encoding scheme that are used to control peripheral devices such as printers and teletypewriters. They are non-printable characters and typically have specific functions rather than representing printable symbols like letters or numbers.

Here is a list of some commonly used ASCII control characters along with their decimal and hexadecimal values:

Control CharacterASCII DezimalASCII HEXDescription
NUL000null character
SOH101start of header
STX202start of text
ETX303end of text
EOT404end of transmission
ENQ505enquiry
ACK606acknowledge
BEL707bell (ring)
BS808backspace
HT909horizontal tab
LF100Aline feed
VT110Bvertical tab
FF120Cform feed
CR130Dcarriage return
SO140Eshift out
SI150Fshift in
DLE1610data link escape
DC11711device control 1
DC21812device control 2
DC31913device control 3
DC42014device control 4
NAK2115negative acknowledge
SYN2216synchronize
ETB2317end transmission block
CAN2418cancel
EM2519end of medium
SUB261Asubstitute
ESC271Bescape
FS281Cfile separator
GS291Dgroup separator
RS301Erecord separator
US311Funit separator
   
DEL1277Fdelete (rubout)

Foto von Jess Bailey auf Unsplash

 

Ping server on a specific port

Terminal

You can’t ping ports, as Ping is using ICMP which doesn’t have the concept of ports. Ports belong to the transport layer protocols like TCP and UDP. However, you could use nmap to see whether ports are open or not:

nmap -p 80 example.com

The output will look like this:

nmap -p 80 google.de
Starting Nmap 7.92 ( https://nmap.org ) at 2021-12-08 10:59 CET
Nmap scan report for google.de (142.250.185.131)
Host is up (0.017s latency).
rDNS record for 142.250.185.131: fra16s50-in-f3.1e100.net

PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds

Source: https://serverfault.com/questions/309357/ping-a-specific-port

 

CUDART Error in Singularity Container Workaround

Singularity is a Linux container system similar (and compatible to) Docker. It’s advantage over Docker is that is was designed to allow users without superuser privileges to run containers within their environment. I recently encountered the following error when running a Nvidia CUDA application within a Singularity container using “singularity run -nv <container>:

CUDART: cudaGetDeviceCount(&deviceCount); = 999 (unknown error)

Workaround: After running /usr/local/cuda/samples/1_Utilities/deviceQuery/deviceQuery outside of the container, the CUDA application within the container ran without any problem.

Fix/Solution: TODO

Finding the NUMA Node of a Nvidia CUDA GPU in Linux

For some applications it might be useful to pin their CPU processes to the NUMA node which is connected to the GPU. To find out which GPU is located at which NUMA node one can use the following script:

for i in $(nvidia-smi -x -q | grep "gpu id" | awk -F "\"" '{print $2}' | awk -F ":" '{print "0000:"  $2 ":"  $3}' | tr '[:upper:]' '[:lower:]'); do echo $i; cat "/sys/bus/pci/devices/$i/numa_node"; done

Pinning the CPU process to the right NUMA node can speed up your application significantly on all Nvidia GPUs like the double precision HPC GPUs Tesla V100, A100 and A10, the professional Quadro RTX GPUs as well as all CUDA capable GeForce GPUs.

How to set C, C++ or Fortran compiler for CMake

To use a different compiler (e.g. Intel Compiler, CLANG or PGI) or a different version then CMake uses by default, one can either set environment variables or modify
the CMakeLists.txt file.

CMake evaluates the environment variables CC for the C compiler, CXX for the C++ compiler and FC
for the Fortran compiler:

CC=/path/to/icc cmake ..
CXX=/path/to/icpc cmake ..
FC=/path/to/ifort cmake ..

For a more permanent solution, one can also edit the CMakeLists.txt file:

SET(CMAKE_C_COMPILER /path/to/pgcc)
SET(CMAKE_CXX_COMPILER /path/to/pgc++)
SET(CMAKE_FC_COMPILER /path/to/pgfortran)

BTW: The environment variables LDFLAGS, CFLAGS, CXXFLAGS or FFLAGS are also evaluated by CMake.

SPACK and Intel Parallel Studio: “error while loading shared libraries: libimf.so”

Spack is a package manager for supercomputers, Linux, and macOS. It makes installing scientific software easy. With Spack, you can build a package with multiple versions, configurations, platforms, and compilers, and all of these builds can coexist on the same machine.

However, when using the Intel Compiler as compiler, I got the following error for some packages:

error while loading shared libraries: libimf.so: cannot open shared object file: No such file or directory

To solve this, edit your ~/.spack/linux/compilers.yaml file and set the extra_rpaths to your Intel Compiler libraries directory:

- compiler:
    environment: {}
    extra_rpaths: [/opt/intel/compilers_and_libraries_2018.1.163/linux/compiler/lib/intel64/]
    flags: {}
    modules: []
    operating_system: centos7
    paths:
      cc: /opt/intel/compilers_and_libraries_2018.1.163/linux/bin/intel64/icc
      cxx: /opt/intel/compilers_and_libraries_2018.1.163/linux/bin/intel64/icpc
      f77: /opt/intel/compilers_and_libraries_2018.1.163/linux/bin/intel64/ifort
      fc: /opt/intel/compilers_and_libraries_2018.1.163/linux/bin/intel64/ifort
    spec: intel@18.0.1
    target: x86_64

Terminal: Größe eines Verzeichnisses ausgeben

Um die Größe eines Verzeichnisses unter macOS im Terminal auszugeben, kann man den Befehl du verwenden. Hier ist ein Beispiel, wie man die Größe eines Verzeichnisses ausgeben lässt:

du -hsc /path/to/directory

Das -s-Option gibt die zusammengefasste Größe aller Unterverzeichnisse aus, während das -h-Option die Größe in einer lesbaren Form (z.B. KB, MB, GB) ausgibt.

Oder ein Beispiel für alle Verzeichnisse im aktuellen Pfad:

du -hsc .