Why says readlink that there is no such file or directory [duplicate] Ask Question. Asked 2 years, 2 months ago. Active 2 years, 2 months ago. Viewed 1k times. Improve this question. Rabarberski Rabarberski 7 7 bronze badges. The answer of UmairKhan looks right.
AdminBee: Works perfect now. Jump to bottom. Labels fixed waitingoninfo. Copy link. Thanks for the quick response. I can try and debug this some more later. No worries. It has yet to affect functionality. Thank you. Sign up for free to join this conversation on GitHub. Already have an account?
If a name is none of the above, lsof lists any open files whose device and inode match that of the specified path name. If you have also specified the -b option, the only names you may safely specify are file systems for which your mount table supplies alternate device numbers.
It may recognize AFS files on other versions of these dialects, but has not been tested there. In that case, lsof may have to guess at the identity of AFS files, and might not be able to obtain volume information from the kernel that is needed for calculating AFS volume node numbers. When lsof can't compute volume node numbers, it reports blank in the NODE column.
The -A A option is available in some dialect implementations of lsof for specifying the name list file where dynamic module kernel addresses may be found. When this option is available, it's listed in the lsof help output, presented in response to the -h or -?
Because AFS path lookups don't seem to participate in the kernel's name cache operations, lsof can't identify path name components for AFS files. First, its default compilation mode allows anyone to list all open files with it. Second, by default it creates a user-readable and user-writable device cache file in the home directory of the real user ID that executes lsof. The list-all-open-files and device cache features may be disabled when lsof is compiled. Third, its -k and -m options name alternate kernel name list or memory files.
The non-root user may list only open files of processes with the same user IDentification number as the real user ID number of the lsof process the one that its user logged on with. Help output, presented in response to the -h or -? For security considerations it is important to note that in the default lsof distribution, if the real user ID under which lsof is executed is root, the device cache file will be written in root's home directory — e.
When lsof user declares alternate kernel name list or memory files with the -k and -m options, lsof checks the user's authority to read them with access. This is intended to prevent whatever special power lsof's modes might confer on it from letting it read files not normally accessible via the authority of the real user ID. The lsof process must be supplied a language locale environment variable e.
Otherwise, lsof considers the extended characters non-printable and prints them according to its rules for non-printable characters, stated above. Consult your dialect's setlocale man page for the names of other environment variables used in place of LANG — e. Wide characters are printable under those conditions if iswprint reports them to be. Consult the answers to the "Language locale support" questions in the lsof FAQ. The FAQ section gives its location for more information.
It also guarantees that each column is separated from its predecessor by at least one space. All command name characters maintained by the kernel in its structures are displayed in field output when the command name descriptor ' c ' is specified. FD is followed by one of these characters, describing the mode under which the file is open:.
The mode character is followed by one of these lock characters, describing the type of lock applied to the file:. A value is displayed in this column only if it's available. Lsof displays whatever value — size or offset — is appropriate for the type of the file and the version of lsof. On some UNIX dialects lsof can't obtain accurate or consistent file offset information from its kernel data sources, sometimes for particular kinds of files e.
In other cases, files don't have true sizes — e. The file size is displayed in decimal; the offset is normally displayed in decimal with a leading "0t" if it contains 8 digits or less; in hexadecimal with a leading "0x" if it's longer than 8 digits. Consult the -o o option description for information on when 8 might default to some other value. Thus the leading " 0t " and " 0x " identify an offset when the column may contain both a size and an offset i.
If the -o option is specified, lsof always displays the file offset or nothing if no offset is available and labels the column OFFSET. The offset always begins with " 0t " or " 0x " as described above. Consult its description for more information. If the -s option is specified, lsof always displays the file size or nothing if no size is available and labels the column SIZE.
For files that don't have a fixed size — e. What it reports in a single character is a compromise between the information it finds in the kernel and the limitations of the reporting format.
Moreover, when a process holds several byte level locks on a file, lsof only reports the status of the first lock it encounters.
If it is a byte level lock, then the lock character will be reported in lowercase — i. Generally lsof can only report on locks held by local processes on local files. When a local process sets a lock on a remotely mounted e. One exception is Solaris — at some patch levels of 2. When the -F option is specified, lsof produces output that is suitable for processing by another program — e. Each unit of information is output in a field that is identified with a leading character and terminated by an NL or a NULL if the 0 zero field identifier character is specified.
The data of the field follows immediately after the field identification character and extends to the field terminator. It is possible to think of field output as process and file sets. It extends to the beginning of the next PID field or the beginning of the first file set of the process, whichever comes first.
A file set begins with a field whose identifier is ' f ' for file descriptor. It is followed by lines that describe the file's access mode, lock state, type, device, size, offset, inode, protocol, name and stream module names.
It extends to the beginning of the next file or process set, whichever comes first. When the NULL field terminator is selected with the 0 zero field identifier character, lsof ends each process and file set with an NL character.
All other fields may be declared optionally in the field identifier character list that follows the -F option. It is entirely possible to select a set of fields that cannot easily be parsed — e. To help you avoid this difficulty, lsof supports the -F option; it selects the output of all fields with NL terminators the -F0 option pair selects the output of all fields with NULL terminators. For compatibility reasons neither -F nor -F0 select the raw device field.
These are the fields that lsof produces. The single character listed first is the field identifier. You can get online help information on these characters and their descriptions by specifying the -F? As an example, " -F pcfn " selects the process ID ' p ' , command name ' c ' , file descriptor ' f ' and file name ' n ' fields with an NL field terminator character; " -F pcfn0 " selects the same output with a NULL field terminator character.
One or the other member of these mutually exclusive sets appears in field output, but not both. Normally lsof ends each field with an NL character.
The 0 zero field identifier character may be specified to change the field terminator character to a NULL A NULL terminator may be easier to process with xargs , for example, or with programs whose quoting mechanisms may not easily cope with the range of characters in the field output.
Three aids to producing programs that process lsof field output are included in the lsof distribution. The second aid is a set of sample scripts that process field output, written in awk, Perl 4, and Perl 5. They're located in the scripts subdirectory of the lsof distribution. The third aid is the C library used for the lsof test suite.
The test suite is written in C and uses field output to validate the correct operation of lsof. These functions are stalled in the kernel, for example, when the hosts where mounted NFS file systems reside become inaccessible.
When lsof does manage to break a block, it will report the break with an error message. The messages may be suppressed with the -t and -w options. The default timeout value may be displayed with the -h or -? The minimum for t is two seconds, avoid small values since slow system responsiveness can cause short timeouts to expire unexpectedly and perhaps stop lsof before it can produce any output. When lsof has to break a block during its access of mounted file system information, it normally continues, although with less information available to display about open files.
While this allows lsof to start up with less overhead, it exposes lsof completely to the kernel situations that might block it. You can use the -b option to tell lsof to avoid using kernel functions that would block. Some cautions apply. First, using this option usually requires your system supply alternate device numbers in place of the device numbers that lsof would normally obtain with the lstat and stat kernel functions.
Second, you can't specify names for lsof to locate unless they're file system names. This is because lsof needs to know the device and inode numbers of files listed with names in the lsof options, and the -b option prevents lsof from obtaining them.
Moreover, since lsof only has device numbers for the file systems that have alternates, its ability to locate files on file systems depends completely on the availability and accuracy of the alternates. If no alternates are available, or if they're incorrect, lsof won't be able to locate files on the named file systems.
Third, if the names of your file system directories that lsof obtains from your system's mount table are symbolic links, lsof won't be able to resolve the links. This is because the -b option causes lsof to avoid the kernel readlink function it uses to resolve symbolic links.
Finally, using the -b option causes lsof to issue warning messages when it needs to use the kernel functions that the -b option directs it to avoid. You can suppress these messages by specifying the -w option, but if you do, you won't see the alternate device numbers reported in the warning messages. On some dialects, when lsof has to break a block because it can't get information about a mounted file system via the lstat and stat kernel functions, or because you specified the -b option, lsof can obtain some of the information it needs — the device number and possibly the file system type — from the system mount table.
When that is possible, lsof will report the device number it obtained. You can suppress the report by specifying the -w option. Note: you must be able to edit the file — i. Check the output of lsof 's -h or -? The " xxxx " portion of the field is the hexadecimal value of the file system's device number. Here's an example from a Sun Solaris 2. When a remote server crashes and you want to identify its users by running lsof on one of its clients, lsof probably won't be able to get output from the lstat and stat functions for the file system.
If it can obtain the file system's device number from the mount table, it can display the files open on the crashed NFS server. Lsof knows how to obtain the alternative device number for these dialects and uses it when its attempt to lstat or stat the file system is blocked.
If you're not sure your dialect supplies alternate device numbers for file systems from its mount table, use this lsof incantation to see if it reports any alternate device numbers:. AFS file system path lookups don't use the kernel's name cache; some Solaris VxFS file system operations apparently don't use it, either. When lsof is run in repeat mode — i.
That's because other running processes can cause the kernel to remove entries from its name cache and replace them with others. Lsof's use of the kernel name cache to identify the paths of files can lead it to report incorrect components under some circumstances. Viewed 41k times. FYI for the Internet passer-by: I wanted to solve a similar problem--counting the number of open files per process, specifically Java. Add a comment. Active Oldest Votes. Ben Jackson Ben Jackson You can use xargs -L1 lsof -p to run lsof once per pid.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
0コメント