Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

18,876 views
Skip to first unread message

LynnOS

unread,
Jul 3, 2008, 3:26:07 AM7/3/08
to bug-...@gnu.org
root@Avct Linux-vserver:~# pwd
/root
root@Avct Linux-vserver:~# ls -ld /root
drwx------ 3 root root 4096 Jul 3 14:52 /root
root@Avct Linux-vserver:~# su lynn
*shell-init: error retrieving current directory: getcwd: cannot access
parent directories: Permission denied*
lynn@Avct Linux-vserver:/root$

lynn@Avct Linux-vserver:/root$ bash --version
GNU bash, version 3.2.39(1)-release (i686-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

===============================================================================

I appay 39 patches from http://ftp.gnu.org/gnu/bash/bash-3.2-patches
but the error message doesn't go
in many popular linux distributions,the problem disappear

thanks

--
OpenEmbedded,Linux vserver,Python

sume...@gmail.com

unread,
Jul 11, 2008, 6:36:17 AM7/11/08
to
Hello,

I got the same error and I corrected it by changing the shell in /etc/
passwd.
changed from /usr/bin/bash/ to /bin/sh ...

sum
--------

Chet Ramey

unread,
Jul 12, 2008, 3:45:15 PM7/12/08
to sume...@gmail.com, bug-...@gnu.org, chet....@case.edu
sume...@gmail.com wrote:

> LynnOS wrote:
>> root@Avct Linux-vserver:~# pwd
>> /root
>> root@Avct Linux-vserver:~# ls -ld /root
>> drwx------ 3 root root 4096 Jul 3 14:52 /root
>> root@Avct Linux-vserver:~# su lynn
>> *shell-init: error retrieving current directory: getcwd: cannot access
>> parent directories: Permission denied*
>> lynn@Avct Linux-vserver:/root$

This is not a bash problem. You're in a directory which can be read and
searched only by root, and you're su'ing to another user. That user
does not have permission to search the current directory, even to find
`..', so getcwd is going to fail.

You might be able to avoid the need for the getcwd call at startup by
exporting PWD, so the child shell can read it, but there aren't any
guarantees.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


LynnOS

unread,
Jul 16, 2008, 10:15:47 PM7/16/08
to chet....@case.edu, sume...@gmail.com, bug-...@gnu.org
*"You might be able to avoid the need for the getcwd call at startup by
exporting PWD*"

Sorry,would you give us more details about how to avoid the "error" message

Thanks very much

LynnOS

2008/7/13 Chet Ramey <chet....@case.edu>:

> sume...@gmail.com wrote:
>
> LynnOS wrote:
>>
>>> root@Avct Linux-vserver:~# pwd
>>> /root
>>> root@Avct Linux-vserver:~# ls -ld /root
>>> drwx------ 3 root root 4096 Jul 3 14:52 /root
>>> root@Avct Linux-vserver:~# su lynn
>>> *shell-init: error retrieving current directory: getcwd: cannot access
>>> parent directories: Permission denied*
>>> lynn@Avct Linux-vserver:/root$
>>>
>>

> This is not a bash problem. You're in a directory which can be read and
> searched only by root, and you're su'ing to another user. That user
> does not have permission to search the current directory, even to find
> `..', so getcwd is going to fail.
>

> *You might be able to avoid the need for the getcwd call at startup by
> exporting PWD, *so the child shell can read it, but there aren't any


> guarantees.
>
> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>
> Chet Ramey, ITS, CWRU ch...@case.edu

> http://cnswww.cns.cwru.edu/~chet/ <http://cnswww.cns.cwru.edu/%7Echet/>
>
>
>


--
OpenEmbedded,Linux vserver,Python

Chet Ramey

unread,
Jul 17, 2008, 8:16:52 AM7/17/08
to lyn...@tong-ji.org, sume...@gmail.com, bug-...@gnu.org, chet....@case.edu
> *"You might be able to avoid the need for the getcwd call at startup by
> exporting PWD*"
>
> Sorry,would you give us more details about how to avoid the "error" message

export PWD

Bash performs a check at startup in which it compares $PWD to `.' and skips
the call to getcwd if the two refer to the same device and inode. File
permissions may still keep you from being able to stat $PWD, but it's worth
a shot.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU ch...@case.edu http://tiswww.tis.case.edu/~chet/


LynnOS

unread,
Jul 17, 2008, 10:01:18 PM7/17/08
to chet....@case.edu, sume...@gmail.com, bug-...@gnu.org
Thanks ,but after I export PWD,the problem doesn't go
the following is my step:


root@Linux-vserver:~# export
declare -x EDITOR="/bin/vi"
declare -x HOME="/root"
declare -x LD_LIBRARY_PATH="/usr/lib:/lib"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD
declare -x OPIEDIR
declare -x
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:"
declare -x PS1="\\u@\\h:\\w\\\$ "
declare -x PWD="/root"
declare -x PYTHONHOME="/usr/lib/python2.5"
declare -x PYTHONPATH="/usr/lib/python2.5:/usr/lib/python2.5/lib-dynload"
declare -x QPEDIR
declare -x QTDIR
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="172.26.26.200 1593 22"
declare -x SSH_CONNECTION="172.26.26.200 1593 172.26.26.106 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="vt100"
declare -x USER="root"
root@Linux-vserver:~# su lynn


shell-init: error retrieving current directory: getcwd: cannot access parent
directories: Permission denied

lynn@Linux-vserver:/root$


2008/7/17 Chet Ramey <chet....@case.edu>:

> http://tiswww.tis.case.edu/~chet/ <http://tiswww.tis.case.edu/%7Echet/>
>

--
OpenEmbedded,Linux vserver,Python

Chet Ramey

unread,
Jul 17, 2008, 11:42:57 PM7/17/08
to LynnOS, sume...@gmail.com, bug-...@gnu.org, chet....@case.edu
LynnOS wrote:
> Thanks ,but after I export PWD,the problem doesn't go

As I explained previously, this is not a bash problem. This is a
problem with file permissions in the current working directory.


Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


allan...@gmail.com

unread,
Dec 4, 2013, 10:03:40 AM12/4/13
to
I just saw this message upon logging in from OSX Lion to our Centos 5.5 and was starting to look at remote permissions. Before I started to mess with things I tried from a freshly started console; no problem there. So I logged out of the remote machine, changed to my home directory (simply typing "cd") and tried again. No issue.

I think I was in a local directory that was removed and recreated or something odd.

So FWIW.

zea...@gmail.com

unread,
Feb 27, 2014, 5:31:07 PM2/27/14
to
Ditto on that. I was in a directory that I had previously deleted and recreated. When I moved off and launched SSH from another directory. Error on remote host disappeared. Both hosts CentOS 6.x

vhdm...@gmail.com

unread,
Aug 12, 2015, 4:35:54 PM8/12/15
to
chupilirola
0 new messages