0

I'm experiencing "weird" behavior on a Linux PC -- I don't know how to qualify the problem exactly, other than that it seems to have something to do with /dev/null, based on the error messages.

When I ssh to the PC, the message -bash: /dev/null: Permission denied appears immediately, e.g.:

$ ssh linux-pc
user@linux-pc's password:
Linux linux-pc 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Mar 20 19:34:08 2023 from 10.100.71.69
-bash: /dev/null: Permission denied
-bash: /dev/null: Permission denied

When I tab to autocomplete in Bash, the -bash: /dev/null: Permission denied error as well as an invalid number specifier appear, e.g. below, I typed cd fo[TAB] expecting auto-completion to cd foo/:

user@linux-pc:~$ mkdir foo
mkdir: cannot create directory ‘foo’: File exists
user@linux-pc:~$ cd fo-bash: /dev/null: Permission denied
bash: _upvars: `-a2': invalid number specifier
-bash: /dev/null: Permission denied
bash: _upvars: `-a0': invalid number specifier

I also can't scp files to the PC -- again, an error message relating to /dev/null appears:

user@linux-pc:~/foo$ scp user@my_device:/home/user/dropbox/* ./
Couldn't open /dev/null: Permission denied

All these error-messages circling /dev/null, so I tried looking at the file permissions:

user@linux-pc:~/foo$ ls -l /dev/null
-rw-r--r-- 1 root root 0 Mar 29 17:22 /dev/null

...below is the /dev/null file permissions from another Linux PC that doesn't have this problem:

user@linux-pc-2:~$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Jul  1  2022 /dev/null

It caught my eye that on the working PC, /dev/null is flagged as a character device, and on the problem PC, it is not.

What could have happened to /dev/null/ on the problem PC that put it into this problem state, and how can I recover it to a correct state?

StoneThrow
  • 1,575
  • 5
  • 19
  • 41
  • 2
    We can't say *why* `/dev/null` is no longer a character device in your system - maybe you ran some command that had a typo which deleted it, or maybe you ran some broken tool. Who knows? – muru Mar 30 '23 at 02:25

0 Answers0