Without permission to use
.. inside a directory, most commands using these names all fail:
$ cd /tmp ; mkdir dir ; cd dir ; pwd
$ chmod u-x . ; ls
ls: cannot open directory .: Permission denied
$ cd .
-bash: cd: .: Permission denied
$ ls ..
ls: cannot access ..: Permission denied
So why does this subsequent command succeed (in BASH)?
$ cd ..
The answer is here in the
physical option being disabled:
$ set -o | grep 'physical'
The shell is secretly internally using the
.. to change the current directory from
/tmp/dir to just
/tmp and is using that to do
cd /tmp instead of doing the
cd .. that you typed! The shell isn’t actually using and following the
.. pathname! See the updated section on
set -o physical in Login and Shell Startup Files, aliases, options: .bash_profile and .bashrc. System administrators should always set the
-o physical option in BASH.
There are three sets of of three read/write/execute permissions set in every inode: one set for the inode’s user/owner, one set for the group, and a third set for all other users.
When performing a long directory listing,
ls -ld, the inode’s permissions (mode) appear as nine characters (three sets of read/write/execute) in the first field (column) of each output line, after the inode’s type indicator character. The second field in the output is a link count. The third field is the user/owner of the inode. The fourth field is the group to which the inode belongs. The fifth field is the date/time the inode was modified. The last field is a name for the inode. (Inodes may have multiple names.) If you use the
-i option, the inode numbers appear at the start (left) of the output lines:
$ ls -il
555 -rw-r----- 3 user1 group1 123 Nov 12 14:14 fileone
928 drwxrwxr-x 2 user1 group1 4096 Nov 12 14:14 directoryone
382 lrwxrwxrwx 1 root root 30 Oct 13 12:39 symlink -> ../some/place
- Inode 555 is a plain file named
fileone owned by
user1 and in group
group1 with size 123 and link count of 3.
- Inode 928 is a directory named
- Inode 382 symbolic link named
The permissions and owners of symbolic links are ignored; all that matters are the permissions on the inode being linked to. Symbolic links allow directories to appear to have multiple names.
The “inode type” character is the first character before the nine permission characters. It identifies the type of the inode that this name is attached to. The three most common inode types are:
- (a hyphen/minus/dash) for a regular file inode
d for a directory inode
l (lower-case L) for a soft or symbolic link (soft link) linking to a pathname (not to an inode!)
In the example above,
fileone is typed as a regular file (the type character is a leading
directoryone is a directory (a leading ‘d’)
symlink is a symbolic link (a leading ‘l’) that points to pathname
The permissions, owner, and group of symbolic links are ignored; all that matters are the permissions on the inode being linked to.
| Ian! D. Allen - firstname.lastname@example.org - Ottawa, Ontario, Canada
| Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/
Plain Text - plain text version of this page in Pandoc Markdown format