If you’ve just started a small online business, you may already know that modern marketing isn’t just about social media. Email marketing campaigns can play a key role in your overall strategy. However, it’s hard to make much progress if your email list isn’t very long.
Fortunately, there are lots of simple and inexpensive ways to grow your email list. All this requires is your time, dedication, and a few simple strategies.
In this post, we’ll explore why email marketing is a great way to grow your business. Then we’ll cover seven powerful ways to grow your email list. Let’s get started!
Why Email Marketing Is an Effective Way to Grow Your Business
To succeed, you have to cover all your bases. That’s why any ambitious content marketing strategy should be comprehensive. Some people may forget about email marketing because we spend so much of our time using newer forms of communication, such as social media and messaging platforms.
However, 4 billion people still use email worldwide. Additionally, the number of emails people send on a daily basis continues to grow every year. Therefore, email marketing remains a highly effective form of lead generation, even in 2022.
Email is also highly targeted, and when you’re organizing your inbox, you have to address every single message. When there’s such a big audience at stake, neglecting this platform would mean missing out on a significant opportunity.
With the rise of newsletters and the continued importance of email, there are now plenty of popular tools like ConvertKit and Mailchimp to help you manage your campaigns.
These tools offer an all-in-one solution so you can effectively reach your audience. They’re a great place to start – however, you’ll need more than just a dedicated tool. Let’s dive in.
7 Powerful Ways to Grow Your Email List
Your email marketing campaigns are only as strong as your email list. Let’s cover some worthwhile ways that you can get more leads and grow your base of subscribers.
1. Add an Opt-In Form to Your Website
An opt-in form is a simple element that prompts website visitors to sign-up to receive emails from your business. Usually, an email address is the only personal information requested. This is an easy way to convert readers to subscribers fast, and it’s at the top of our list because it requires minimal effort on your end.
Some opt-in forms are more subtle, and others are more attention-grabbing. A few common types include popup forms, exit-intent forms, and bar forms. It’s important to choose your design carefully, and base it on your product and your overall marketing style.
The timing and presentation of these forms are essential if you want to maximize sign-ups. If you’re not sure where to start, try using opt-in forms on your most popular pages:
If you’re using WordPress, you can easily create and manage opt-in forms by downloading and installing a plugin like OptinMonster or Convert Pro. Either one will enable you to choose from a wide variety of opt-in form templates and designs, which you can further customize to meet your specific needs.
Hey look, it’s one of those email opt-in forms!
Click below to sign up for more how-to’s and tutorials just like this one, delivered to your inbox.
2. Host a Giveaway
There’s nothing like a giveaway to get people excited. People will always love free stuff, so it’s a great way to incentivize readers and followers to sign-up for your email list. If you’re lucky, most won’t even think twice about offering up their email address. When done well, you can see massive growth in your email list in a very short time.
You can offer up your own products, but if this would cause undue stress on your product pipeline, then you don’t necessarily have to. Another option is to conduct a sponsored event with one or even multiple brands:
For example, a farm-to-table restaurant may partner with a variety of brands or supermarkets that offer organic goods. A small jewelry business might pair with a high-end sunglasses company.
Of course, be mindful of your partnerships. They must make sense for your business and offer quality products. If you accept a sponsorship deal with a subpar or irrelevant product, this might be off-putting to your audience.
While you should always be cautious, giveaways can be a gold mine. They are an especially useful opportunity for anyone who already has a strong social media presence:
If you’re not sure how to run an online giveaway, you can use a free WordPress plugin like RafflePress:
This solution offers an intuitive giveaway builder that lets you start by choosing a template for your giveaway. Then, you can take advantage of promotional and marketing tools to maximize the number of participants.
3. Offer Content Upgrades
Content upgrades are another type of ‘freebie’ you can offer. There are plenty of different types, but some common options are ebooks, workbooks, printables, and guides:
It’s important to remember that these content bonuses should be exclusive. The only way to get them should be by signing up for your email list.
As with any other strategy you use, it’s best to opt for something that’s relevant to your brand. Here, a food influencer with a cookbook offers recipe box functionality, but also a free recipe download upon sign up:
Notice how this offer is paired with catchy and irresistible copywriting: “5 Secrets to Super Simple Meals”.
Don’t forget that you can always combine the strategies on this list to increase their effectiveness. As in the example above, you may consider offering your site’s visitors an opt-in form upon entry, but also dangle a freebie in the navigation bar. The more opportunities visitors have to sign up, the more likely they are to do so.
4. Organize a Webinar
A webinar is a workshop, seminar, or presentation that you conduct online using video conferencing software. Most of us have attended one at some point, but if you haven’t, you can still host one without much difficulty.
For most, a webinar means moving your content to a different medium. It’s cheap and easy, but production may take a good amount of time:
This method is well suited to bloggers and influencers who have already monetized their ideas, but any expertise you have to offer will do. If you’re wondering how to host a webinar, you should start by choosing a topic. Then, be sure to nail down the logistical details, spend plenty of time preparing, and of course, promote your webinar.
This is a great way to get lots of new email addresses, but you want to be thorough so that all your hard work doesn’t go to waste. Remember to make the most of the opportunity. If you host your webinar on a popular social media platform such as Instagram or YouTube, you can boost your engagement as well.
Additionally, a webinar can provide you with social credibility. Since the time commitment from viewers is significant, this is not only a great way to get emails, but it may potentially lead to long-lasting and loyal customers.
5. Create an Email Course
An email course is similar to a traditional online class, but it arrives in your inbox. Typically, an email course is automated and has a short time frame of a few days or a few weeks. It should be easily digestible for participants:
Email courses are usually self-paced, but individual classes arrive on a set schedule. They don’t require any follow-up or feedback from the instructor. So you don’t have to worry about grading your students. This is also a great way to repurpose old content.
Related: How to Update Old Blog Posts to Keep Your Content Fresh
For example, if you already have a thorough how-to guide on your blog, you can simply expand on that and make it a three-day email course. If you’re using an email marketing service, many of them will already have this process streamlined for you:
The beauty of this type, of course, is that you can re-use it or revamp it whenever your email list needs a boost. You can even promote your products in the course! As always, however, you should make sure that the content of the course is truly useful to the participants.
6. Give a Welcome Discount
Another way to get people on your email list is by offering a generous one-time discount. This can be especially effective because it also incentivizes users to buy your product right away:
This can be a more costly strategy than most of the methods on this list. However, if your budget allows for it, you can be sure that many customers will find this offer difficult to resist.
Typically, an online store will offer somewhere between 10 and 25 percent off of an initial purchase when you sign up for its email list. When you use an eCommerce solution such as WooCommerce, creating discount codes is a breeze.
7. Start an Email Newsletter
In the past few years, email newsletters have become wildly popular. They are emerging as a new form of media consumption, but also as a new form of marketing. When you’re producing a quality newsletter, you’re sure to get more email addresses for your list:
Many newsletters are some combination of quality long-form content blended with product promotion via recommendations and favorites lists. They can also be combined well with affiliate marketing.
The beauty of the email newsletter is that anyone can do it, from the biggest corporations to the humblest solopreneurs. The only catch is that it’s a long-term obligation. Newsletters typically go out weekly or monthly, so you would need to commit to a regular schedule.
The majority of the popular email marketing services can offer you step-by-step guidance on how to create a newsletter. However, before you embark on this journey, you should make sure you have a clear goal, and always prioritize quality over quantity.
Grow Your Business with Email Marketing
We know that getting a respectable email list together may seem challenging. No one wants to launch an email marketing campaign with just a few people to contact.
Fortunately, you can make sure that all your hard work gets the viewers it deserves. Just remember to focus on growing your email list with the following strategies before you launch:
Add opt-in forms. Encourage website visitors to sign up for your email list on popular pages, using tools like OptinMonster or Convert Pro.
Host a giveaway. Offer free products or sponsored products to incentivize people to share their email addresses. WordPress plugins like RafflePress make this simple.
Offer content upgrades. Give people quality exclusive content in the form of ebooks, printables, guides, and so much more. You can pair this with opt-in forms to maximize sign-ups.
Organize a webinar. Use your expertise to host a webinar and offer participants valuable knowledge.
Create an email course. Repurpose old pillar content and provide your audience with a practical, short-term course. Use a popular tool like Mailchimp (or any email marketing service) to streamline the process.
Give a discount. Offer people a generous one-time discount for users who sign up for your email list. You can create discount codes in an eCommerce platform such as WooCommerce.
Start an email newsletter. Commit for the long haul and lure users with the promise of quality, regular content. Your preferred email marketing platform should be able to help you get started.
Get Professional Email @yourdomain
Promote your website with every message you send when you set up professional email that matches your domain with DreamHost. Plans start at $1.67/mo.
If you’ve just started a small online business, you may already know that modern marketing isn’t just about social media. Email marketing campaigns can play a key role in your overall strategy. However, it’s hard to make much progress if your email list isn’t very long.
Fortunately, there are lots of simple and inexpensive ways to grow your email list. All this requires is your time, dedication, and a few simple strategies.
In this post, we’ll explore why email marketing is a great way to grow your business. Then we’ll cover seven powerful ways to grow your email list. Let’s get started!
Why Email Marketing Is an Effective Way to Grow Your Business
To succeed, you have to cover all your bases. That’s why any ambitious content marketing strategy should be comprehensive. Some people may forget about email marketing because we spend so much of our time using newer forms of communication, such as social media and messaging platforms.
However, 4 billion people still use email worldwide. Additionally, the number of emails people send on a daily basis continues to grow every year. Therefore, email marketing remains a highly effective form of lead generation, even in 2022.
Email is also highly targeted, and when you’re organizing your inbox, you have to address every single message. When there’s such a big audience at stake, neglecting this platform would mean missing out on a significant opportunity.
With the rise of newsletters and the continued importance of email, there are now plenty of popular tools like ConvertKit and Mailchimp to help you manage your campaigns.
These tools offer an all-in-one solution so you can effectively reach your audience. They’re a great place to start – however, you’ll need more than just a dedicated tool. Let’s dive in.
7 Powerful Ways to Grow Your Email List
Your email marketing campaigns are only as strong as your email list. Let’s cover some worthwhile ways that you can get more leads and grow your base of subscribers.
1. Add an Opt-In Form to Your Website
An opt-in form is a simple element that prompts website visitors to sign-up to receive emails from your business. Usually, an email address is the only personal information requested. This is an easy way to convert readers to subscribers fast, and it’s at the top of our list because it requires minimal effort on your end.
Some opt-in forms are more subtle, and others are more attention-grabbing. A few common types include popup forms, exit-intent forms, and bar forms. It’s important to choose your design carefully, and base it on your product and your overall marketing style.
The timing and presentation of these forms are essential if you want to maximize sign-ups. If you’re not sure where to start, try using opt-in forms on your most popular pages:
If you’re using WordPress, you can easily create and manage opt-in forms by downloading and installing a plugin like OptinMonster or Convert Pro. Either one will enable you to choose from a wide variety of opt-in form templates and designs, which you can further customize to meet your specific needs.
Hey look, it’s one of those email opt-in forms!
Click below to sign up for more how-to’s and tutorials just like this one, delivered to your inbox.
2. Host a Giveaway
There’s nothing like a giveaway to get people excited. People will always love free stuff, so it’s a great way to incentivize readers and followers to sign-up for your email list. If you’re lucky, most won’t even think twice about offering up their email address. When done well, you can see massive growth in your email list in a very short time.
You can offer up your own products, but if this would cause undue stress on your product pipeline, then you don’t necessarily have to. Another option is to conduct a sponsored event with one or even multiple brands:
For example, a farm-to-table restaurant may partner with a variety of brands or supermarkets that offer organic goods. A small jewelry business might pair with a high-end sunglasses company.
Of course, be mindful of your partnerships. They must make sense for your business and offer quality products. If you accept a sponsorship deal with a subpar or irrelevant product, this might be off-putting to your audience.
While you should always be cautious, giveaways can be a gold mine. They are an especially useful opportunity for anyone who already has a strong social media presence:
If you’re not sure how to run an online giveaway, you can use a free WordPress plugin like RafflePress:
This solution offers an intuitive giveaway builder that lets you start by choosing a template for your giveaway. Then, you can take advantage of promotional and marketing tools to maximize the number of participants.
3. Offer Content Upgrades
Content upgrades are another type of ‘freebie’ you can offer. There are plenty of different types, but some common options are ebooks, workbooks, printables, and guides:
It’s important to remember that these content bonuses should be exclusive. The only way to get them should be by signing up for your email list.
As with any other strategy you use, it’s best to opt for something that’s relevant to your brand. Here, a food influencer with a cookbook offers recipe box functionality, but also a free recipe download upon sign up:
Notice how this offer is paired with catchy and irresistible copywriting: “5 Secrets to Super Simple Meals”.
Don’t forget that you can always combine the strategies on this list to increase their effectiveness. As in the example above, you may consider offering your site’s visitors an opt-in form upon entry, but also dangle a freebie in the navigation bar. The more opportunities visitors have to sign up, the more likely they are to do so.
4. Organize a Webinar
A webinar is a workshop, seminar, or presentation that you conduct online using video conferencing software. Most of us have attended one at some point, but if you haven’t, you can still host one without much difficulty.
For most, a webinar means moving your content to a different medium. It’s cheap and easy, but production may take a good amount of time:
This method is well suited to bloggers and influencers who have already monetized their ideas, but any expertise you have to offer will do. If you’re wondering how to host a webinar, you should start by choosing a topic. Then, be sure to nail down the logistical details, spend plenty of time preparing, and of course, promote your webinar.
This is a great way to get lots of new email addresses, but you want to be thorough so that all your hard work doesn’t go to waste. Remember to make the most of the opportunity. If you host your webinar on a popular social media platform such as Instagram or YouTube, you can boost your engagement as well.
Additionally, a webinar can provide you with social credibility. Since the time commitment from viewers is significant, this is not only a great way to get emails, but it may potentially lead to long-lasting and loyal customers.
5. Create an Email Course
An email course is similar to a traditional online class, but it arrives in your inbox. Typically, an email course is automated and has a short time frame of a few days or a few weeks. It should be easily digestible for participants:
Email courses are usually self-paced, but individual classes arrive on a set schedule. They don’t require any follow-up or feedback from the instructor. So you don’t have to worry about grading your students. This is also a great way to repurpose old content.
Related: How to Update Old Blog Posts to Keep Your Content Fresh
For example, if you already have a thorough how-to guide on your blog, you can simply expand on that and make it a three-day email course. If you’re using an email marketing service, many of them will already have this process streamlined for you:
The beauty of this type, of course, is that you can re-use it or revamp it whenever your email list needs a boost. You can even promote your products in the course! As always, however, you should make sure that the content of the course is truly useful to the participants.
6. Give a Welcome Discount
Another way to get people on your email list is by offering a generous one-time discount. This can be especially effective because it also incentivizes users to buy your product right away:
This can be a more costly strategy than most of the methods on this list. However, if your budget allows for it, you can be sure that many customers will find this offer difficult to resist.
Typically, an online store will offer somewhere between 10 and 25 percent off of an initial purchase when you sign up for its email list. When you use an eCommerce solution such as WooCommerce, creating discount codes is a breeze.
7. Start an Email Newsletter
In the past few years, email newsletters have become wildly popular. They are emerging as a new form of media consumption, but also as a new form of marketing. When you’re producing a quality newsletter, you’re sure to get more email addresses for your list:
Many newsletters are some combination of quality long-form content blended with product promotion via recommendations and favorites lists. They can also be combined well with affiliate marketing.
The beauty of the email newsletter is that anyone can do it, from the biggest corporations to the humblest solopreneurs. The only catch is that it’s a long-term obligation. Newsletters typically go out weekly or monthly, so you would need to commit to a regular schedule.
The majority of the popular email marketing services can offer you step-by-step guidance on how to create a newsletter. However, before you embark on this journey, you should make sure you have a clear goal, and always prioritize quality over quantity.
Grow Your Business with Email Marketing
We know that getting a respectable email list together may seem challenging. No one wants to launch an email marketing campaign with just a few people to contact.
Fortunately, you can make sure that all your hard work gets the viewers it deserves. Just remember to focus on growing your email list with the following strategies before you launch:
Add opt-in forms. Encourage website visitors to sign up for your email list on popular pages, using tools like OptinMonster or Convert Pro.
Host a giveaway. Offer free products or sponsored products to incentivize people to share their email addresses. WordPress plugins like RafflePress make this simple.
Offer content upgrades. Give people quality exclusive content in the form of ebooks, printables, guides, and so much more. You can pair this with opt-in forms to maximize sign-ups.
Organize a webinar. Use your expertise to host a webinar and offer participants valuable knowledge.
Create an email course. Repurpose old pillar content and provide your audience with a practical, short-term course. Use a popular tool like Mailchimp (or any email marketing service) to streamline the process.
Give a discount. Offer people a generous one-time discount for users who sign up for your email list. You can create discount codes in an eCommerce platform such as WooCommerce.
Start an email newsletter. Commit for the long haul and lure users with the promise of quality, regular content. Your preferred email marketing platform should be able to help you get started.
Get Professional Email @yourdomain
Promote your website with every message you send when you set up professional email that matches your domain with DreamHost. Plans start at $1.67/mo.
Use promo code DOCS10 for $10 credit on a new account.
Introduction
lsof was created by Victor A. Abell and is a utility that lists open files. As everything in Linux can be considered a file, this means that lsof can gather information on the majority of activity on your Linode, including network interfaces and network connections. lsof by default will output a list of all open files and the processes that opened them.
The two main drawbacks of lsof are that it can only display information about the local machine (localhost), and that it requires administrative privileges to print all available data. Additionally, you usually do not execute lsof without any command line parameters because it outputs a large amount of data that can be difficult to parse. This happens because lsof will natively list all open files belonging to all active processes – for example, the output of wc(1) (a word count utility) when applied to lsof on a test instance shows the size of the output is extremely large:
sudo lsof | wc
7332 68337 1058393
Before You Begin
Note
Running lsof without root privileges will only return
the results available to the current user. If you are not familiar with the sudo command,
see the Users and Groups guide.
On most major distributions, lsof will come pre-installed and you can begin using it immediately. If for any reason it is not found, you can install lsof using your preferred package manager.
Command Line Options
The lsof(8) binary supports a large number of command line options, including the following:
Option
Description
-h and -?
Both options present a help screen. Please note that you will need to properly escape the ? character for -? to work.
-a
This option tells lsof to logically ADD all provided options.
-b
This option tells lsof to avoid kernel functions that might block the returning of results. This is a very specialized option.
-l
If converting a user ID to a login name is working improperly or slowly, you can disable it using the -l parameter.
–P
The -P option prevents the conversion of port numbers to port names for network files.
-u list
The -u option allows you to define a list of login names or user ID numbers whose files will be returned. The -u option supports the ^ character for excluding the matches from the output.
-c list
The -c option selects the listing of files for processes executing the commands that begin with the characters in the list. This supports regular expressions, and also supports the ^ character for excluding the matches from the output.
-p list
The -p option allows you to select the files for the processes whose process IDs are in the list. The -p option supports the ^ character for excluding the matches from the output.
-g list
The -g option allows you to select the files for the processes whose optional process group IDs are in the list. The -g option supports the ^ character for excluding the matches from the output.
-s
The -s option allows you to select the network protocols and states that interest you. The -s option supports the ^ character for excluding the matches from the output. The correct form is PROCOTCOL:STATE. Possible protocols are UDP and TCP. Some possible TCP states are: CLOSED, SYN-SENT, SYN-RECEIVED, ESTABLISHED, CLOSE-WAIT, LAST-ACK, FIN-WAIT-1, FIN-WAIT-2, CLOSING, and TIME-WAIT. Possible UDP states are Unbound and Idle.
+d s
The +d option option tells lsof to search for all open instances of directory s and the files and directories it contains at its top level.
+D directory
The +D option tells lsof to search for all open instances of directory directory and all the files and directories it contains to its complete depth.
-d list
The -d option specifies the list of file descriptors to include or exclude from the output. -d 1,^2 means include file descriptor 1 and exclude file descriptor 2.
-i4
This option is used for displaying IPv4 data only.
-i6
This option is used for displaying IPv6 data only.
-i
The -i option without any values tells lsof to display network connections only.
-i ADDRESS
The -i option with a value will limit the displayed information to match that value. Some example values are TCP:25 for displaying TCP data that listens to port number 25, @google.com for displaying information related to google.com, :25 for displaying information related to port number 25, :POP3 for displaying information related to the port number that is associated to POP3 in the /etc/services file, etc. You can also combine hostnames and IP Addresses with port numbers and protocols.
-t
The -t option tells lsof to display process identifiers without a header line. This is particularly useful for feeding the output of lsof to the kill(1) command or to a script. Notice that -t automatically selects the -w option.
-w
The -w option disables the suppression of warning messages.
+w
The +w option enables the suppression of warning messages.
-r TIME
The -r option causes the lsof command to repeat every TIME seconds until the command is manually terminated with an interrupt.
+r TIME
The +r command, with the + prefix, acts the same as the -r command, but will exit its loop when it fails to find any open files.
-n
The -n option prevents network numbers from being converted to host names.
-F CHARACTER
The -F command instructs lsof to produce output that is suitable as input for other programs. For a complete explanation, consult the lsof manual entry.
Note
By default, the output of lsof will include the output of each one of its command line options,
like a big logical expression with multiple OR logical operators between all the command line
options. However, this default behavior can change with the use of the -a option.
Note
For the full list of command line options supported by lsof and a more detailed
explanation of the presented command line options, you should consult its manual page:
man lsof
Anatomy of lsof Output
The following command uses the -i option to display all open UDP files/connections:
The COMMAND column contains the first nine
characters of the name of the UNIX command associated with the process.
The PID column
shows the process ID of the command.
The USER column displays the name of the
user that owns the process.
The TID column shows the task ID. A blank TID indicates a
process. Note that this column will not appear in the output of many lsof commands.
The FD column stands for file descriptor. Its values can be cwd, txt, mem, and mmap.
The TYPE column displays the type of the file: regular file, directory, socket, etc.
The DEVICE column contains the device numbers separated by commas.
The value of the SIZE/OFF
column is the size of the file or the file offset in bytes. The value of the NODE column
is the node number of a local file.
Lastly, the NAME column shows the name of the mount point
and file system where the file is located, or the Internet address.
The Repeat Mode
Running lsof with the –r option puts lsof in repeat mode, re-running the command in a loop every few seconds. This mode is useful for monitoring for a process or a connection that might only exist for a short time. The -r command will run forever, so when you are finished you must manually terminate the command.
The +r option will also put lsof in repeat mode – the difference between -r and +r is that +r will
automatically terminate lsof when a loop has no new output to print.
When lsof
is in repeat mode, it prints new output every t seconds (a loop); the default value
of t is 15 seconds, which you can change by typing an integer value after -r or +r.
The following command tells lsof to display all UDP connections every 10 seconds:
sudo lsof -r 10 -i UDP
Choosing Between IPv4 and IPv6
lsof lists both IPv4 and IPv6 connections by default, but you can choose the kind
of connections you want to display. The following command displays IPv4 connections
only:
sudo lsof -i4
Therefore, the next command will display all TCP connections of the IPv4 protocol:
sudo lsof -i4 -a -i TCP
An equivalent command to the above is the following command that uses grep:
sudo lsof -i4 | grep TCP
On the other hand, the following command will display IPv6 connections only:
sudo lsof -i6
Therefore, the next command will display all UDP connections of the IPv6 protocol:
In this section of the guide you will learn how to logically ADD the existing options
using the -a flag. This provides you enhanced filtering capabilities. Take the following command as an example:
sudo lsof -Pni -u www-data
The above command would print out all network connections (-i), suppressing network number conversion (-n) and the conversion of port numbers to port names (-P), and it would also print out all files pertaining to the www-data user, without combining the two options into one logical statement.
The following command combines these two options with the -a logical AND option and finds all open sockets belonging to the www-data user:
You are allowed to place the -a option wherever you like as lsof will still detect the relevant options.
Using Regular Expressions
lsof has support for regular expressions. Regular expressions begin and end with a
forward slash (/) character. The ^ character denotes the beginning of a line whereas $
denotes the end of the line. Each dot (.) character represents a single character in
the output.
The following lsof command will find all commands that have precisely five characters:
lsof -c /^.....$/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
netns 18 root cwd DIR 8,0 4096 2 /
netns 18 root rtd DIR 8,0 4096 2 /
netns 18 root txt unknown /proc/18/exe
jfsIO 210 root cwd DIR 8,0 4096 2 /
jfsIO 210 root rtd DIR 8,0 4096 2 /
jfsIO 210 root txt unknown /proc/210/exe
kstrp 461 root cwd DIR 8,0 4096 2 /
kstrp 461 root rtd DIR 8,0 4096 2 /
kstrp 461 root txt unknown /proc/461/exe
Output For Other Programs
Using the -F option, lsof generates output that is suitable for processing by scripts
written in programming languages such as awk, perl and python.
The following command will display each field of the lsof output in a separate line:
sudo lsof -n -i4 -a -i TCP:ssh -F
p812
g812
R1
csshd
u0
Lroot
f3
au
l
tIPv4
.
.
.
Providing various arguments to the -F option allows you to generate less output – notice that the process ID
and the file descriptor are always printed in the output. As an example, the following command
will only print the process ID, which is preceded by the p character, the file descriptor, which
is preceded by the f character, and the protocol name of each entry, which is preceded by
the P character:
sudo lsof -n -i4 -a -i TCP:ssh -FP
p812
f3
PTCP
p22352
f3
PTCP
p22361
f3
PTCP
Note
For the full list of options supported by -F, you should visit the manual page of lsof.
Additional Examples
Show All Open TCP Files
Similar to the aforementioned UDP command, the following command will display all open TCP files/connections:
The lsof -i -n -P command can be also written as lsof -i -nP or alternatively as lsof -nPi – writing it as lsof -inP would generate a syntax error because lsof
thinks that np is a parameter to -i.
SSH Connections
The following command finds all established SSH connections to the local machine:
The following command produces the same output as the previous command, but will do so more quickly because the -i TCP
option limits the amount of information lsof prints, which mean that grep will have less data
to process:
sudo lsof -i TCP | grep ssh | grep ESTABLISHED
Alternatively, you can execute the following command to find all established SSH
connections:
sudo lsof -nP -iTCP -sTCP:ESTABLISHED | grep SSH
Showing Processes that are Listening to a Particular Port
The following command shows all network connections that listen to port number 22
(ssh) using either UDP or TCP:
One of the most frequent uses of lsof is determining which program listens to a given TCP port.
The following command will print TCP processes that are in the LISTEN state by using the -s option to provide a protocol and protocol state:
Other possible states of a TCP connection are CLOSED, SYN-SENT, SYN-RECEIVED, ESTABLISHED, CLOSE-WAIT, LAST-ACK, FIN-WAIT-1, FIN-WAIT-2, CLOSING, and TIME-WAIT.
Finding Information on a Given Protocol
The next lsof command shows open UDP files that use the NTP (Network Time Protocol) port only:
The output displays connections that use either IPv4 or IPv6. If you want to display
the connections that use IPv4 only, you can run the following command:
lsof uses the data found in the /etc/services file to map a port number to a
service. You can disable this functionality by using the –P option as follows:
Determine Which Processes are Accessing a Given File
With lsof you can find the processes that are accessing a given file. For example, by running the lsof command on it’s own file you can determine the processes that are accessing it:
There are two lines in the above output because the /usr/bin/lsof file is being accessed twice, by
both which(1) and lsof.
If you are only interested in the process ID of the processes that are accessing
a file, you can use the -t option to suppress header lines:
sudo lsof -t `which lsof`
25157
25158
A process ID can commonly be used for easily killing a process using the kill(1) command,
however this is something that should only be executed with great care.
List Open Files Under a Given Directory
The +Dlsof command will display all open files under a given directory,
which in this case is /etc, as well as the name of the process that keeps a
file or a directory open:
sudo lsof +D /etc
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae 669 avahi cwd DIR 8,0 4096 745751 /etc/avahi
avahi-dae 669 avahi rtd DIR 8,0 4096 745751 /etc/avahi
List Files that are Opened by a Specific User
Another option is to locate the files opened by
any user, including web and database users.
The following command lists all open files opened by the www-data user:
sudo lsof -u www-data
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php5-fpm 1066 www-data cwd DIR 8,0 4096 2 /
php5-fpm 1066 www-data rtd DIR 8,0 4096 2 /
...
The next variation finds all ESTABLISHED connections owned by the www-data user:
Last, the next command will find all processes except the ones owned by www-data by using the ^ character:
sudo lsof -u ^www-data
COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd 1 root cwd DIR 8,0 4096 2 /
systemd 1 root rtd DIR 8,0 4096 2 /
systemd 1 root txt REG 8,0 1120992 1097764 /lib/systemd/systemd
...
If the user name you are trying to use does not exist, you will get an error message
similar to the following:
sudo lsof -u doesNotExist
lsof: can't get UID for doesNotExist
lsof 4.89
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-E] [+|-e s] [+|-f[gG]]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
Kill All Processes Owned by a User
The following command will kill all of the processes owned by the www-data user:
Caution
Please be careful when combining lsof with the kill(1) command. Do not try to
test similar commands on a live server unless you are absolutely certain you will not experience issues – for testing purposes you can use a disposable Docker image or something similar.
sudo kill -9 `lsof -t -u www-data`
Find All Network Activity from a Given User
The following command lists all network activity by a user named mtsouk:
lsof -a -u mtsouk -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 22361 mtsouk 3u IPv4 8613370 0t0 TCP li140-253.members.linode.com:ssh->ppp-2-86-23-29.home.otenet.gr:60032 (ESTABLISHED)
On the other hand, the following command lists all network activity from processes not owned by
the root or the www-data user:
If you process the output of lsof with some traditional UNIX command line tools, like grep and awk,
you can calculate the total number of TCP and UDP connections:
The lsof –i command lists all Internet connections whereas awk extracts the 8th
field, which is the value of the NODE column and sort sorts the output. Then, the uniq –c command counts how many times each line exists. Last, the grep –v 'TCP|UDP'
command displays the lines that contain the TCP or the UDP word in them.
Summary
lsof is a powerful diagnostic tool capable of a significant number of ways that you can combine its command line options to troubleshoot various issues administrators can find themselves facing. As this guide has only provided a few examples of how to use this tool, additional options can be combined for various effects that can be specifically suited to your needs.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.