Boston Linux & UNIX was originally founded in 1994 as part of The Boston Computer Society. We meet on the third Wednesday of each month, online, via Jitsi Meet.

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] Linux command-line mystery: why does "cd" hang?



Daniel Barrett said on Tue, 8 Sep 2026 17:43:34 -0400

>If you like Linux puzzles, I've encountered a command-line mystery
>like nothing I've ever seen before.
>
>tl;dr: I have a directory with mode 0755. Anytime I cd into it, my
>shell hangs. 

Assuming the directory name is /baddir, what is the output of the
following:

ls -ldF /baddir
ls -ldF /baddir/*
lsof | grep baddir

Perform the preceding command both as root and as the user that's
hanging.

>You might think, "Oh, that's a hung mount point," but no.
>It's just a subdirectory within the root filesystem, and the root user
>can cd into it with no problems. 

OK, it's sensitive to user. Now the question is, is root special, or is
your account (I'll call it dbarrett) special. Create another normal
user and try cd-ing in as that user.

>You might think, "Oh, maybe your shell
>prompt PS1 has some funky stuff that's not returning," but no, my
>prompt is just a static dollar sign. Any other guesses?

Substitute diagnostic tests for guesses.

* Create a different directory, off the root, with the same ownership
  and permissions as /baddir: Can you cd into the new directory as your
  usual normal user account?

* ln /baddir /testdir; su dbarrett; cd /testdir  : Does the cd work? If
  so, maybe there's something funky about the filename.

* Same as previous step, but with a symbolic link instead of a hard
  link.

The preceding tests will take less than 1/2 hour and will get you MUCH
closer to the root cause.

>
>Full details:

You should have mentioned full details would come later...

>
>I'm logged in via ssh on a Linode server running Ubuntu 26.04. On that
>server, I have a WordPress-related directory in my web tree,
>/var/www/wordpress/wp-content/uploads:
>
>  $ cd /var/www/wordpress/wp-content/uploads
>  <succeeds>
>
> It has a subdirectory, prime-mover-import-files. It appears to be an
> ordinary directory:
>
>  $ ls -ld  
>  drwxr-xr-x 2 www-data www-data 12288 Sep  8 20:53
> prime-mover-import-files

Temporarily chmod a+w prime-mover-import-files  : Does the symptom
change?

Stop the Wordpress process. Can you NOW cd in as the normal user
(dbarrett I assume).

>ChatGPT suggested that the problem has to do with

When working with ChatGPT, don't ask "what could be wrong?". Ask "what
diagnostic tests can I do to narrow this down?" You can ask ChatGPT
what your results reveal and rule out. I do this all the time.

SteveT

Steve Litt 

http://444domains.com



Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org