$ nasm -f bin -o <output.bin|o> <input.s|asm>
Where -f
specifies the output format. Another option would be elf32
or
elf
.
$ nasm -f bin -o <output.bin|o> <input.s|asm>
Where -f
specifies the output format. Another option would be elf32
or
elf
.
Date created: 2024-10-02
https://stackoverflow.com/questions/1068650/using-awk-to-remove-the-byte-order-mark
# Removing BOM from all csv files in current directory:
sed -i '1 s/^\xef\xbb\xbf//' *.csv
Date created: 2024-10-02
Given an awk script script.awk
, an input file source.csv
, and an output
file target.js
, we can execute awk like the following:
$ awk -f script.awk ./source.csv > target.js
Date created: 2025-02-14
This allows for sed
to operate on multiline input, i.e. an entire file or
multiline console output. For those pesky times when you want to use it to
replace a new line symbol with a comma and a space for example.
sed ':a;N;$!ba;s/\n/ /g' file
- :a create a label 'a'
- N append the next line to the pattern space
- $! if not the last line, ba branch (go to) label 'a'
- s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
Date created: 2024-10-10
https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html
[Unit]
Description=Some service template
After=network.target # Means "start when network ready".
# Can be replaced with the name of some other service to wait for.
StartLimitIntervalSec=0
[Service]
Type=simple # One of simple, exec, forking, oneshot, dbus, notify, notify-reload, or idle.
Restart=always # One of always, on-failure, on-success, on-abnormal, on-watchdog, on-abort.
RestartSec=1 # Time to sleep before attempting a restart.
User=kblagoev # User to run service under.
ExecStart=/usr/bin/env php /path/to/server.php # The actual command to run.
[Install]
WantedBy=multi-user.target
To make use of it:
$ cp <some.service> /etc/systemd/system/<some.service>
$ systemctl start <some.service>
$ systemctl enable <some.service> # This will ensure automatic start on boot
By default, systemd
gives up restarting the service if it fails to start more
than 5 times within 10 seconds. This is defined in the following variables
[Unit]
StartLimitBurst=5
StartLimitIntervalSec=10
This is avoided by setting StartLimitIntervalSec=0
. This will assure systemd
attempts restarting forever. The idea is that, as long as
StartLimitIntervalSec
is less than RestartSec * StartLimitBurst
, the service
will be restarted indefinitely.
As an alternative, you can leave the default settings, and ask systemd to
restart your service if the start limit is reached, using
StartLimitAction=reboot
.
https://serverfault.com/questions/736624/systemd-service-automatic-restart-after-startlimitinterval
To have a service restart 3 times at 90 second intervals include the following lines in your systemd service file:
[Unit]
StartLimitIntervalSec=400
StartLimitBurst=3
[Service]
Restart=always
RestartSec=90
Date created: 2024-10-06
Ubuntu supports .deb
packages for installation. This allows to convert .rpm
packages into .deb
, and install them on Ubuntu.
sudo add-apt-repository universe #Add the Universe Repository
sudo apt-get update
sudo apt-get install alien #Install Alien package
sudo alien <name of package>.rpm #Convert .rpm package to .deb
sudo dpkg -i <name of package>.deb #Install the Converted Package
Or directly install .rpm
with alien:
sudo alien -i <name of package>.rpm #Install RPM Package Directly Onto the System on Ubuntu
Date created: 2024-09-23
https://stackoverflow.com/questions/57335266/how-to-untar-a-file
.tar.gz
tar -xzvf <filename.tar.gz>
tar -xzvf <filename.tar.gz> -C <output/dir>
Where,
Date created: 2024-09-23
https://stackoverflow.com/questions/57335266/how-to-untar-a-file
.tar.xz
tar -xjvf <filename.tar.xz>
tar -xjvf <filename.tar.xz> -C <output/dir>
Where,
Directly from the systemd documentation
A unit configuration file whose name ends in ".service" encodes information about a process controlled and supervised by systemd.
Below is an example of how I'd set one up
[Unit]
Description=Some service template
After=network.target # Means "start when network ready".
# Can be replaced with the name of some other service
# to wait for.
StartLimitIntervalSec=0
[Service]
Type=simple # One of simple, exec, forking, oneshot, dbus, notify,
# notify-reload, or idle.
Restart=always # One of always, on-failure, on-success, on-abnormal,
# on-watchdog, on-abort.
RestartSec=1 # Time to sleep before attempting a restart.
User=kblagoev # User to run service under.
ExecStart=/usr/bin/env node /path/to/server.js # The actual command to run.
[Install]
WantedBy=multi-user.target
To make use of it:
$ cp <some.service> /etc/systemd/system/<some.service>
$ systemctl start <some.service>
$ systemctl enable <some.service> # This will ensure automatic start on boot
By default, systemd
gives up restarting the service if it fails to start more than 5 times within 10 seconds. This is defined in the following variables
[Unit]
StartLimitBurst=5
StartLimitIntervalSec=10
This is avoided by setting StartLimitIntervalSec=0
. This will assure systemd attempts restarting forever. The idea is that, as long as StartLimitIntervalSec
is less than RestartSec * StartLimitBurst
, the service will be restarted indefinitely.
As an alternative, you can leave the default settings, and ask systemd to restart your service if the start limit is reached, using StartLimitAction=reboot
.
To have a service restart 3 times at 90 second intervals include the following lines in your systemd service file:
[Unit]
StartLimitIntervalSec=400
StartLimitBurst=3
[Service]
Restart=always
RestartSec=90