namei Command in Linux System - Explained with Examples

As a Linux administrator, you often have to work with files, folders, symlinks, etc. And sometimes you need to know more information about individual elements in a path for example file type, owner, and so on. This is where the namei commandcomes to play.

Here at LinuxAPT, we shall look into how to use the namei command in Linux.


What is the syntax of the namei command ?

It's syntax is given below:

$ namei [options] pathname...

For example, For example, if we have a file named test1.txt:

$ namei test/test1.txt

Then from the output, you will see:

  • f: the path name.
  • d: directory.
  • -: the file name.


Example of using the namei command

1. Align to the left margin (using -v option):

$ namei -v test/test1.txt


2. Show owner and group (using -o option):

$ namei -o test/test1.txt

In our case, the folder and file are both owned by ubuntu.


3. Show long list (using -l option):

$ namei -l test/test1.txt

With this option, it will show more privileges of the owner.

If you only want to show the privileges of the owner, let’s use the -m option:

$ namei -m test/test1.txt


[Need help in fixing Linux system issues ? We can help you. ]

This article covers how to use the namei command in Linux.


The namei command in Linux follows a pathname until a terminal point is found. Following is its syntax:

$ namei [options] pathname...

And here's what the man page says about this tool:

  • namei :interprets  its  arguments as pathnames to any type of Unix file (symlinks, files, directories, and so forth).  namei then follows  each pathname  until  an  endpoint  is  found (a file, a directory, a device node, etc).  If it finds a symbolic link, it shows the link, and starts following it, indenting the output to show the context.
  • This  program is useful for finding "too many levels of symbolic links" problems.

Related Posts