Skip to main content

45 posts tagged with "linux"

View All Tags

· 3 min read
Pamparau Sebastian

This was tested on Debian 10, running KDE.

I bought the following headphones: Coocheer ANC8.

I wanted to use them on a desktop machine running Debian 10 with KDE. Here's what I did:

  1. Since my desktop environment had not bluetooth capabilities, I bought the following Bluetooth USB Adapter: TP-Link UB400. Inserting it in one of the USB ports of my machine, KDE detected it instantly and activated the bluetooth capability.

After this single step, I could see my headphones on the list of available bluetooth devices but got the following error when trying to connect to it (seen in journalctl)

a2dp-sink profile connect failed for 30:21:07:9D:72:05: Protocol not available

· One min read
Hreniuc Cristian-Alexandru


You can achieve it in two steps:

1) You need to start nc with a named pipe (fifo) as its input:

mkfifo /tmp/fifoIn; cat /tmp/fifoIn | nc localhost 2222 &

2) Send your data from file input.txt, line by line with 2 sec delay:

cat input.txt | while read line; do echo $line; sleep 2; done > /tmp/fifoIn

I've tested it with this "server" (I'm using openbsd netcat syntax):

nc -l localhost 2222

If you don't want the new-line char after every line use echo -n instead of echo.

· One min read
Hreniuc Cristian-Alexandru

Build project with : -fsanitize=address -fsanitize-recover=address

Run the excutable with this enviroment variable: ASAN_OPTIONS=halt_on_error=0. Source:


ASAN_OPTIONS=halt_on_error=0 ./executable

When the address sanitizer will find a problem, it will not abort the execution of the exe as it ussualy does.

· One min read
Hreniuc Cristian-Alexandru

Where are the coredumps generated?

$ cat /proc/sys/kernel/core_pattern


Before running your executable, set the limit for the coredump:

$ ulimit -c unlimited

You can add ulimit -n 99999 in your ~/.bashrc. But if you want all gui apps(qtcreator) to use it, you should also include it in your ~/.xsession:


ulimit -n 99999

You mai also need to update the limits(only if setting the limit returns error):

sudo nano /etc/security/limits.conf

* hard nofile 99999

# --------------------

sudo nano /etc/pam.d/common-session

session required

· 4 min read
Hreniuc Cristian-Alexandru

There is a tutorial here

Install filebeat:
curl -L -O
tar xzvf filebeat-6.5.4-linux-x86_64.tar.gz

Create the config file:

