> For the complete documentation index, see [llms.txt](https://kchuene.gitbook.io/data-communication-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kchuene.gitbook.io/data-communication-project/troubleshooting.md).

# Troubleshooting

Commands to mostly help you troubleshoot configuration issues.

## Kali

**/usr/bin/nmap: 6: exec: /usr/lib/nmap/nmap: Operation not permitted**

The error occurs when trying to run `nmap` within the **Kali Linux Docker** container. Run the following command to resolve the issue.

{% code overflow="wrap" lineNumbers="true" %}

```
setcap cap_net_raw,cap_net_bind_service+eip /usr/lib/nmap/nmap
```

{% endcode %}

## SSH

**PasswordAuthentication set to "no" but not taking effect**

Configs inside `/etc/ssh/sshd_config.d/` take pre-emminence over the `/etc/ssh/sshd_config` because of the line&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```
Include /etc/ssh/sshd_config.d/*.conf
```

{% endcode %}

which appears at the beginning of `/etc/ssh/sshd_config` file. The `/etc/ssh/sshd_config` is not meant to be modified directly, rather make configuration changes in a custom `.conf` file inside the `/etc/ssh/sshd_config.d/` directory and they will take effect on a **First Match Rule** over those of `sshd_config` .

The following command can be used to see if your editions take effect

{% code overflow="wrap" lineNumbers="true" %}

```
sudo sshd -T | grep PasswordAuthentication
```

{% endcode %}

## General

**If no nano or vi (vim) text editor**

Use the `tee` command

{% code overflow="wrap" lineNumbers="true" %}

```
tee output.txt <<EOF
```

{% endcode %}

## Snapshots

**GUI**

{% code overflow="wrap" %}

```
sudo apt install timeshift
```

{% endcode %}

## Virtualbox

**Enable SSD Virtual Disk (Virtualbox)**

If your host is running on SSD. Have the guest machine see the virtual disk as a Solid State Drive

{% code overflow="wrap" lineNumbers="true" %}

```
VM > Settings > Storage > [Guest Name].vdi > Check Solid-state Drive
```

{% endcode %}

{% hint style="info" %}
Faster and more stable booting from what I noticed.&#x20;
{% endhint %}

**Issue of not having root or sudo access after Ubuntu Desktop installation**

Don't use **unattended installation** on **Virtualbox**, rather install Ubuntu manually. You should get the following message the first time you open the terminal.

```
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
```

**Create a new NAT Network adapter**

```
File > Tools > Network Manager > NAT Networks > Create
```

**Expanding an existing dynamic virtual disk**

In **Virtualbox**:

{% code overflow="wrap" lineNumbers="true" %}

```
File > Tools > Virtual Media Manager > (Select one) > Properties > Attributes
```

{% endcode %}

{% hint style="warning" %}
Make sure you expand the listed hard disk to also increase the size of nested disks, eg. **{xxxx-xxxx-xxx}.vdi** files and not just **Ubuntu-Dektop.vdi.** There is probably one **.vdi** file for every snapshot.
{% endhint %}

Have the OS use the available space by resizing the partition and filesystem

{% code overflow="wrap" lineNumbers="true" %}

```
# 1. Get filesystem size relative to available disk space
df -h /
lsblk

# 2. Resize partition number 3 (sda3) of disk sda
sudo parted /dev/sda
(parted) print free
(parted) resizepart 1 100%
(parted) quit

# 3. Resize filesystem (/ mounted on sda3) to size of partition (full size by default)
sudo resize2fs /dev/sda3

# 4. Verify
df -h /
lsblk
```

{% endcode %}

{% hint style="info" %}
When asked to "fix the GPT to use all of the space" enter "Fix".
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```
// Alternate command sequence
df -h /
lsblk
sudo parted /dev/sda print
sudo parted /dev/sda resizepart 3 100%
sudo resize2fs /dev/sda3
df -h
lsblk
```

{% endcode %}

## Network

**Monitor network traffic (communication) with tcpdump**

{% code overflow="wrap" lineNumbers="true" %}

```
tcpdump -i enp0s3 dst port 9880 or dst port 22
```

{% endcode %}

**View open ports**

```
ss -tlnp
```

**Restart a network interface**

```
sudo ip link set enp0s3 down
sudo ip link set enp0s3 up
```

## Host Services

**Check Configuration Loaded by Systemd Service**

```
systemctl cat wazuh-agent
```

**Check any service's status**

```
systemctl status service-name
```

**Check connection status to a specific port**

```
watch -n 1 'ss -tnp | grep :9880'
```

**View service logs after it failed**

```
journalctl -u wazuh-agent
```

**View service logs live**

```
journalctl -u wazuh-agent
```

## Docker Containers

**Attach to a container**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo docker attach my-container
```

{% endcode %}

**Clearing unused volumes (data left behind by removed applications)**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo docker volume prune -a
```

{% endcode %}

**View environment variables of a container (specifically useful to see $PATH and the like, ie. what commands in the container)**

{% code overflow="wrap" %}

```
sudo docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}'  my-container
```

{% endcode %}

**View open ports within distroless containers (uses host binaries)**

{% code overflow="wrap" %}

```
sudo docker inspect -f '{{.State.Pid}}' cowrie # Gets container PID
```

{% endcode %}

{% code overflow="wrap" %}

```
sudo nsenter -t 1353 -n ss -tlnp # Enter network (ss) namespace and run ss
```

{% endcode %}

**Check containers' statuses**

```
sudo docker ps
```

**Recreate images for services to reload env or changes to compose config**

```
sudo docker compose up --force-recreate
```

**View logs of a container**

```
sudo docker logs 84006cac987 # container-id
```

**Deleting unused containers**

```
sudo docker container ls -a
sudo docker container prune
```

**Attaching a shell to a container or running a command (useful for getting a view of the container filesystem)**

```
sudo docker exec -it mycontainer /bin/bash
sudo docker exec mycontainer ls -la /
```

## Miscellaneous

**Run a process in the background (since ubuntu server does not come with multi-window terminal)**

```
nc -lvp 9880 &
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kchuene.gitbook.io/data-communication-project/troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
