Tag Archives: linux

UTF encoding

Code point range UTF-8 UTF-16
hexadecimal binary Bytes
(code bits)
binary hexadecimal Bytes
(code bits)
binary hexadecimal
00 00 00
00 00 7F
0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0111 1111
1
(7)
0xxx xxxx 00
7F
2
(16)
xxxx xxxx xxxx xxxx 00 00
FF FF
00 00 80
00 07 FF
0000 0000 0000 0000 1000 0000
0000 0000 0000 0111 1111 1111
2
(11)
110x xxxx
10xx xxxx
C2 80
DF BF
00 08 00
00 FF FF
0000 0000 0000 1000 0000 0000
0000 0000 1111 1111 1111 1111
3
(16)
1110 xxxx
10xx xxxx
10xx xxxx
E0 A0 80
EF BF BF
01 00 00
10 FF FF
0000 0001 0000 0000 0000 0000
0001 0000 1111 1111 1111 1111
4
(21)
1111 0xxx
10xx xxxx
10xx xxxx
10xx xxxx
F0 90 80 80
F4 8F BF BF
4
(20)
1101 10xx xxxx xxxx
1101 11xx xxxx xxxx
D8 00 DC 00
DB FF DF FF

Test Jumbo Frames / MTU 9000

Linux:

ping -M do -s 8972 xxx.xxx.xxx.xxx

OSX/BSD:

ping -D -s 8184 xxx.xxx.xxx.xxx

Windows:

ping -f -l 9000 xxx.xxx.xxx.xxx

Example results on Linux

If you’ve forgotten to enable jumbo frames/9k MTU on your client device you’re sending the ping from:

PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes
ping: sendto: Message too long

If you have enabled jumbo frames on your client but not the destination (or a switch in between):

PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes
Request timeout for icmp_seq 0

If you’ve done everything righ:

PING xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx): 8184 data bytes
8192 bytes from xxx.xxx.xxx.xxx: icmp_seq=0 ttl=128 time=0.714 ms

WebDAV with cURL

Assuming the following Data:

  • Webdav URL: http://example.com/webdav
  • Username: user
  • Password: pass

Actions

Reading Files/Folders

curl 'http://example.com/webdav'

Creating new Folder

curl -X MKCOL 'http://example.com/webdav/new_folder'

Uploading File

curl -T '/path/to/local/file.txt' 'http://example.com/webdav/test/new_name.txt'

Renaming File

curl -X MOVE --header 'Destination:http://example.org/webdav/new.txt' 'http://example.com/webdav/old.txt'

Deleting Files/Folders

File:

curl -X DELETE 'http://example.com/webdav/test.txt'

Folder:

curl -X DELETE 'http://example.com/webdav/test'

List Files in a Folder

curl -i -X PROPFIND http://example.com/webdav/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
<a:prop><a:resourcetype/></a:prop>
</a:propfind>
end

Continue reading WebDAV with cURL

Mount disk image partition

View partition table of disk.img:

fdisk -lu disk.img
Disk disk.img: 1.3 GiB, 1361051648 bytes, 2658304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6f92008e

Device    Boot  Start     End Sectors  Size Id Type
disk.img1        8192  131071  122880   60M  c W95 FAT32 (LBA)
disk.img2      131072 2658303 2527232  1.2G 83 Linux

Mount partition by using start multiplied by sector size as offset

mount -o loop,offset=$((131072 * 512))

Tmux on login

to start tmux on login add the following to your ~/.bashrc

# Start Tmux by default
# If not running interactively, do not do anything
if command -v tmux>/dev/null; then
  [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi

Auto attach

to automatically attach to last session or create a new if none available extend your ~/.bashrc and ~/.tmux.conf with the following

~/.bashrc

# Start Tmux by default
# If not running interactively, do not do anything
if command -v tmux>/dev/null; then
  [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux attach
fi

~/.tmux.conf

# if run as "tmux attach", create a session if one does not already exist
new-session -n $HOST

Continue reading Tmux on login