- type: log
enabled: true
- /mnt/projects/log_investigation/*.log
# Multiline log, it starts with: 2019-09-25 11:55:30.378|
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\|'
multiline.negate: true
multiline.match: after
# Just in case multiple apps are using the same logstash.
fields: server_app

#----------------------------- Logstash output --------------------------------
# Listen for logstash
hosts: [""]

Test the config file:

filebeat test config -c filebeat.yml

Start filebeat:

filebeat run -c filebeat.yml


Config file:

input {
# Filebeat port
beats {
port => 5044

filter {
grok {
# Patterns for ndc and thread
patterns_dir => ["./patterns"]
# Regex
match => { "message" => "%{TIMESTAMP_ISO8601:log_time}\|%{ISO8601_TIMEZONE:server_timezone}\|%{TZ:server_tz}\|%{HOSTNAME:server_hostname}\|%{WORD:app_name}\|%{LOGLEVEL:log_level}\|%{NDC:ndc}\|(?<logger>[A-Za-z0-9$_.]+)\|%{THREAD:thread}\|%{NUMBER:message_size}\|%{GREEDYDATA:message_logged}" }
# ndc will become an array:
kv {
# This works with values like this: "key1=value key2=value", it doesn't support "key" like we have for query.
source => "ndc"
target => "ndc_context"
# You will be able to access them like this: [ndc_context][username]"
# "ndc_context" => {
# "interface" => "client",
# "ke2" => "value",
# "username" => "chreniuc"
# },

# Convert to UTC(Logs may come from different servers with different timezones)
mutate {
add_field => [ "log_time_tz", "%{log_time} %{server_timezone}" ]
date {
# log_time_tz looks like this: 2019-09-25 11:55:30.378 -0500
match => [ "log_time_tz" , "yyyy-MM-dd HH:mm:ss.SSS Z" ]
target =>["log_time_tz"]
timezone => "UTC"

# Get the date in this format: dd-mm-yyyy(We will use this for the log file name)
# The log files will be per day
# Convert the date back to string.
convert => ["log_time_tz","string"]
# Extract the date
grok {
# Patterns for LOG_DATE
patterns_dir => ["./patterns"]
# 2019-10-02T21:09:45.290Z
match => { "log_time_tz" => "%{LOG_DATE:log_date}%{GREEDYDATA:ignored_log_date}" }

# We can remove the unwanted fields afterwards.
mutate {
remove_field => [ "log_time_tz" ]
remove_field => [ "ignored_log_date" ]
# We have the ndc context in "ndc_context" so we can avoid sending this forward.
remove_field => [ "ndc" ]

output {
# Print on console, just for debug purpose
stdout {
codec => rubydebug
# This is how you access nested fields
if ([ndc_context][username] != "") { # Centralise log files per user and per days from multiple servers.
file {
path => "/mnt/projects/log_investigation/out_put_logs/%{log_date}/%{[ndc_context][username]}.log"
codec => line { format => "%{message}"}


./patterns content:

NDC ([0-9A-Za-z=\+\-\s\_])*

THREAD 0x[0-8a-f]+

LOG_DATE [0-9]{4}\-[0-9]{2}\-[0-9]{2}

Start logstash:

logstash -f logstash.conf

Test it:

echo '2019-09-25 11:55:30.378|-0500|CST|server|server_app|INFO|interface=client|request_response|0x7f7461f38700|295|Message' >> file.log

# Multiline:

printf '2019-09-25 11:55:30.378|-0500|CST|server|server_app|INFO|interface=client username=username key2=value query|request_response|0x7f7461f38700|295|Message\ndada\ndas\n' >> file.log

The output of logstash should be:

"host" => {
"name" => "chreniuc-sv"
"input" => {
"type" => "log"
"thread" => "0x7f7461f38700",
"fields" => {
"app" => {
"name" => "server_app"
"logger" => "request_response",
"@timestamp" => 2019-10-02T22:41:40.464Z,
"tags" => [
[0] "beats_input_codec_plain_applied"
"message_logged" => "Message\ndada\ndas",
"log_time" => "2019-09-25 11:55:30.378",
"app_name" => "server_app",
"offset" => 6490,
"@version" => "1",
"server_timezone" => "-0500",
"server_hostname" => "server",
"log_date" => "2019-09-25",
"beat" => {
"name" => "chreniuc",
"hostname" => "chreniuc",
"version" => "6.5.4"
"log" => {
"flags" => [
[0] "multiline"
"prospector" => {
"type" => "log"
"server_tz" => "CST",
"message_size" => "295",
"message" => "2019-09-25 11:55:30.378|-0500|CST|server|app|INFO|interface=client username=username key2=value query|request_response|0x7f7461f38700|295|Message\n
"source" => "/mnt/projects/log_investigation/file.log",
"log_level" => "INFO",
"ndc_context" => {
"username" => "username",
"key2" => "value",
"interface" => "client"


· One min read
Hreniuc Cristian-Alexandru

As root user:

cd /mnt
mkdir mount_folder

sshfs -o allow_other user@ip:/remote_folder /mnt/mount_folder/

# -o allow_other -> Needed so every user can see the folder.

· One min read
Hreniuc Cristian-Alexandru


If you need to connect remote to a PC and download something via torrent you need to do these steps:

Install transmission-daemon:

apt-get install transmission-daemon

This will install and start the service: transmission-daemon.

If you want to check it's status you can run:

systemctl status transmission-daemon

This will start a service and a web interface to acces the torrent client. This client will be at: ip:9091/transmission.

If you open that url, it will ask a user and password, by default these are:transmission:transmission.

If you want to change something, ex: the username, password, port; you can edit the settings file: /etc/transmission-daemon/settings.json. But before stop the deamon:

systemctl stop transmission-daemon
# After edit, start the daemon
systemctl start transmission-daemon

By default the download_dir is set to /var/lib/transmission-daemon/downloads you can change it to any value.

For username and password for the web interface: rpc-username and rpc-password(put it in plain, it will be hashed automatically after daemon starts).

If you want to access this interface from remote, you can do a tunnel via ssh:

ssh -L user@pc

· 2 min read
Hreniuc Cristian-Alexandru

Here is the source.

Activate WOL in bios:

First, reboot the remote server and go to BIOS > Power Management > “Wake On LAN”. Turn it on. Next, save and close the bios.

Install ethtool:

apt-get install ethtool


ethtool -s enp9s0 wol g
# ethtool -s <interface> wol g

Check if enabled:

ethtool enp9s0
# ethtool <interface>
# Output:

Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: Symmetric
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: MII
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes

The most important thins is to check these two lines(g should be present):

Supports Wake-on: pumbg
Wake-on: g

You should also make it run at boot-up. Add this is /etc/rc.local:


ethtool -s enp9s0 wol g

exit 0

Then make that file executable:

chmod +x /etc/rc.local

Reboot and check if you get Wake-on: g.

To access it from Internet, add a port forwarding in your router settings, to port 9 (UDP) on your PC.

Example if my PC has the ip and the external port(from the router is 999) it will look like this:

public_ip:999 UDP -> UDP.

Turn your pc from linux pc:

apt-get install wakeonlan
wakeonlan -i IP -p PORT MAC

From android.