2

My Debian 11 VPS is running now for about 2 weeks- and today I just wanted to analyse, why my traffic is ~70GiB (counted by bashtop). So somewhere in the net I read about nethogs, that this could help. So I installed it with my non-root, but sudo-grouped user.

sudo apt install nethogs

I couldn't run it.

So I switched to the root user with

su

It still didn't worked. So I just wanted to check the most important thing, the ufw.

ufw status

Output: command not found


So ...

  1. ufw is installed
  2. but it works if I execute it from the full path with

/usr/sbin/ufw status

But I want to know also, if the incoming traffic is really blocked by default until now:

/usr/sbin/ufw status verbose

Output: ERROR: problem running sysctl

Something is really fcked up ... I don't know why? The last thing I did 2 weeks ago was installing kuma-uptime with the kuma_install.sh After that I didn't tried ufw. So. my $PATH seems to be not working correct- even as the root user.

I'm not an expert, but this is how my bashrc file looks like (from the root user):

# ~/.bashrc: executed by bash(1) for non-login shells.

Note: PS1 and umask are already set in /etc/profile. You should not

need this unless you want different defaults for root.

PS1='${debian_chroot:+($debian_chroot)}\h:\w$ '

umask 022

You may uncomment the following lines if you want `ls' to be colorized:

export LS_OPTIONS='--color=auto'

eval "dircolors"

alias ls='ls $LS_OPTIONS'

alias ll='ls $LS_OPTIONS -l'

alias l='ls $LS_OPTIONS -lA'

Some more alias to avoid making mistakes:

alias rm='rm -i'

alias cp='cp -i'

alias mv='mv -i'

and the .profile file:

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fi

mesg n 2> /dev/null || true

and this is the path to ufw:

ufw: /usr/sbin/ufw /etc/ufw /lib/ufw /usr/share/ufw /usr/share/man/man8/ufw.8.gz

and that is my echo $PATH:

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin

Hope this is enought and someone could help me please, you're my last hope. Otherwise I have to switch to ubuntu, maybe ubuntu behaves better. I hope, I can solve the problem with your help. It would be great, if someone could tell more or less what I have exactly to do now.

1 Answers1

7

This is an expected behavior in Debian.

nethogs full path is /usr/sbin/nethogs.

Non-root user in Debian does not have /usr/sbin in its default $PATH.

With command su you become a root, but the environment variables do not get expanded. Use either:

  1. su - and then nethogs
  2. sudo su and then nethogs
  3. sudo nethogs.

More information here Can't access some commands when logged in with non-root user (even after "su root").

Edit: You mention switching to Ubuntu. Ubuntu non-root user does have /usr/sbin in its default $PATH, so here it might be less confusing. However, you need a root access to flawlessly run nethogs anyway.

ethcz
  • 365