Namei: File Permissions Listing Tool

While setting up the Apache web server, occasionally we’ll encounter the file permission issues in the document root folder, especially when symlink involved. This console app, namei, which is part of util-linux, provides a quick view of the file permissions of each component of the resolved full path. Quite a useful tool especially for those who just venture into GNU/Linux and haven’t fully grasp the file permissions in the system.

For example, listing of the file permission of the folders and file of SSH private key.
$ namei -l ~/.ssh/id_rsa 
f: /home/ang/.ssh/id_rsa
drwxr-xr-x root root /
drwxr-xr-x root root home
drwx------ ang ang ang
drwx------ ang ang .ssh
-rw------- ang ang id_rsa

First, let's create a sample symlink.
$ sudo ln -s /tmp /var/www/html/tmp

Tracing to the endpoint of the symlink.
$ namei /var/www/html/tmp
f: /var/www/html/tmp
d /
d var
d www
d html
l tmp -> /tmp
d /
d tmp

Similarly, but showing the permissions of each component of the resolved full path.
$ namei -l /var/www/html/tmp
f: /var/www/html/tmp
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxr-xr-x root root html
lrwxrwxrwx root root tmp -> /tmp
drwxr-xr-x root root /
drwxrwxrwt root root tmp

No comments:

Post a Comment