Linux - HsuJv/Note GitHub Wiki

Content

  1. Content
  2. Network
    1. Static IP
      1. Modify the interface file
      2. Restart the internet modular
    2. PPPoE server
      1. Install PPPoE
      2. Configure PPPoE
      3. Configure ip tables
      4. Run PPPoE server
      5. Shutdown the server
      6. View the logs
      7. PPP State Transition Table
    3. SS-Server
    4. BBR
    5. Chaos network testing
      1. Tools
      2. Preparing
      3. Obstructing
      4. External accessing
    6. L2TP Server
    7. Dump Hex Packet
  3. Glibc Memory Management
  4. GUI explorer
  5. Samba
  6. Auth
    1. Sudo without a password
    2. Mutliple ssh keys
    3. SSH Login
  7. Open A Swap
    1. Try to use swap more
  8. Videos
  9. Archives
  10. Shell
    1. String
  11. Setup a Local Only SMTP Email Server (Linux, Unix, Mac)
    1. 1 - Point localhost.com to your machine
    2. 2 - Install Postfix
    3. 3 - Configure Postfix to Local only
    4. 4 - Configure a Catch-all Address
    5. 5 - Install Thunderbird
    6. 6 - Configure Thunderbird
    7. 7 - Start your Mail Spool file
  12. GDB
  13. Partition
    1. Extend LVM

Network

Static IP

Modify the interface file

  • vim /etc/network/interface

    auto interface_name
    iface interface_name inet static
    address xxx.xxx.xxx.xxx
    netmask xxx.xxx.xxx.xxx
    gateway xxx.xxxx.xxx.xxx
    dns-nameservers xxx.xxx.xxx.xxx
    
  • For ubuntu 18

    • vim /etc/systemd/resolved.conf
    • Uncomment the line #DNS=
    • And configure your own dns
    • Reboot it
  • For those auto turn to 127.0.0.53

    • sudo apt install resolvconf
    • vim /etc/resolvconf/resolv.conf.d/tail
    • add nameserver xxx.xxx.xxx.xxx

Restart the internet modular

  • sudo /etc/init.d/networking restart

PPPoE server

Install PPPoE

  • sudo apt-cache search pppoe
  • sudo apt install pppoe
  • pppoe-server -h to make sure it is installed successfully.

Configure PPPoE

  • cd /etc/ppp

  • sudo vim options

    • set ms-dns to distribute a valid DNS server to a Microsoft host
    • comment +pap, uncomment -pap to not use pap for authentication, uncomment +chap to use chap for authentication
  • sudo vim chap-secrets

    • type in testing * password * at the end of the file. Which means create an account with credentials testing/password, for any server name(first star) and any ip(second star).
  • sudo vim pppoe-server-options (create one if does not exist)

    • type in
    auth
    require-chap
    logfile /var/log/pppd.log
    
  • All configuration is done

Configure ip tables

  • sudo vim /etc/sysctl.conf

    • uncomment net.ipv4.ip_forward=1 to turn on ip forward on this host
    • run sysctl -p to take effect
  • sudo iptables -A POSTROUTING -t nat -s 10.10.10.0/24 -j MASQUERADE

    • -s arguement specifies the network which should be SNAT
    • -j MASQUERADE means the sourse ip after SNAT should be this host itself
    • All SNAT should be added to POSTROUTING list while DNAT to PREROUTING list.

Run PPPoE server

  • sudo pppoe-server -I wlan0 -L 10.10.10.1 -R 10.10.10.100 -N 100 -S service_name -s -k
    • -I argument specifies the interface bounds to PPPoE server
    • -L argument specifies the PPPoE server's IP
    • -R argument specifies the distributed IPs
    • -N argument specifies the scale of IP pool
    • -S argument specifies the service_name for client to connect

Shutdown the server

  • killall pppoe-server

View the logs

  • journalctl --boot /usr/bin/pppd --follow

PPP State Transition Table

