Search

namei : A command to follow pathnames

namei

The command takes as input a path or a file/directory  gives, as output, information about the file and also about the other directories in the path. If the input is a symbolic link, it will follow the link to the original file showing the path that needs to be taken to reach the original file.

For eg if we have a folder "temp" with the files one,two and three then command namei on a file can be run as follows

$ namei /home/user/Desktop/temp/one
f: /home/user/Desktop/temp/one
 d /
 d home
 d user
 d Desktop
 d temp
 - one




In the output above  the "d" in the first column informs us that the item in second column is a directory and the "-" informs that the item in second column is simple text file, thus giving us information about all the directories that lead up to the file we are interested in.
The -o option that will give information about the owners of the all the folders along the path as shown below.

$ namei -o /home/user/Desktop/temp/one

f: /home/user/Desktop/temp/one
 d root  root /
 d root  root home
 d user adm  nitin
 d user adm  Desktop
 d user root temp
 - user root one

If the file passed as the argument is a symbolic link then command will follow till the real file.
For Eg Assume that the file "two" in our example is a link to another file "four" in the Desktop.

$ namei /home/user/Desktop/temp/two


f: /home/user/Desktop/temp/two
 d root  root /
 d root  root home
 d user adm  nitin
 d user adm  Desktop
 d user root temp
 l user root two -> ../four
 d user root ..
 - root  root four

The letter "l" in the first column indicates the the file is a symbolic link, and then the entries after that is the relative path from the link to the original file.


The option -l gives output similar to "ls -l" and the option "-m" gives the permission of each file or folder.

No comments:

Post a Comment