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?



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. 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. 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?

Full details:

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 prime-mover-import-files
  drwxr-xr-x 2 www-data www-data 12288 Sep  8 20:53 prime-mover-import-files

  $ df prime-mover-import-files/
  Filesystem     1K-blocks    Used Available Use% Mounted on
  /dev/sda        25186308 5130400  18755860  22% /

I don't see any unusual attributes:

  $ stat prime-mover-import-files
    File: prime-mover-import-files
    size: 12288           Blocks: 24         IO Block: 4096   directory
  Device: 8,0     Inode: 270434      Links: 2
  Access: (0755/drwxr-xr-x)  Uid: (   33/www-data)   Gid: (   33/www-data)
  Access: 2026-09-08 21:05:43.038735433 +0000
  Modify: 2026-09-08 21:05:43.038735433 +0000
  Change: 2026-09-08 21:05:43.038735433 +0000
   Birth: 2026-09-08 19:37:29.024640959 +0000

  $ stat -f prime-mover-import-files
    File: "prime-mover-import-files"
      ID: 738537e1353f0990 Namelen: 255     Type: ext2/ext3
  Block size: 4096       Fundamental block size: 4096
  Blocks: Total: 6296577    Free: 5016423    Available: 4691411
  Inodes: Total: 1593088    Free: 1428275

  $ lsattr -d prime-mover-import-files
  -----------I--e------- prime-mover-import-files

At the current moment, an hours-long WordPress import operation is in
progress (over https) involving the prime-mover-import-files
subdirectory. During that time, when I cd into the directory, my shell
hangs.

  $ cd prime-mover-import-files
  <shell hangs>

It hangs so badly that ^C has no effect, and I can't even terminate my
SSH connection with the ssh escape sequence "~." I can only kill the
enclosing X window. But the root user can cd into the directory anytime.

  # cd prime-mover-import-files
  # ls
  <files are listed>

I thought, maybe the system was so busy it couldn't serve my cd
command, so I waited about 5 minutes. Still hung. Also, all other
commands in other windows work fine.

I checked the process state of the hung bash shell from another shell:

  # ps -ut4
  USER     PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  me     63169  0.0  0.5   8968  5844 pts/4    Ss+  21:18   0:00 -bash

I killed that shell as root (kill -9 63169) but my session was still hung.

ChatGPT suggested that the problem has to do with my prompt, PS1, not
returning. My prompt for both users (root and non-root) was:

  # echo $PS1
  \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

However, I changed my non-root prompt to something static:

  PS1='$ '

then logged out, logged back in, and the problem still occurred. Plus,
the root user has the fancy PS1 value and it encounters no problems
cd-ing into the subdirectory in question.

ChatGPT also suggested a hung mount point, but it's just a normal
subdirectory, and no other commands hang, and root can cd into it.

The problem appears to vanish when the hours-long WordPress import is
finished. I can only guess that WordPress has temporarily restricted
the directory in some weird way that doesn't affect root??

I'm stumped. Any ideas what I should check next?

Thanks very much,
Dan

--
Dan Barrett
dbarrett at blazemonger.com




Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org