State 0 1 2 3 4 5 6 7 8 9
Events Initial Starting Closed Stopped Closing Stopping Req-Sent Ack-Rcvd Ack-Sent Opened
Up 2 irc,scr/6 - - - - - - - -
Down - - 0 tls/1 0 1 1 1 1 tld/1
Open tls/1 1 irc,scr/6 3r 5r 5r 6 7 8 9r
Close 0 tlf/0 2 2 4 4 irc,str/4 irc,str/4 irc,str/4 tld,irc,str/4
TO+ - - - - str/4 str/5 scr/6 scr/6 scr/8 -
TO- - - - - tlf/2 tlf/3 tlf/3p tlf/3p tlf/3p -
RCR+ - - sta/2 irc,scr,sca/8 4 5 sca/8 sca,tlu/9 sca/8 tld,scr,sca/8
RCR- - - sta/2 irc,scr,scn/6 4 5 scn/6 scn/7 scn/6 tld,scr,scn/6
RCA - - sta/2 sta/3 4 5 irc/7 scr/6x irc,tlu/9 tld,scr/6x
RCN - - sta/2 sta/3 4 5 irc,scr/6 scr/6x irc,scr/8 tld,scr/6x
RTR - - sta/2 sta/3 sta/4 sta/5 sta/6 sta/6 sta/6 tld,zrc,sta/5
RTA - - 2 3 tlf/2 tlf/3 6 6 8 tld,scr/6
RUC - - scj/2 scj/3 scj/4 scj/5 scj/6 scj/7 scj/8 scj/9
RXJ+ - - 2 3 4 5 6 6 8 9
RXJ- - - tlf/2 tlf/3 tlf/2 tlf/3 tlf/3 tlf/3 tlf/3 tld,irc,str/5
RXR - - 2 3 4 5 6 7 8 ser/9

SS-Server

BBR

  • Modify the env:

    echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
    echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
  • Make it effective: sysctl -p

  • To see if it works:

    # sysctl net.ipv4.tcp_available_congestion_control
    net.ipv4.tcp_available_congestion_control = bbr cubic reno
    
    # lsmod | grep bbr
    tcp_bbr                20480  1

Chaos network testing

Tools

  • pumba(only works on docker traffic)

Preparing

  1. run a Linux docker:
    • docker run --rm --privileged -it ubuntu bash
    • the docker0 ip: 172.17.0.1
    • the docker's ip: 172.17.0.3
  2. turn on ip forward:
  3. Add a fake ip for routing (e.g. 10.103.1.178):
    • route add 10.103.1.178/32 gw 172.17.0.3
  4. Add DNAT and SNAT in docker:(we are going to connect to 10.103.229.178)
    • d-nat: iptables -t nat -A PREROUTING -d 10.103.1.178 -j DNAT --to-destination 10.103.229.178
    • s-nat: iptables -A POSTROUTING -t nat -s 172.17.0.1/32 -j MASQUERADE

Obstructing

  • On host, run this command: sudo pumba --interval 20s netem --duration 15s --tc-image gaiadocker/iproute2 delay --distribution normal --time 1000 --jitter 300 loss --percent 80 --correlation 0 duplicate --percent 80 --correlation 0 corrupt --percent 50 --correlation 0 (docker_name)

External accessing

  • if we are using another host, and we wants to use this docker as a route:
    • this host ip: 10.103.14.253
    • the ohter host ip: 10.103.14.149
    1. add route rules on the other host: route add 10.103.1.178/32 gw 10.103.14.253
    2. Add forwarding rule on this host: sudo iptables -A FORWARD -t filter -s 10.103.14.149 -i eno1 -o docker0 -j ACCEPT
    3. Add s-nat on this host: sudo iptables -A POSTROUTING -t nat -s 10.103.14.149 -j MASQUERADE

L2TP Server

  • install the required app: apt install xl2tpd
  • backup the default config: mv /etc/xl2tpd/xl2tpd.conf /etc/xl2tpd/xl2tpd.conf.bak
  • edit our config: vim /etc/xl2tpd/xl2tpd.conf
[global]
ipsec saref = no

[lns default]
ip range = 100.0.0.128-100.0.0.255
local ip = 100.0.0.10
require chap = yes
require authentication = yes
ppp debug = yes
pppoptfile =/etc/ppp/options.xl2tpd
length bit = yes
  • config auth info and DNS: vim /etc/ppp/options.xl2tpd
require-chap #or pap
ms-dns 10.102.1.60
lcp-echo-interval 10
lcp-echo-failure 3
auth
  • add user: see How PPPoE does

  • reboot, start the server: /etc/init.d/xl2tpd start

  • add snat: iptables -t nat -A POSTROUTING -s 100.0.0.128/25 -j MASQUERADE

