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, …
For that matter, the namei command appeared. Now we’re gonna teach you to use the namei command in Linux.
The syntax of the namei command
Code language: CSS (css)
namei [options] pathname...
$ namei test/test1.txt
f: the path name
-: the file name
Code language: HTML, XML (xml)
<strong>namei </strong>interprets its arguments as pathnames to any type of Unix file (symlinks, files, directories, and so forth). <strong>namei </strong>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. For each line of output, <strong>namei </strong>uses the following characters to identify the file type found: f: = the pathname currently being resolved d = directory l = symbolic link (both the link and its contents are output) s = socket b = block device c = character device p = FIFO (named pipe) - = regular file ? = an error of some kind <strong>namei </strong>prints an informative message when the maximum number of symbolic links this system can have has been exceeded.
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
This proves that this 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
We just taught you to use the namei command in Linux.
Another interesting article may be: A Easy Way To Install FortiClient VPN