<?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 Commands - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/linux-commands/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Tue, 24 Apr 2018 14:04:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>Linux Commands - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Use CAT Command on Linux System?</title>
		<link>https://techyaz.com/linux/how-to-use-cat-command-in-linux-system/</link>
					<comments>https://techyaz.com/linux/how-to-use-cat-command-in-linux-system/#respond</comments>
		
		<dc:creator><![CDATA[Angelo Marquez]]></dc:creator>
		<pubDate>Tue, 24 Apr 2018 13:55:44 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[RedHat Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2126</guid>

					<description><![CDATA[<p>This time we continue with the explanation of simple Linux command to learn basics. The command chosen today is the cat command. Cat comes from the word &#8220;concatenate&#8220;.  In short the main utility is to display the contents of one or&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/linux/how-to-use-cat-command-in-linux-system/">How to Use CAT Command on Linux System?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This time we continue with the explanation of simple Linux command to learn basics. The command chosen today is the cat command. Cat comes from the word &#8220;<em>concatenate</em>&#8220;.  In short the main utility is to display the contents of one or more files in the terminal. Here, i will describe most useful examples of CAT command.</p>
<p>Normally the cat command is applied for basically three things in particular:</p>
<ul>
<li>Display the contents of a file</li>
<li>Copy text files to another text file</li>
<li>Append a text file&#8217;s contents to another text file</li>
</ul>
<p>Being a UNIX command it is ported to all GNU/LINUX distributions and of course, it has options to expand and vary the power of the command itself.  Let&#8217;s see the output at the terminal if we do the following command:</p>
<pre><span style="color: #0000ff;"><strong>cat --help</strong></span></pre>
<p>The command shows us a quick help on the cat command including its options.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-2127" src="http://techyaz.com/wp-content/uploads/2018/04/1-cat-min.png" alt="cat help" width="616" height="504" srcset="https://techyaz.com/wp-content/uploads/2018/04/1-cat-min.png 616w, https://techyaz.com/wp-content/uploads/2018/04/1-cat-min-300x245.png 300w" sizes="(max-width: 616px) 100vw, 616px" /></p>
<p>The basic usage syntax is:</p>
<p><strong><em>cat [OPTION] [FILE]&#8230;</em></strong></p>
<p>And the list of commands is shown in this table:</p>
<table>
<tbody>
<tr>
<td width="234"><strong>Option</strong></td>
<td width="342"><strong>Description</strong></td>
</tr>
<tr>
<td width="234">-A</td>
<td width="342">&#8211;show-all Euivalent to –vET</td>
</tr>
<tr>
<td width="234">-b</td>
<td width="342">&#8211;number-nonblank number nonempty output lines, overrides -n</td>
</tr>
<tr>
<td width="234">-e</td>
<td width="342">equivalent to -vE</td>
</tr>
<tr>
<td width="234">-E</td>
<td width="342">&#8211;show-ends display $ at end of each line</td>
</tr>
<tr>
<td width="234">-n</td>
<td width="342">&#8211;number number all outpout lines</td>
</tr>
<tr>
<td width="234">-s</td>
<td width="342">&#8211;squeeze-blank  suppress repeated empty output lines</td>
</tr>
<tr>
<td width="234">-t</td>
<td width="342">equivalent to -vT</td>
</tr>
<tr>
<td width="234">-T</td>
<td width="342">&#8211;show-tabs display TAB characters as ^I</td>
</tr>
<tr>
<td width="234">-u</td>
<td width="342">(ignored)</td>
</tr>
<tr>
<td width="234">-V</td>
<td width="342">&#8211;show-nonprinting   use ^ and M- notation, except for LFD and TAB</td>
</tr>
</tbody>
</table>
<p>Don&#8217;t worry; we&#8217;ll examine the most useful options with several examples.</p>
<h5><span style="color: #993300;">Display Content of File</span></h5>
<p>If we want to show the content of a text file, the syntax would be:</p>
<pre><span style="color: #0000ff;"><strong>cat path_of_the_archive</strong></span></pre>
<p>I&#8217;m going to show the content of a file called file1.txt located in the Example folder. Run below command to display file1.txt content.</p>
<pre><span style="color: #0000ff;"><strong>cat file1.txt</strong></span></pre>
<p><img decoding="async" class="alignnone size-full wp-image-2128" src="http://techyaz.com/wp-content/uploads/2018/04/2-cat-min.png" alt="Show content of a file using CAT" width="842" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/2-cat-min.png 842w, https://techyaz.com/wp-content/uploads/2018/04/2-cat-min-300x60.png 300w, https://techyaz.com/wp-content/uploads/2018/04/2-cat-min-768x152.png 768w" sizes="(max-width: 842px) 100vw, 842px" /></p>
<p>And there we have the content of the file shown on the terminal in above image.</p>
<p>If you would like to display the contents of several files, simply place them next. Run below command to display contents of two files file1.txt and file2.txt.</p>
<pre><span style="color: #0000ff;"><strong>cat file1.txt file2.txt</strong></span></pre>
<p>The exit at the terminal would be as follows:</p>
<p><img decoding="async" class="alignnone size-full wp-image-2129" src="http://techyaz.com/wp-content/uploads/2018/04/3-cat-min.png" alt="Display content of several files" width="805" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/3-cat-min.png 805w, https://techyaz.com/wp-content/uploads/2018/04/3-cat-min-300x62.png 300w, https://techyaz.com/wp-content/uploads/2018/04/3-cat-min-768x159.png 768w" sizes="(max-width: 805px) 100vw, 805px" /></p>
<p>You can see the contents of both files one by one in above image.</p>
<h5><span style="color: #993300;">Identify Specific File Content</span></h5>
<p>As we can see in above image, it simply shows the contents of file 1 and when it ends, it immediately shows the content of file 2 as if they were &#8220;concatenated&#8221;. If you would like to know where the content of each file ends, then use the <strong>-e</strong> option to show a <strong>$</strong> at the end of the file.</p>
<pre><span style="color: #0000ff;"><strong>cat –e file1.txt file2.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2130" src="http://techyaz.com/wp-content/uploads/2018/04/4-cat-min.png" alt="Display where the content of the file ends" width="815" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/4-cat-min.png 815w, https://techyaz.com/wp-content/uploads/2018/04/4-cat-min-300x61.png 300w, https://techyaz.com/wp-content/uploads/2018/04/4-cat-min-768x157.png 768w" sizes="auto, (max-width: 815px) 100vw, 815px" /></p>
<h5><span style="color: #993300;">Add Number of Lines in Output</span></h5>
<p>If you want to display the number of lines along with the file content then you can show it by adding <strong>-n</strong> option. Run below command to display the line numbers while displaying the file content.</p>
<pre><span style="color: #0000ff;"><strong>cat –n file1.txt file2.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2131" src="http://techyaz.com/wp-content/uploads/2018/04/5-cat-min.png" alt="display the number of lines in a file" width="887" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/5-cat-min.png 887w, https://techyaz.com/wp-content/uploads/2018/04/5-cat-min-300x56.png 300w, https://techyaz.com/wp-content/uploads/2018/04/5-cat-min-768x145.png 768w" sizes="auto, (max-width: 887px) 100vw, 887px" /></p>
<h5><span style="color: #993300;">Copy Contents of One file to Another</span></h5>
<p>We can also copy the content of one text file to another using CAT command. Run below command to copy content of file1.txt to file4.txt.</p>
<pre><span style="color: #0000ff;"><strong>cat file1.txt &gt; file4.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2132" src="http://techyaz.com/wp-content/uploads/2018/04/6-cat-min.png" alt="Copy content of file 1 to file 2" width="698" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/6-cat-min.png 698w, https://techyaz.com/wp-content/uploads/2018/04/6-cat-min-300x72.png 300w" sizes="auto, (max-width: 698px) 100vw, 698px" /></p>
<p>In this case, the command reads the contents of file1.txt and overwrites the contents of the new file. If it does not exist, it is simply created. Now we can validate above command whether contents have been copied to not. Now we proceed to show the contents of <em>file4.txt</em> to verify that it made the &#8220;copy&#8221;. Display content of file4.txt by running below command.</p>
<pre><span style="color: #0000ff;"><strong>cat file4.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2133" src="http://techyaz.com/wp-content/uploads/2018/04/7-cat-min.png" alt="Validate the copied content" width="655" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/7-cat-min.png 655w, https://techyaz.com/wp-content/uploads/2018/04/7-cat-min-300x76.png 300w" sizes="auto, (max-width: 655px) 100vw, 655px" /></p>
<p>We can see the content is same as file1.txt in above image.</p>
<h5><span style="color: #993300;">Combine or Append the Content of One File to Another</span></h5>
<p>The cat command also allows us to combine or append a text file data to another one, thanks to the operator &gt;&gt;</p>
<p>In this case, we will combine the content of file1.txt with that of file2.txt</p>
<pre><span style="color: #0000ff;"><strong>cat file1.txt &gt;&gt; file2.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2134" src="http://techyaz.com/wp-content/uploads/2018/04/8-cat-min.png" alt="Combine the content of two files into one file" width="693" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/8-cat-min.png 693w, https://techyaz.com/wp-content/uploads/2018/04/8-cat-min-300x72.png 300w" sizes="auto, (max-width: 693px) 100vw, 693px" /></p>
<p>And then we check the contents of the file2.txt file to validate it.</p>
<pre><span style="color: #0000ff;"><strong>cat file2.txt</strong></span></pre>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2135" src="http://techyaz.com/wp-content/uploads/2018/04/9-cat-min.png" alt="Validate the combined content" width="626" height="167" srcset="https://techyaz.com/wp-content/uploads/2018/04/9-cat-min.png 626w, https://techyaz.com/wp-content/uploads/2018/04/9-cat-min-300x80.png 300w" sizes="auto, (max-width: 626px) 100vw, 626px" /></p>
<p>We can see contents have been combined in to this file. Basically the command takes the content of file1.txt and places it at the end of the file2.txt file</p>
<p>As a conclusion we can say that the cat command is a useful and important command to work with text files in GNU/LINUX and everything about the terminal. It is very useful for managing service configuration files on a server.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/rhel/11-examples-ls-command-list-files-linux/" target="_blank" rel="noopener">11 Examples of ls command to List Files in Linux</a></strong></li>
<li><strong><a href="http://techyaz.com/rhel/linux-user-administration-add-delete-modify-user-accounts/" target="_blank" rel="noopener">Add, Delete &amp; Modify Linux User Accounts</a></strong></li>
<li><strong><a href="http://techyaz.com/rhel/how-to-reset-or-change-user-password-on-linux/" target="_blank" rel="noopener">How to Reset or Change Linux User Passwords?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-on-linux/change-hostname-red-hat-linux-server/" target="_blank" rel="noopener">How to Change Linux Server Name?</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/linux/how-to-use-cat-command-in-linux-system/">How to Use CAT Command on Linux System?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/linux/how-to-use-cat-command-in-linux-system/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>11 Examples of ls Command to List Files in Linux</title>
		<link>https://techyaz.com/linux/11-examples-ls-command-list-files-linux/</link>
					<comments>https://techyaz.com/linux/11-examples-ls-command-list-files-linux/#respond</comments>
		
		<dc:creator><![CDATA[Angelo Marquez]]></dc:creator>
		<pubDate>Tue, 20 Mar 2018 10:21:41 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[RedHat Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[Linux Interview Questions and Answers]]></category>
		<category><![CDATA[Linux Tools]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1958</guid>

					<description><![CDATA[<p>Normally, the work of system administrators consists of an almost permanent use of the terminal; this is because servers with GNU/LINUX-based systems, for security reasons, do not have a graphical desktop environment. And this means that we have to use&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/linux/11-examples-ls-command-list-files-linux/">11 Examples of ls Command to List Files in Linux</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Normally, the work of system administrators consists of an almost permanent use of the terminal; this is because servers with GNU/LINUX-based systems, for security reasons, do not have a graphical desktop environment. And this means that we have to use the terminal for basically everything from the simplest or most complex tasks. Today we will learn the <strong>ls</strong> command utility that allows us to list files and folders from the terminal. Here we will also describe different combinations and options that can be used with ls command to get different output.</p>
<h3><span style="color: #333399;"><strong>LIST FILES IN LINUX: &#8220;ls&#8221; COMMAND</strong></span><strong> </strong></h3>
<p>As it was said, the command <strong>ls</strong> allows you to list files and folders of a specific path, is easy to use and is very useful and used in the daily work. The command has several options to improve the listings. In a terminal, we can invoke the help of the command <strong>ls</strong> in this way.</p>
<pre><span style="color: #0000ff;"><strong>ls --help</strong><strong> </strong></span></pre>
<p>Above command will display all options available for ls command to list the files and folders. In this way we get the syntax of usage and options as output per terminal.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1959" src="http://techyaz.com/wp-content/uploads/2018/03/1-ls-cmd-min.png" alt="List all ls command options" width="758" height="736" srcset="https://techyaz.com/wp-content/uploads/2018/03/1-ls-cmd-min.png 758w, https://techyaz.com/wp-content/uploads/2018/03/1-ls-cmd-min-300x291.png 300w" sizes="auto, (max-width: 758px) 100vw, 758px" /></p>
<p>As all options will not cover in one single screenshot so i have scrolled the above screen and taken another screenshots to cover all options in screenshots that has been displayed below.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1960" src="http://techyaz.com/wp-content/uploads/2018/03/2-ls-cmd-min.png" alt="Display all ls command options" width="764" height="736" srcset="https://techyaz.com/wp-content/uploads/2018/03/2-ls-cmd-min.png 764w, https://techyaz.com/wp-content/uploads/2018/03/2-ls-cmd-min-300x289.png 300w" sizes="auto, (max-width: 764px) 100vw, 764px" /></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1961" src="http://techyaz.com/wp-content/uploads/2018/03/3-ls-cmd-min.png" alt="Display all ls command options" width="750" height="736" srcset="https://techyaz.com/wp-content/uploads/2018/03/3-ls-cmd-min.png 750w, https://techyaz.com/wp-content/uploads/2018/03/3-ls-cmd-min-300x294.png 300w" sizes="auto, (max-width: 750px) 100vw, 750px" /></p>
<p>As we can see the documentation is extensive, but don&#8217;t worry we will examine the most useful and used options. The basic syntax of the command is:</p>
<pre><span style="color: #0000ff;"><strong>ls [options] [file|dir]</strong></span></pre>
<p>Although it is possible to use ls from the most basic form only by typing:</p>
<pre><span style="color: #008000;"><strong>#List files from your given directory.</strong></span>
<span style="color: #0000ff;"><strong>ls</strong></span></pre>
<p>With this we only list the files that are in the directory where we are located in the terminal. For example, if we wanted to list everything in the root directory of our GNU/LINUX distribution it would be with the command:</p>
<pre><span style="color: #008000;"><strong>#List everything in the root directory</strong></span>
<span style="color: #0000ff;"><strong>ls /</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1962" src="http://techyaz.com/wp-content/uploads/2018/03/4-ls-cmd-min-1024x150.png" alt="Run ls / to display all directories" width="1024" height="150" srcset="https://techyaz.com/wp-content/uploads/2018/03/4-ls-cmd-min-1024x150.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/4-ls-cmd-min-300x44.png 300w, https://techyaz.com/wp-content/uploads/2018/03/4-ls-cmd-min-768x112.png 768w, https://techyaz.com/wp-content/uploads/2018/03/4-ls-cmd-min.png 1366w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>It was easy, wasn&#8217;t it?</p>
<h5><span style="color: #993300;">Most Important Options of the Command &#8220;ls&#8221;</span></h5>
<p><strong>ls</strong> as well as all GNU/LINUX commands have options that modify the basic command execution result. Here is a list of the most outstanding ones for this command.</p>
<table style="height: 441px;" width="784">
<tbody>
<tr>
<td width="198"><strong>Options</strong></td>
<td width="374"><strong>Description</strong></td>
</tr>
<tr>
<td width="198">-a</td>
<td width="374"> Do not ignore entries starting with .</td>
</tr>
<tr>
<td width="198">-A</td>
<td width="374"> Do not list implied . And ..</td>
</tr>
<tr>
<td width="198">-d</td>
<td width="374">List directories themselves, not their contents</td>
</tr>
<tr>
<td width="198">-i</td>
<td width="374">print the index number of each file</td>
</tr>
<tr>
<td width="198">-l</td>
<td width="374">Use a long listing format.  Displays information such as permissions and owner of the folder or file.</td>
</tr>
<tr>
<td width="198">-r</td>
<td width="374">reverse order while sorting</td>
</tr>
<tr>
<td width="198">-R</td>
<td width="374">List subdirectories recursively.  Displays the contents of the directory subfolders.</td>
</tr>
<tr>
<td width="198">-s</td>
<td width="374">print the allocated size of each file, in blocks</td>
</tr>
<tr>
<td width="198">-S</td>
<td width="374">sort by file size, largest first</td>
</tr>
<tr>
<td width="198">-t</td>
<td width="374">sort by modification time, newest first</td>
</tr>
<tr>
<td width="198">-U</td>
<td width="374">do not sort; list entries in directory order</td>
</tr>
<tr>
<td style="text-align: left;" width="198">-X</td>
<td style="text-align: left;" width="374">sort alphabetically by entry extension</td>
</tr>
</tbody>
</table>
<h3><span style="color: #333399;"> Examples of Command &#8220;ls&#8221;</span></h3>
<p>Here i have given different examples of command ls that you can use to fulfill different requirements.</p>
<h5><span style="color: #993300;">List Hidden Files </span></h5>
<p>We can use option -a if we want to list the hidden files of a specific folder, it would be enough to write:</p>
<pre><span style="color: #0000ff;"><strong>ls –a path</strong></span></pre>
<p>In my case it would be something like that:</p>
<pre><span style="color: #0000ff;"><strong>ls –a /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1963" src="http://techyaz.com/wp-content/uploads/2018/03/5-ls-cmd-min-1024x217.png" alt="list hidden files in Linux" width="1024" height="217" srcset="https://techyaz.com/wp-content/uploads/2018/03/5-ls-cmd-min-1024x217.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/5-ls-cmd-min-300x63.png 300w, https://techyaz.com/wp-content/uploads/2018/03/5-ls-cmd-min-768x162.png 768w, https://techyaz.com/wp-content/uploads/2018/03/5-ls-cmd-min.png 1182w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>You can see all hidden files as well in above screenshot. We can identify hidden files by looking at the output as such files or folders start with dot (.).</p>
<h5><span style="color: #993300;">Display Files with their Index Number</span></h5>
<p>We can list files with their index number by running below command. To show files/folders with their index number we will use the option –i along with command ls. You can see i have used below command and output is showing in below image.</p>
<pre><span style="color: #0000ff;"><strong>ls -i /home/angelo/
</strong></span><strong><em> </em></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1964" src="http://techyaz.com/wp-content/uploads/2018/03/6-ls-cmd-min-1024x195.png" alt="List folders with index number" width="1024" height="195" srcset="https://techyaz.com/wp-content/uploads/2018/03/6-ls-cmd-min-1024x195.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/6-ls-cmd-min-300x57.png 300w, https://techyaz.com/wp-content/uploads/2018/03/6-ls-cmd-min-768x147.png 768w, https://techyaz.com/wp-content/uploads/2018/03/6-ls-cmd-min.png 1142w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">List Files with full Details (Permissions, Index no, Owner, Create Date etc.)</span></h5>
<p>We can use ls command to display information such as permissions and owner of the folder or file. We will be using option -I to show complete information about files and folders as shown in below screenshot.</p>
<pre><span style="color: #0000ff;"><strong>ls -l /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1965" src="http://techyaz.com/wp-content/uploads/2018/03/7-ls-cmd-min.png" alt="Display all details of folders and files" width="778" height="462" srcset="https://techyaz.com/wp-content/uploads/2018/03/7-ls-cmd-min.png 778w, https://techyaz.com/wp-content/uploads/2018/03/7-ls-cmd-min-300x178.png 300w, https://techyaz.com/wp-content/uploads/2018/03/7-ls-cmd-min-768x456.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></p>
<p>This output shows us more specific information about what we have in the folder: First it shows the permissions on the folder, its index number, the owner of the folder, who created the folder, its size in kb, the date it was modified and the folder name.</p>
<h5><span style="color: #993300;">List Files or Folders in a Reverse Order</span></h5>
<p>ls command also gives an option to sort files and folders in reverse order. We can use -r option to show files and folders in a reverse order as shown in below screenshot after running below command.</p>
<pre><span style="color: #0000ff;"><strong>ls –r  /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1966" src="http://techyaz.com/wp-content/uploads/2018/03/8-ls-cmd-min-1024x139.png" alt="Display files and folders in reverse order" width="1024" height="139" srcset="https://techyaz.com/wp-content/uploads/2018/03/8-ls-cmd-min-1024x139.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/8-ls-cmd-min-300x41.png 300w, https://techyaz.com/wp-content/uploads/2018/03/8-ls-cmd-min-768x105.png 768w, https://techyaz.com/wp-content/uploads/2018/03/8-ls-cmd-min.png 1366w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">List Subdirectories Recursively</span></h5>
<p>We can List subdirectories recursively by adding the -R option with ls command.  It will display the contents of the directory subfolders. Run below command to display the result.</p>
<pre><span style="color: #0000ff;"><strong>ls –R /home/angelo/</strong></span></pre>
<h5><strong><em> </em></strong><span style="color: #993300;">Display list of Directories Only</span></h5>
<p>We can use -d and an asterisk option to list and show only the directories. Have a look at below command that has displayed the list of directories under /home/angelo.</p>
<pre><span style="color: #0000ff;"><strong>ls –d */home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1967" src="http://techyaz.com/wp-content/uploads/2018/03/9-ls-cmd-min.png" alt="Show directories with astrick" width="980" height="184" srcset="https://techyaz.com/wp-content/uploads/2018/03/9-ls-cmd-min.png 980w, https://techyaz.com/wp-content/uploads/2018/03/9-ls-cmd-min-300x56.png 300w, https://techyaz.com/wp-content/uploads/2018/03/9-ls-cmd-min-768x144.png 768w" sizes="auto, (max-width: 980px) 100vw, 980px" /></p>
<h5><span style="color: #993300;">Display Files Sort by their File Size</span></h5>
<p>Run below command to display files sort by file size. It is possible with the option –S.</p>
<pre><span style="color: #0000ff;"><strong>ls -S /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1968" src="http://techyaz.com/wp-content/uploads/2018/03/10-ls-cmd-min-1024x145.png" alt="Display files sort by file size" width="1024" height="145" srcset="https://techyaz.com/wp-content/uploads/2018/03/10-ls-cmd-min-1024x145.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/10-ls-cmd-min-300x42.png 300w, https://techyaz.com/wp-content/uploads/2018/03/10-ls-cmd-min-768x108.png 768w, https://techyaz.com/wp-content/uploads/2018/03/10-ls-cmd-min.png 1260w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">Sort by Date/Time</span></h5>
<p>We can option -t to display files sort by date/time. Run below command to see the output that is also showing in below screenshot.</p>
<pre><span style="color: #0000ff;"><strong>ls –t /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1969" src="http://techyaz.com/wp-content/uploads/2018/03/11-ls-cmd-min-1024x152.png" alt="Display files sort by date time" width="1024" height="152" srcset="https://techyaz.com/wp-content/uploads/2018/03/11-ls-cmd-min-1024x152.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/11-ls-cmd-min-300x45.png 300w, https://techyaz.com/wp-content/uploads/2018/03/11-ls-cmd-min-768x114.png 768w, https://techyaz.com/wp-content/uploads/2018/03/11-ls-cmd-min.png 1252w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">Display Files as they were Created</span></h5>
<p>Use option -U to show folders and files in no order at all. It will display just as they are created.</p>
<pre><span style="color: #0000ff;"><strong>ls –U /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1970 size-large" src="http://techyaz.com/wp-content/uploads/2018/03/12-ls-cmd-min-1024x132.png" alt="Display Files as they were created" width="1024" height="132" srcset="https://techyaz.com/wp-content/uploads/2018/03/12-ls-cmd-min-1024x132.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/12-ls-cmd-min-300x39.png 300w, https://techyaz.com/wp-content/uploads/2018/03/12-ls-cmd-min-768x99.png 768w, https://techyaz.com/wp-content/uploads/2018/03/12-ls-cmd-min.png 1366w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">Sort by File Extension</span></h5>
<p>We can use option -X with ls command to sort files by their extension names. You can see this in below screenshot.</p>
<pre><span style="color: #0000ff;"><strong>ls –X /home/angelo/</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-1971" src="http://techyaz.com/wp-content/uploads/2018/03/13-ls-cmd-min-1024x142.png" alt="Display files sort by file extension" width="1024" height="142" srcset="https://techyaz.com/wp-content/uploads/2018/03/13-ls-cmd-min-1024x142.png 1024w, https://techyaz.com/wp-content/uploads/2018/03/13-ls-cmd-min-300x42.png 300w, https://techyaz.com/wp-content/uploads/2018/03/13-ls-cmd-min-768x107.png 768w, https://techyaz.com/wp-content/uploads/2018/03/13-ls-cmd-min.png 1366w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h5><span style="color: #993300;">Sort by Modified Files</span></h5>
<p>We can use combination of options <strong>-ltr</strong> to show last modification file or directory date. Simply run below command to display the output.</p>
<pre><strong><span style="color: #0000ff;">ls -lrt</span></strong>

<strong><span style="color: #0000ff;">ls -lrt [path]</span></strong></pre>
<p>In conclusion we can say that the <strong>ls</strong> command, even when it is relatively easy to use, is one of the tools most used by system administrators.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/rhel/red-hat-enterprise-linux-interview-questions-answers/" target="_blank" rel="noopener">RHEL Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="http://techyaz.com/rhel/linux-user-administration-add-delete-modify-user-accounts/" target="_blank" rel="noopener">Linux User Administration &#8211; Add, Delete &amp; Modify User Accounts</a></strong></li>
<li><strong><a href="http://techyaz.com/rhel/install-htop-monitor-linux-processes/" target="_blank" rel="noopener">Install HTop and Use it to Monitor Linux Processes</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-on-linux/change-hostname-red-hat-linux-server/" target="_blank" rel="noopener">How to Change Host Name of RHEL system?</a></strong></li>
<li><strong><a href="http://techyaz.com/rhel/how-to-reset-or-change-user-password-on-linux/" target="_blank" rel="noopener">How to Reset or Change Linux User Account Passwords?</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/linux/11-examples-ls-command-list-files-linux/">11 Examples of ls Command to List Files in Linux</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/linux/11-examples-ls-command-list-files-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