Dump Hex Packet

  • sed s/[[:space:]]//g [hexfile] | xxd -r -p - | od -Ax -tx1 | text2pcap -l 101 -o hex - - | tshark -r -

  • sed s/[[:space:]]//g - | xxd -r -p - | od -Ax -tx1 | text2pcap -l 101 -o hex - - | tshark -r -

Glibc Memory Management

/*
  This struct declaration is misleading (but accurate and necessary).
  It declares a "view" into memory allowing access to necessary
  fields at known offsets from a given base. See explanation below.
*/
struct malloc_chunk {
  INTERNAL_SIZE_T      mchunk_prev_size;  /* Size of previous chunk (if free).  */
  INTERNAL_SIZE_T      mchunk_size;       /* Size in bytes, including overhead. */
  struct malloc_chunk* fd;         /* double links -- used only if free. */
  struct malloc_chunk* bk;
  /* Only used for large blocks: pointer to next larger size.  */
  struct malloc_chunk* fd_nextsize; /* double links -- used only if free. */
  struct malloc_chunk* bk_nextsize;
};
/*
   malloc_chunk details:
    (The following includes lightly edited explanations by Colin Plumb.)
    Chunks of memory are maintained using a `boundary tag' method as
    described in e.g., Knuth or Standish.  (See the paper by Paul
    Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a
    survey of such techniques.)  Sizes of free chunks are stored both
    in the front of each chunk and at the end.  This makes
    consolidating fragmented chunks into bigger chunks very fast.  The
    size fields also hold bits representing whether chunks are free or
    in use.
    An allocated chunk looks like this:
    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of previous chunk, if unallocated (P clear)  |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of chunk, in bytes                     |A|M|P|
      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             User data starts here...                          .
            .                                                               .
            .             (malloc_usable_size() bytes)                      .
            .                                                               |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             (size of chunk, but used for application data)    |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of next chunk, in bytes                |A|0|1|
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    Where "chunk" is the front of the chunk for the purpose of most of
    the malloc code, but "mem" is the pointer that is returned to the
    user.  "Nextchunk" is the beginning of the next contiguous chunk.
    Chunks always begin on even word boundaries, so the mem portion
    (which is returned to the user) is also on an even word boundary, and
    thus at least double-word aligned.
    Free chunks are stored in circular doubly-linked lists, and look like this:
    chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of previous chunk, if unallocated (P clear)  |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `head:' |             Size of chunk, in bytes                     |A|0|P|
      mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Forward pointer to next chunk in list             |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Back pointer to previous chunk in list            |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Unused space (may be 0 bytes long)                .
            .                                                               .
            .                                                               |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    `foot:' |             Size of chunk, in bytes                           |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of next chunk, in bytes                |A|0|0|
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    The P (PREV_INUSE) bit, stored in the unused low-order bit of the
    chunk size (which is always a multiple of two words), is an in-use
    bit for the *previous* chunk.  If that bit is *clear*, then the
    word before the current chunk size contains the previous chunk
    size, and can be used to find the front of the previous chunk.
    The very first chunk allocated always has this bit set,
    preventing access to non-existent (or non-owned) memory. If
    prev_inuse is set for any given chunk, then you CANNOT determine
    the size of the previous chunk, and might even get a memory
    addressing fault when trying to do so.
    The A (NON_MAIN_ARENA) bit is cleared for chunks on the initial,
    main arena, described by the main_arena variable.  When additional
    threads are spawned, each thread receives its own arena (up to a
    configurable limit, after which arenas are reused for multiple
    threads), and the chunks in these arenas have the A bit set.  To
    find the arena for a chunk on such a non-main arena, heap_for_ptr
    performs a bit mask operation and indirection through the ar_ptr
    member of the per-heap header heap_info (see arena.c).
    Note that the `foot' of the current chunk is actually represented
    as the prev_size of the NEXT chunk. This makes it easier to
    deal with alignments etc but can be very confusing when trying
    to extend or adapt this code.
    The three exceptions to all this are:
     1. The special chunk `top' doesn't bother using the
        trailing size field since there is no next contiguous chunk
        that would have to index off it. After initialization, `top'
        is forced to always exist.  If it would become less than
        MINSIZE bytes long, it is replenished.
     2. Chunks allocated via mmap, which have the second-lowest-order
        bit M (IS_MMAPPED) set in their size fields.  Because they are
        allocated one-by-one, each must contain its own trailing size
        field.  If the M bit is set, the other bits are ignored
        (because mmapped chunks are neither in an arena, nor adjacent
        to a freed chunk).  The M bit is also used for chunks which
        originally came from a dumped heap via malloc_set_state in
        hooks.c.
     3. Chunks in fastbins are treated as allocated chunks from the
        point of view of the chunk allocator.  They are consolidated
        with their neighbors only in bulk, in malloc_consolidate.
*/

