Examples of using the lsof command in Linux

Source: Internet
Author: User
Tags ftp connection tmp folder

Enter lsof under the terminal to display the system open files, because the lsof need to access core memory and various files, so you must run it as root to fully perform its function

LSOF-PNL +m-i4
LSOF-PNL +m-i6
Ls-i: 80

Add: Practical command

The code is as follows Copy Code

Lsof ' which HTTPd '//That process is using the Apache executable file
LSOF/ETC/PASSWD//That process is occupying/etc/passwd
Lsof/dev/hda6//That process is taking up Hda6
lsof/dev/ CDROM//That process is seizing the optical drive
Lsof-c sendmail//Viewing file usage of SendMail process
Lsof-c courier-u//showing that the files were opened with a ^zahn-preceded process, but not On the user Zahn
Lsof-p 30297//display those files are open by the PID 30297 process
lsof-d/TMP displays all instance and file processes opened in the/tmp folder. However, the symbol file is not in the column

lsof-u1000//View file usage for the process of the user with the UID of 100
Lsof-utony//View file Usage for user Tony's process
Lsof-u^tony// View file usage for a process that is not a user Tony (^ is the reverse meaning)
Lsof-i//Display all open ports
lsof-i:80//Show all open 80 ports process
Lsof-i-u//Show all open ports and Unix DOMA In file
Lsof-i udp@[url]www.akadia.com:123//display links to the 123 (NTP) ports that the process has opened to www.akadia.com UDP
Lsof-i Tcp@ohaha.ks.edu.tw:ftp-r//Constantly view the current FTP connection (-r,lsof will always continue to execute until the interrupt signal is received, +r,lsof will always execute until no files are displayed, default is 15s refresh)
Lsof-i Tcp@ohaha.ks.edu.tw:ftp-n//lsof-n does not convert IP to hostname, the default is not to add the-n parameter

lsof Command parameter Interpretation

1-P: This option constrains the conversion of the port number of the network file to the ports name. Constraint conversions can make lsof run faster. This is useful when the search for a port name does not work.
2-N: This option constrains the conversion of the port number of the network file to the host name. Constraint conversions can make lsof run faster. It is useful when the search for a host name does not work.
3-L: This option constrains the conversion of the user ID number to the login name. This option is useful when the Sign-in name lookup is incorrect or slow.
4) +m: This option supports registration reports for local TCP and UDP port mapper programs.
5)-i4: Only the ports under the IPV4 protocol are listed.
6)-i6: Only the ports under the IPV6 protocol are listed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.