<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>linux command tutorial Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/linux-command-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Thu, 13 Dec 2018 06:49:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>Uniq on Linux</title>
		<link>https://www.osradar.com/uniq-on-linux/</link>
					<comments>https://www.osradar.com/uniq-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[osradar_editor]]></dc:creator>
		<pubDate>Thu, 13 Dec 2018 06:49:30 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[linux command tutorial]]></category>
		<category><![CDATA[linux tutorial]]></category>
		<category><![CDATA[uniq]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=8336</guid>

					<description><![CDATA[<p>Linux, by default, comes up with a huge collection of handy and powerful tools that can make the life a ton easier. Does your workload requires lots of manipulation of text files and strings? Then you may be already familiar with the “uniq” command. It’s quite common in that type of workspace. Are you new [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/uniq-on-linux/">Uniq on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Linux, by default, comes up with a huge collection of handy and powerful tools that can make the life a ton easier. Does your workload requires lots of manipulation of text files and strings? Then you may be already familiar with the “uniq” command. It’s quite common in that type of workspace.</p>
<p>Are you new to “uniq”? Don’t worry! Let’s have a look at “uniq” and its usage.</p>
<p>What “uniq” is</p>
<p>Linux comes up with a big collection of tools and features. “uniq” is one of them. The tool works on the command line interface. The purpose of this tool is reporting and/or omitting repeated lines or strings of a file.</p>
<p>The tool just filters adjacent matching from INPUT (standard input) and write out to OUTPUT (standard output). If no option is specified, the tool will merge all the occurrences into the first occurrence.</p>
<h1>Uniq usage</h1>
<p>At first, let’s grab a text file to work with. For demo purpose, my “demo.txt” contains a number of duplicate entries.</p>
<ul>
<li>
<h3>Omitting duplicates on a file</h3>
</li>
</ul>
<pre class="">bat demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8338 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-1.png" alt="" width="1039" height="336" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-1.png 1039w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-1-300x97.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-1-768x248.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-1-1024x331.png 1024w" sizes="(max-width: 1039px) 100vw, 1039px" /></p>
<p><em>Note – Instead of “cat”, I’m using <a href="https://www.osradar.com/bat-advanced-cat-for-linux/">“bat” – a beautiful clone of “cat” with additional advanced features</a>.</em></p>
<p>Now, open up the file with “uniq” –</p>
<pre class="">uniq demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8339 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-2.png" alt="" width="1045" height="479" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-2.png 1045w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-2-300x138.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-2-768x352.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-2-1024x469.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-2-916x420.png 916w" sizes="(max-width: 1045px) 100vw, 1045px" /></p>
<ul>
<li>
<h3>Displaying the number of repetition</h3>
</li>
</ul>
<p>Using the “-c” flag, you can also ask “uniq” how many times a repeated line is repeated.</p>
<pre class="">bat demo.txt

uniq -c demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8340 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-3.png" alt="" width="1039" height="480" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-3.png 1039w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-3-300x139.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-3-768x355.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-3-1024x473.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-3-909x420.png 909w" sizes="(max-width: 1039px) 100vw, 1039px" /></p>
<ul>
<li>
<h3>Printing the “duplicates” ONLY</h3>
</li>
</ul>
<p>Need to figure out the duplicates ONLY? Then use the “-d” flag with “uniq”.</p>
<pre class="">bat demo.txt

uniq -d demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8341 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-4.png" alt="" width="1041" height="387" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-4.png 1041w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-4-300x112.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-4-768x286.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-4-1024x381.png 1024w" sizes="(max-width: 1041px) 100vw, 1041px" /></p>
<ul>
<li>
<h3>Printing the “unique” ONLY</h3>
</li>
</ul>
<p>If you need to work with the unique lines ONLY, then you should use the “-u” flag.</p>
<pre class="">bat demo.txt

uniq -u demo.txt</pre>
<p>&nbsp;</p>
<p><img loading="lazy" class="size-full wp-image-8346 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-9.png" alt="" width="1051" height="452" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-9.png 1051w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-9-300x129.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-9-768x330.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-9-1024x440.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-9-977x420.png 977w" sizes="(max-width: 1051px) 100vw, 1051px" /></p>
<ul>
<li>
<h3>Disable case sensitivity</h3>
</li>
</ul>
<p>When “uniq” is checking the strings, all the characters are case-sensitive, so, “Viktor” and “viktor” are different entry. Need to disable the case sensitivity? Then use the “-i” parameter.</p>
<pre class="">bat demo.txt

uniq -i demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8342 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-5.png" alt="" width="1039" height="491" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-5.png 1039w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-5-300x142.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-5-768x363.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-5-1024x484.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-5-889x420.png 889w" sizes="(max-width: 1039px) 100vw, 1039px" /></p>
<ul>
<li>
<h3>Sorting and finding duplicates</h3>
</li>
</ul>
<p>In most of the cases, the duplicates may be scattered throughout the entire file. When you use “uniq” on that file, it can be misleading and confusing. So, what to do?</p>
<p>Well, sort out the file contents first and then, do the “uniq” thing!</p>
<pre class="">bat demo.txt

sort demo.txt | uniq -c</pre>
<p><img loading="lazy" class="size-full wp-image-8343 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-6.png" alt="" width="1043" height="479" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-6.png 1043w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-6-300x138.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-6-768x353.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-6-1024x470.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-6-915x420.png 915w" sizes="(max-width: 1043px) 100vw, 1043px" /></p>
<ul>
<li>
<h3>Ignoring characters</h3>
</li>
</ul>
<p>In cases, you may need to ignore the presence of a first few characters in the file. In that case, use the “-s” flag followed by the number of character you’d like to omit from the OUTPUT.</p>
<p>bat demo.txt</p>
<pre class="">uniq -s 3 demo.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8344 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-7.png" alt="" width="1041" height="472" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-7.png 1041w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-7-300x136.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-7-768x348.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-7-1024x464.png 1024w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-7-926x420.png 926w" sizes="(max-width: 1041px) 100vw, 1041px" /></p>
<ul>
<li>
<h3>Exporting the output to a file</h3>
</li>
</ul>
<p>It’s quite easy to export the output of any command into a file. Just <a href="https://www.osradar.com/export-linux-command-outputs-to-a-file/">check out this awesome tutorial on exporting command output to a file</a>.</p>
<pre class="">uniq -u demo.txt &gt; demo-1.txt

bat demo-1.txt</pre>
<p><img loading="lazy" class="size-full wp-image-8345 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/12/uniq-8.png" alt="" width="1046" height="265" srcset="https://www.osradar.com/wp-content/uploads/2018/12/uniq-8.png 1046w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-8-300x76.png 300w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-8-768x195.png 768w, https://www.osradar.com/wp-content/uploads/2018/12/uniq-8-1024x259.png 1024w" sizes="(max-width: 1046px) 100vw, 1046px" /></p>
<p>Enjoy!</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/uniq-on-linux/">Uniq on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/uniq-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>lsof Command on Linux</title>
		<link>https://www.osradar.com/lsof-command-on-linux/</link>
					<comments>https://www.osradar.com/lsof-command-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[osradar_editor]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 17:15:35 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[linux command]]></category>
		<category><![CDATA[linux command tutorial]]></category>
		<category><![CDATA[lsof]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=7853</guid>

					<description><![CDATA[<p>Linux is one of the most powerful platforms that offer the utmost control over your system. It comes up with a number of pre-installed tools that can be of tremendous power. “lsof” is such a command that’s available on almost all the UNIX/Linux systems. “lsof” stands for “list open files”. Using this tool, you can [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/lsof-command-on-linux/">lsof Command on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Linux is one of the most powerful platforms that offer the utmost control over your system. It comes up with a number of pre-installed tools that can be of tremendous power. “lsof” is such a command that’s available on almost all the UNIX/Linux systems.</p>
<p>“lsof” stands for “list open files”. Using this tool, you can identify what files are being used by which process/program. In the UNIX/Linux environment, every single thing is a file (pipes, directories, devices, sockets etc.). So, having a good knowledge of “lsof” can provide you with useful info in lots of scenarios.</p>
<p>Let’s check out some of the use cases of “lsof”.</p>
<h1>“lsof” usage</h1>
<p>The basic usage is listing all the open files that belong to all the active processes –</p>
<pre class="">sudo lsof</pre>
<p><img loading="lazy" class="size-full wp-image-7854 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-1.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-1.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-1-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p><img loading="lazy" class="size-full wp-image-7855 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-2.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-2.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-2-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>The purpose of using “sudo” is to list ALL the files that are actively being used. Otherwise, it may not properly identify all the files.</p>
<p>You can also check if a specific file is being used.</p>
<pre class="">sudo lsof &lt;file_name&gt;</pre>
<p>&nbsp;</p>
<p><img loading="lazy" class="size-full wp-image-7856 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-3.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-3.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-3-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>Suppose, you need to identify what processes are accessing the file(s) of a certain directory.</p>
<pre class="">lsof +D &lt;directory_path&gt;

lsof +d &lt;directory_path&gt;</pre>
<p><img loading="lazy" class="size-full wp-image-7857 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-4.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-4.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-4-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /> <img loading="lazy" class="size-full wp-image-7858 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-5.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-5.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-5-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>Here, “+D” indicates to include the subdirectories within the directory. If you don’t want to include them, then use “+d”.</p>
<p>Need to find out the file(s) a certain process is accessing? Then use the “-c” flag. The command structure will be –</p>
<pre class="">lsof -c &lt;process_name&gt; -c &lt;process_name&gt;</pre>
<p><img loading="lazy" class="size-full wp-image-7859 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-6.png" alt="" width="1060" height="475" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-6.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-6-300x134.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-6-768x344.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-6-1024x459.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-6-937x420.png 937w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>“lsof” is capable of handling multiple “-c” flags.</p>
<p>You can also list the processes that are using a certain mount point. For this purpose, the following structure must be followed –</p>
<pre class="">lsof &lt;mount_point&gt;</pre>
<p><img loading="lazy" class="size-full wp-image-7860 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-7.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-7.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-7-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>Not all the processes in your system run under a certain user. For example, “root”, “&lt;account_username&gt;” etc. You can also tell “lsof” to show the files that are being used as a certain user permission.</p>
<pre class="">lsof -u &lt;username&gt;</pre>
<p><img loading="lazy" class="size-full wp-image-7861 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-8.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-8.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-8-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>From the above example, need to exclude a certain user? Then you have to use “^” flag.</p>
<pre class="">lsof -u ^&lt;username&gt;</pre>
<p><img loading="lazy" class="size-full wp-image-7862 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-9.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-9.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-9-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>It’s also possible to list all the files a certain process is accessing. Use the “-p” flag in this case. Note that as the value for the flag “-p”, you need to provide the PID of that process</p>
<pre class="">lsof -p &lt;PID&gt;</pre>
<p>&nbsp;</p>
<p>List all the network connections –</p>
<pre>lsof -i</pre>
<p><img loading="lazy" class="size-full wp-image-7863 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-10.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-10.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-10-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>Another interesting ability of &#8220;lsof&#8221; is listing all the processes that are listening to a specific port. For example, you want to find out what processes are using the 25 port.</p>
<pre class="">lsof -i TCP:25</pre>
<p>Need to scan a range of port, say, 1-25? Then the command structure will be the following one &#8211;</p>
<pre class="">lsof -i TCP:1-25</pre>
<p>You can also filter your result by IPv4 and IPv6.</p>
<pre class=""># IPv4

lsof -i 4

# IPv6

lsof -i 6</pre>
<p><img loading="lazy" class="size-full wp-image-7883 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-0.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-0.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-0-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /> <img loading="lazy" class="size-full wp-image-7884 aligncenter" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-00.png" alt="" width="1058" height="236" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-00.png 1058w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-00-300x67.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-00-768x171.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-00-1024x228.png 1024w" sizes="(max-width: 1058px) 100vw, 1058px" /></p>
<p>Need to find out all the available options of “lsof”? You can get the help of the man page.</p>
<pre class="">man lsof</pre>
<p><img loading="lazy" class="alignnone size-full wp-image-7864" src="https://www.osradar.com/wp-content/uploads/2018/11/lsof-11.png" alt="" width="1060" height="734" srcset="https://www.osradar.com/wp-content/uploads/2018/11/lsof-11.png 1060w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-300x208.png 300w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-768x532.png 768w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-1024x709.png 1024w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-100x70.png 100w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-218x150.png 218w, https://www.osradar.com/wp-content/uploads/2018/11/lsof-11-607x420.png 607w" sizes="(max-width: 1060px) 100vw, 1060px" /></p>
<p>You can also export the man page for future usage. <a href="https://www.osradar.com/export-linux-command-outputs-to-a-file/">Learn how to export Linux command output to a text file</a>.</p>
<p>Enjoy!</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/lsof-command-on-linux/">lsof Command on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/lsof-command-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