GUI explorer

  • nautilus .

Samba

  • sudo smbpasswd -a my_user_name

    • Add a samba user with the same name of my ubuntu user
  • Map the HOME directory

    • sudo vim /etc/samba/smb.conf
    • Navigate to line 190
    • uncomment corresponding lines.
  • sudo services smbd restart

Auth

Sudo without a password

  • try visudo and add line username ALL=(ALL) NOPASSWD:ALL at the end

Mutliple ssh keys

  • Method one

    • generate ssh keys: ssh-keygen -t rsa -C "[email protected]"
      • First input the file name, for default, it is id_rsa
      • Then input the password to use this private key, the pwd can be left blank.
    • ssh-agent bash
    • ssh-add private_key_file_name
    • There will be hint:

    Identity add: id_rsa

  • Method two

    • vim ~/.ssh/config
    Host xxx.com
    HostName xxx.com
    User username
    IdentityFile ~/.ssh/private_key_file_name
    
    • For those do not have a domain name
    Host alias
    HostName ip
    Port 22(for most)
    User username
    IdentityFile ~/.ssh/private_key_file_name
    PreferredAuthentications publickey(can be "publickey", "password", or "publickey, password")
    
  • Test

SSH Login

  • on client:

    1. ssh-keygen, see Mutliple ssh keys
    2. ssh-copy-id user@server or cat ~/.ssh/id_rsa.pub | ssh user@server "cat >> ~/.ssh/authorized_keys"
  • on server:

    1. ps -e | grep ssh
    2. apt-get install openssh-client
    3. apt-get install openssh-server
    4. service ssh start or /etc/init.d/ssh start
    5. service ssh stop or /etc/init.d/ssh stop
    6. use the command before if needed.
  • add autorized_keys

    • ssh-copy-id user@ip

    • sudo vim /etc/ssh/sshd_config and uncomment line 40(AuthorizedKeysFile .ssh/authorized_keys)

    • For SELinux only:

      • Plugin sshd_root (91.4 confidence) suggests:

      If you want to allow sshd to have read access on the authorized_keys file Then you must fix the labels. Do: sbin/restorecon -Rv /root/.ssh

      • Plugin catchall (9.59 confidence) suggests:

      If you believe that sshd should be allowed read access on the authorized_keys file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: $ grep sshd /var/log/audit/audit.log | audit2allow -M mypol $ semodule -i mypol.pp

    • For those Authentication refused: bad ownership or modes for directory /home/user

      • The directory /home/user needs to be 755 or 700
      • The directory /home/user/.ssh needs to be 755 or 700
      • The file /home/user/.ssh/authorized_keys needs to be 644 or 600

Open A Swap

ip-172-25-1-10 sonicos # df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p9   63G   16G   44G  27% /

ip-172-25-1-10 sonicos # sudo fallocate -l 10G /swapfile

ip-172-25-1-10 sonicos # sudo chmod 600 /swapfile

ip-172-25-1-10 sonicos # sudo mkswap /swapfile
Setting up swapspace version 1, size = 10 GiB (10737414144 bytes)
no label, UUID=abeba46f-9bf2-4861-80eb-e07bf88ad6fc

ip-172-25-1-10 sonicos # sudo swapon /swapfile

ip-172-25-1-10 sonicos # free -h
             total       used       free     shared    buffers     cached
Mem:          7.5G       7.3G       118M        16M       1.6M        76M
-/+ buffers/cache:       7.3G       196M
Swap:           9G        14M         9G
  • Make the Swap File Permanent

    1. Our recent changes have enabled the swap file for the current session. However, if we reboot, the server will not retain the swap settings automatically. We can change this by adding the swap file to our /etc/fstab file.
    2. Back up the /etc/fstab file in case anything goes wrong: see command 2
    3. You can add the swap file information to the end of your /etc/fstab file by typing: see command 3
    comm 2: sudo cp /etc/fstab /etc/fstab.bak
    
    comm 3: echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Try to use swap more

  • sudo sh -c " echo 100 > /proc/sys/vm/swappiness "

Videos

  • extract frames using ffmpeg:
    1. for i in {start..end} ; do ffmpeg -accurate_seek -ss $i -i input.mp4 -frames:v 1 period_down_$i.bmp ; done
      • the start and end should be the seconds or the unix time format (HOURS:MM:SS.MILLISECONDS) of the whole video

Archives

  • Extracting special file:
    • Confirm the path to the file: tar tzvf ~/../backup/my_backup@2020-07+05.tgz | grep commented
    • Extracting: tar xzvf ~/../backup/my_backup@2020-07+05.tgz /home/jiaxu/fstack/commented

Shell

String

#*_:     从左边开始,去第一个符号“_”左边的所有字符                                        *代表要删除的字符
% _*:   从右边开始,去掉第一个符号“_”右边的所有字符
##*_:   从右边开始,去掉第一个符号“_”左边的所有字符
%%_*: 从左边开始,去掉第一个符号“_”右边的所有字符

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

Fedora/CentOS/RHEL: sudo yum install postfix

Ubuntu: sudo apt-get install postfix

MacOSX: Postfix is already installed by default.

3 - Configure Postfix to Local only

  • During postfix install process, the configure text dialog will display five options:

    General type of mail configuration: 
    
    No configuration
    Internet Site
    Internet with smarthost
    Satellite system
    Local only
    
  • Select "Local Only".

  • For the domain name, use the default suggested and finish the install.

4 - Configure a Catch-all Address

Enabling this, you can use any email address ending with "@localhost" or "@localhost.com".

Example: here, my unique account is [email protected]. But while testing systems, I can use any address like [email protected], [email protected], etc, because all will be redirected to [email protected]

  • If not exists, create file /etc/postfix/virtual: sudo nano /etc/postfix/virtual
  • Add the following 2 lines content, replacing <your-user> with your Unix user account:
@localhost <your-user>
@localhost.com <your-user>
  • Save and close the file.
  • Configure postifx to read this file:
    • Open /etc/postfix/main.cf: sudo nano /etc/postfix/main.cf
    • And check if this line is enabled, or add it if not exists: virtual_alias_maps = hash:/etc/postfix/virtual
  • Activate it: sudo postmap /etc/postfix/virtual
  • Reload postfix: sudo systemctl restart postfix
  • If you're under non systemd distro, like Ubuntu 14.04, service restart command probably is: sudo service postfix reload

5 - Install Thunderbird

Ubuntu: sudo apt-get install thunderbird

6 - Configure Thunderbird

  • Skip the welcome screen (click in the button to use existing accounts);
  • Click in the Settings button at top right (similar to Chrome settings) then click on Preferences > Account Settings
  • Under Account Actions choose "Add Other Account"
  • Select "Unix Mailspool (Movemail)"
  • Your account will be <your-user>@localhost (of course, replace <your-user> with your user account). Don't use <your-user>@(none), use <your-user>@localhost
  • Ingoing and Outgoing server will be: localhost
  • Restart (close and reopen) Thunderbird.

7 - Start your Mail Spool file

  • This step have two purposes: test your install and stop the Unable to locate mail spool file. message.
  • Using Thunderbird, send new email to <your-user>@localhost, replacing <your-user> with your user account
  • Click on "Get Mail"
  • Test catch-all: send new email to averagejoe@localhost
  • Click on "Get Mail" and you'll see the message at Inbox.

GDB

Name Value Default Event
SIGHUP 1 Exit Hangup (see termio(7I))
SIGINT 2 Exit Interrupt (see termio(7I))
SIGQUIT 3 Core Quit (see termio(7I))
SIGILL 4 Core Illegal Instruction
SIGTRAP 5 Core Trace or Breakpoint Trap
SIGABRT 6 Core Abort
SIGEMT 7 Core Emulation Trap
SIGFPE 8 Core Arithmetic Exception
SIGKILL 9 Exit Killed
SIGBUS 10 Core Bus Error
SIGSEGV 11 Core Segmentation Fault
SIGSYS 12 Core Bad System Call
SIGPIPE 13 Exit Broken Pipe
SIGALRM 14 Exit Alarm Clock
SIGTERM 15 Exit Terminated
SIGUSR1 16 Exit User Signal 1
SIGUSR2 17 Exit User Signal 2
SIGCHLD 18 Ignore Child Status Changed
SIGPWR 19 Ignore Power Fail or Restart
SIGWINCH 20 Ignore Window Size Change
SIGURG 21 Ignore Urgent Socket Condition
SIGPOLL 22 Exit Pollable Event (see streamio(7I))
SIGSTOP 23 Stop Stopped (signal)
SIGTSTP 24 Stop Stopped (user) (see termio(7I))
SIGCONT 25 Ignore Continued
SIGTTIN 26 Stop Stopped (tty input) (see termio(7I))
SIGTTOU 27 Stop Stopped (tty output) (see termio(7I))
SIGVTALRM 28 Exit Virtual Timer Expired
SIGPROF 29 Exit Profiling Timer Expired
SIGXCPU 30 Core CPU time limit exceeded (see getrlimit(2))
SIGXFSZ 31 Core File size limit exceeded (see getrlimit(2))
SIGWAITING 32 Ignore Reserved
SIGLWP 33 Ignore Reserved
SIGFREEZE 34 Ignore Check point Freeze
SIGTHAW 35 Ignore Check point Thaw
SIGCANCEL 36 Ignore Reserved for threading support
SIGLOST 37 Exit Resource lost (for example, record–lock lost)
SIGXRES 38 Ignore Resource control exceeded (see setrctl(2))
SIGJVM1 39 Ignore Reserved for Java Virtual Machine 1
SIGJVM2 40 Ignore Reserved for Java Virtual Machine 2
SIGRTMIN * Exit First real time signal
(SIGRTMIN+1) * Exit Second real time signal
. . .
(SIGRTMAX-1) * Exit Second-to-last real time signal
SIGRTMAX * Exit Last real time signal
#define __SI_KILL        0
#define __SI_TIMER        0
#define __SI_POLL        0
#define __SI_FAULT        0
#define __SI_CHLD        0
#define __SI_RT                0
#define __SI_MESGQ        0
#define __SI_CODE(T,N)        (N)

/*
 * si_code values
 * Digital reserves positive values for kernel-generated signals.
 */
#define SI_USER                0                /* sent by kill, sigsend, raise */
#define SI_KERNEL        0x80                /* sent by the kernel from somewhere */
#define SI_QUEUE        -1                /* sent by sigqueue */
#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */
#define SI_ASYNCIO        -4                /* sent by AIO completion */
#define SI_SIGIO        -5                /* sent by queued SIGIO */
#define SI_TKILL        -6                /* sent by tkill system call */
#define SI_DETHREAD        -7                /* sent by execve() killing subsidiary threads */

#define SI_FROMUSER(siptr)        ((siptr)->si_code <= 0)
#define SI_FROMKERNEL(siptr)        ((siptr)->si_code > 0)

/*
 * SIGILL si_codes
 */
#define ILL_ILLOPC        (__SI_FAULT|1)        /* illegal opcode */
#define ILL_ILLOPN        (__SI_FAULT|2)        /* illegal operand */
#define ILL_ILLADR        (__SI_FAULT|3)        /* illegal addressing mode */
#define ILL_ILLTRP        (__SI_FAULT|4)        /* illegal trap */
#define ILL_PRVOPC        (__SI_FAULT|5)        /* privileged opcode */
#define ILL_PRVREG        (__SI_FAULT|6)        /* privileged register */
#define ILL_COPROC        (__SI_FAULT|7)        /* coprocessor error */
#define ILL_BADSTK        (__SI_FAULT|8)        /* internal stack error */
#define NSIGILL                8

/*
 * SIGFPE si_codes
 */
#define FPE_INTDIV        (__SI_FAULT|1)        /* integer divide by zero */
#define FPE_INTOVF        (__SI_FAULT|2)        /* integer overflow */
#define FPE_FLTDIV        (__SI_FAULT|3)        /* floating point divide by zero */
#define FPE_FLTOVF        (__SI_FAULT|4)        /* floating point overflow */
#define FPE_FLTUND        (__SI_FAULT|5)        /* floating point underflow */
#define FPE_FLTRES        (__SI_FAULT|6)        /* floating point inexact result */
#define FPE_FLTINV        (__SI_FAULT|7)        /* floating point invalid operation */
#define FPE_FLTSUB        (__SI_FAULT|8)        /* subscript out of range */
#define NSIGFPE                8

/*
 * SIGSEGV si_codes
 */
#define SEGV_MAPERR        (__SI_FAULT|1)        /* address not mapped to object */
#define SEGV_ACCERR        (__SI_FAULT|2)        /* invalid permissions for mapped object */
#define NSIGSEGV        2

/*
 * SIGBUS si_codes
 */
#define BUS_ADRALN        (__SI_FAULT|1)        /* invalid address alignment */
#define BUS_ADRERR        (__SI_FAULT|2)        /* non-existant physical address */
#define BUS_OBJERR        (__SI_FAULT|3)        /* object specific hardware error */
/* hardware memory error consumed on a machine check: action required */
#define BUS_MCEERR_AR        (__SI_FAULT|4)
/* hardware memory error detected in process but not consumed: action optional*/
#define BUS_MCEERR_AO        (__SI_FAULT|5)
#define NSIGBUS                5

/*
 * SIGTRAP si_codes
 */
#define TRAP_BRKPT        (__SI_FAULT|1)        /* process breakpoint */
#define TRAP_TRACE        (__SI_FAULT|2)        /* process trace trap */
#define TRAP_BRANCH     (__SI_FAULT|3)  /* process taken branch trap */
#define TRAP_HWBKPT     (__SI_FAULT|4)  /* hardware breakpoint/watchpoint */
#define NSIGTRAP        4

/*
 * SIGCHLD si_codes
 */
#define CLD_EXITED        (__SI_CHLD|1)        /* child has exited */
#define CLD_KILLED        (__SI_CHLD|2)        /* child was killed */
#define CLD_DUMPED        (__SI_CHLD|3)        /* child terminated abnormally */
#define CLD_TRAPPED        (__SI_CHLD|4)        /* traced child has trapped */
#define CLD_STOPPED        (__SI_CHLD|5)        /* child has stopped */
#define CLD_CONTINUED        (__SI_CHLD|6)        /* stopped child has continued */
#define NSIGCHLD        6

/*
 * SIGPOLL si_codes
 */
#define POLL_IN                (__SI_POLL|1)        /* data input available */
#define POLL_OUT        (__SI_POLL|2)        /* output buffers available */
#define POLL_MSG        (__SI_POLL|3)        /* input message available */
#define POLL_ERR        (__SI_POLL|4)        /* i/o error */
#define POLL_PRI        (__SI_POLL|5)        /* high priority input available */
#define POLL_HUP        (__SI_POLL|6)        /* device disconnected */
#define NSIGPOLL        6

/*
 * sigevent definitions
 * 
 * It seems likely that SIGEV_THREAD will have to be handled from 
 * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
 * thread manager then catches and does the appropriate nonsense.
 * However, everything is written out here so as to not get lost.
 */
#define SIGEV_SIGNAL        0        /* notify via signal */
#define SIGEV_NONE        1        /* other notification: meaningless */
#define SIGEV_THREAD        2        /* deliver via thread creation */
#define SIGEV_THREAD_ID 4        /* deliver to thread */
info inferior: get process id
struct pthread*: the struct of thread info
thread_globals: odp threads

Partition

Extend LVM

  1. create new partition by fdisk /dev/sda (n, t, lvm, w), assume the name is /dev/sda3

  2. pvcreate /dev/sda3

  3. vgdisplay to see VG Name : debian-vg

  4. vgextend debian-vg /dev/sda3

  5. lvdisplay to see volume LV Name: LV Path /dev/debian-vg/root

  6. lvextend -l +100%FREE /dev/debian-vg/root

  7. resize2fs /dev/mapper/debian--vg-root

  8. df -h, lsblk to check result

⚠️ **GitHub.com Fallback** ⚠️