<?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 Archives - Coding Campus</title>
	<atom:link href="https://codingcampus.net/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://codingcampus.net/category/linux/</link>
	<description>Learn to Code</description>
	<lastBuildDate>Tue, 09 May 2023 16:22:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://codingcampus.net/wp-content/uploads/2022/11/Coding-Campus-Logo-150x150.png</url>
	<title>Linux Archives - Coding Campus</title>
	<link>https://codingcampus.net/category/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">212689819</site>	<item>
		<title>How to Find a File in Linux</title>
		<link>https://codingcampus.net/how-to-find-a-file-in-linux/</link>
					<comments>https://codingcampus.net/how-to-find-a-file-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[codingxcampus013]]></dc:creator>
		<pubDate>Thu, 09 Mar 2023 19:47:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/how-to-find-a-file-in-linux/</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-find-a-file-in-linux/">How to Find a File in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Do you ever no longer remember where exactly you put a file on your Linux computer or server? You&#8217;re confident that it <em>was</em> saved somewhere but can&#8217;t find exactly where. For Windows users, the obvious solution is to use Explorer&#8217;s &#8216;Find&#8217; function. But what if you&#8217;re unsure about how to find a file in Linux?</p>
<p>We&#8217;ve compiled a list of methods you can use to locate missing files in Linux. As always, we include tools for both more experienced users and beginners, and we hope that these suggestions allow you to avoid the traumatic loss of important data!</p>
<h2>Using the grep command to find a file by its contents</h2>
<p>Grep has been part of Unix for so long that you will often see the term used as a verb in Linux discussions online (it&#8217;s generally synonymous with &#8220;search locally&#8221;). It can be thought of as the ultimate &#8220;pattern recognition tool&#8221;. However, Grep should only be used to search for the contents of a file rather than finding items using their filename.</p>
<p>Now, let&#8217;s look at how grep is actually used. Let&#8217;s say you had a file in your ~/Documents directory called &#8216;Give.txt&#8217;. The contents of the file are as follows:</p>
<pre><code>What's real can't die
You only get what you give
You're gonna get what you give
Don't give up
Just don't be afraid to leave</code></pre>
<p>Of course, these are the lyrics to a <a href="https://www.youtube.com/watch?v=cPAEFnVZVOs&amp;ab_channel=wares_for_coin">famous song by New Radicals</a>. It&#8217;s an excellent example in this case, as it highlights how useful grep is and a few of its behaviors that might appear idiosyncratic at first to new users.</p>
<p>From our Documents directory, we&#8217;re going to execute the following command:<code></code></p>
<pre><code>grep you give.txt</code></pre>
<p>Press return, and you&#8217;ll see that it returns every line with the word &#8220;you&#8221; in it:</p>
<figure id="attachment_3951" aria-describedby="caption-attachment-3951" style="width: 726px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-lowercase-you-e1645361092348.png"><img fetchpriority="high" decoding="async" class="wp-image-3951 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-lowercase-you-e1645361092348.png" alt="Finding files using Grep. Query is &quot;you&quot; in lower case." width="736" height="483" /></a><figcaption id="caption-attachment-3951" class="wp-caption-text">Looking for instances of the term &#8220;you&#8221; in give.txt</figcaption></figure>
<p>Now, let&#8217;s try another command (remember to include the escaped apostrophe):</p>
<pre><code>grep don't give.txt</code></pre>
<p>And here is our result:</p>
<figure id="attachment_3954" aria-describedby="caption-attachment-3954" style="width: 726px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-lowercase-dont.png"><img decoding="async" class="wp-image-3954 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-lowercase-dont.png" alt="Finding files using grep. Query is &quot;don't&quot; in lower case." width="736" height="483" /></a><figcaption id="caption-attachment-3954" class="wp-caption-text">Looking for instances of the word &#8220;don&#8217;t&#8221; in &#8216;give.txt&#8217;</figcaption></figure>
<p>As you can see, the fifth line was identified; however, because grep is case-sensitive by default, the fourth line (&#8220;Don&#8217;t give up&#8221;) was not returned.</p>
<p>Now, we&#8217;ll use the &#8220;-i&#8221; flag to turn off case-sensitivity in our following query (I&#8217;ve also now used quotations to avoid relying on the backslash character this time):</p>
<pre><code>grep -i "don't" give.txt</code></pre>
<figure id="attachment_3956" aria-describedby="caption-attachment-3956" style="width: 717px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-anycase-dont.png"><img decoding="async" class="wp-image-3956 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-anycase-dont.png" alt="Finding files in Grep. Query is &quot;don't&quot;, with case sensitivity turned off." width="727" height="339" /></a><figcaption id="caption-attachment-3956" class="wp-caption-text">The &#8216;-i&#8217; flag will allow us to turn off case sensitivity.</figcaption></figure>
<p>This time, we can see that every instance of the word &#8211; regardless of case &#8211; is brought back. If you use the &#8220;-i&#8221; flag when searching for &#8220;you&#8221;, you&#8217;ll also notice that it now highlights the capitalized appearances of the word as well:</p>
<figure id="attachment_3970" aria-describedby="caption-attachment-3970" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-anycase-you.png"><img loading="lazy" decoding="async" class="wp-image-3970 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-grep-anycase-you.png" alt="Using Grep to find instances of the word &quot;you&quot; in any case" width="763" height="249" /></a><figcaption id="caption-attachment-3970" class="wp-caption-text">Using Grep to find instances of the term &#8220;you&#8221; in any case</figcaption></figure>
<h2>Using the find command to find a file by its name</h2>
<p>While grep allows users to query the contents of files on their computer, the find tool provides an efficient way to locate items based on their actual filename.</p>
<p>The most basic use of the find command is as follows:</p>
<pre><code>find .</code></pre>
<p>The period (&#8216;.&#8217;) tells the command to return every file and subdirectory found if we search from the present working directory. Essentially, all this is is a good starting point.</p>
<figure id="attachment_3959" aria-describedby="caption-attachment-3959" style="width: 717px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-period.png"><img loading="lazy" decoding="async" class="wp-image-3959 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-period.png" alt="Finding all files of any type within the present working directory and its subdirectories" width="727" height="339" /></a><figcaption id="caption-attachment-3959" class="wp-caption-text">Finding all files within the present working directory and its subdirectories</figcaption></figure>
<p>However, there are a variety of additional arguments which allow us to get a lot more specific with how we use the find tool. For example, the following command will return all subdirectories from the present location (with &#8216;d&#8217; standing for &#8220;directories&#8221;):</p>
<pre><code>find . -type d</code></pre>
<figure id="attachment_3960" aria-describedby="caption-attachment-3960" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-type-d.png"><img loading="lazy" decoding="async" class="wp-image-3960 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-type-d.png" alt="Finding all files with type 'directory' (i.e. only folders)" width="763" height="285" /></a><figcaption id="caption-attachment-3960" class="wp-caption-text">Finding all files with type &#8216;directory&#8217; (i.e., only folders)</figcaption></figure>
<p>Alternatively, we can return only files by typing:</p>
<pre><code>find . -type f</code></pre>
<figure id="attachment_3963" aria-describedby="caption-attachment-3963" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-type-f.png"><img loading="lazy" decoding="async" class="wp-image-3963 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-type-f.png" alt="Finding files which are not subdirectories (i.e. single files only)" width="763" height="195" /></a><figcaption id="caption-attachment-3963" class="wp-caption-text">Finding files that are not subdirectories (i.e., single files only)</figcaption></figure>
<p>The find command becomes especially useful for locating misplaced files when switching out the &#8220;-type&#8221; option with &#8220;-name&#8221;. For example, we can return all ePub files (either in the current directory or within its subdirectories) by using:</p>
<pre><code>find . -name "*.epub"</code></pre>
<figure id="attachment_3973" aria-describedby="caption-attachment-3973" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-ext-epub.png"><img loading="lazy" decoding="async" class="wp-image-3973 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-ext-epub.png" alt="Using the find command to locate files with the .ePub extension" width="763" height="249" /></a><figcaption id="caption-attachment-3973" class="wp-caption-text">Using the find command to locate files with the .ePub extension</figcaption></figure>
<p>Or, we can find all ePub files with the word &#8220;great&#8221; in the name by typing:</p>
<pre><code>find . -name "*great*epub"</code></pre>
<figure id="attachment_3974" aria-describedby="caption-attachment-3974" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-great-epub-lowercase.png"><img loading="lazy" decoding="async" class="wp-image-3974 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-find-great-epub-lowercase.png" alt="Using the find tool to locate the lowercase word &quot;great&quot; in filenames with a .epub extension" width="763" height="249" /></a><figcaption id="caption-attachment-3974" class="wp-caption-text">Using the find tool to locate the lowercase word &#8220;great&#8221; in filenames with a .epub extension</figcaption></figure>
<p>And, as with the grep tool, we can choose to make our query case-insensitive:</p>
<pre><code>find . -iname "*great*epub"</code></pre>
<figure id="attachment_3975" aria-describedby="caption-attachment-3975" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-great-epub-anycase.png"><img loading="lazy" decoding="async" class="wp-image-3975 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-great-epub-anycase.png" alt="Using find to locate ePub files with the word &quot;great&quot; (in any case) in their title" width="763" height="249" /></a><figcaption id="caption-attachment-3975" class="wp-caption-text">Using find to locate ePub files with the word &#8220;great&#8221; (in any case) in their title</figcaption></figure>
<p>And, if we want to narrow it down even further, we can combine options too:</p>
<pre><code>find . -type f -iname "*GrEat*"</code></pre>
<figure id="attachment_3976" aria-describedby="caption-attachment-3976" style="width: 753px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-combining-options.png"><img loading="lazy" decoding="async" class="wp-image-3976 size-full" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-combining-options.png" alt="Combining the options provided by the find tool" width="763" height="249" /></a><figcaption id="caption-attachment-3976" class="wp-caption-text">Combining the options provided by the find tool</figcaption></figure>
<p>The above example is slightly redundant, as we only have files with the word &#8216;great&#8217; in their title. However, if the ~/Downloads folder also had a subdirectory called &#8220;Great Expectations&#8221;, it would be omitted from our results as we have specifically included the &#8216;-type f&#8217; option.</p>
<h2>Find files using Catfish</h2>
<p>For those who prefer not to use the command line, you can use a GTK3 application called Catfish. This can be installed from the software repository of your Linux distribution by typing:</p>
<pre><code>sudo apt-get install catfish -y</code></pre>
<p>Other popular choices for Linux users who prefer to use GUI to locate files include fsearch, Cerebro, and Terrier.</p>
<p><a href="http://codingcampus.net/wp-content/uploads/2022/02/find-files-catfish-epub.png"><img loading="lazy" decoding="async" class="wp-image-3965 size-full aligncenter" src="http://codingcampus.net/wp-content/uploads/2022/02/find-files-catfish-epub.png" alt="Finding all ePub files using Catfish" width="650" height="517" /></a></p>
<p>Catfish can provide complex searches (based on criteria like date of modification, file type, and so on). While it&#8217;s not quite as powerful as grep or find, it should suit most users fine.</p>
<p>The post <a href="https://codingcampus.net/how-to-find-a-file-in-linux/">How to Find a File in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-find-a-file-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1595</post-id>	</item>
		<item>
		<title>How to Check CentOS Version</title>
		<link>https://codingcampus.net/how-to-check-centos-version/</link>
					<comments>https://codingcampus.net/how-to-check-centos-version/#respond</comments>
		
		<dc:creator><![CDATA[codingxcampus013]]></dc:creator>
		<pubDate>Thu, 09 Mar 2023 16:22:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/how-to-check-centos-version/</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-check-centos-version/">How to Check CentOS Version</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Though there is certainly reason to be sad about CentOS&#8217; discontinuation, the good news is that the midstream version will receive long-term support up until at least June 2024. So, for any of you who would still like to continue using the RHEL-derived OS, you&#8217;re more than welcome to. In this guide, we&#8217;ll show you how to check the CentOS version running on your machine. I&#8217;ll be checking using CentOS 8 (8.4.2105).</p>
<h2>Check CentOS Using RPM (Easiest)</h2>
<p>The RPM Package Manager provides the quickest and easiest way to find out which version of CentOS is running.</p>
<ol>
<li>From the home screen, click &#8216;Activities&#8217; in the top left-hand corner.
<p><figure id="attachment_2124" aria-describedby="caption-attachment-2124" style="width: 872px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png"><img loading="lazy" decoding="async" class="wp-image-2124 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png" alt="CentOS Article Screen 1" width="882" height="665" /></a><figcaption id="caption-attachment-2124" class="wp-caption-text">Click &#8216;activities&#8217; to bring up the search box</figcaption></figure></li>
<li>Then, type &#8216;terminal&#8217; into the search box which appears. Now, click the terminal button.
<p><figure id="attachment_2125" aria-describedby="caption-attachment-2125" style="width: 873px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen2.png"><img loading="lazy" decoding="async" class="wp-image-2125 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen2.png" alt="CentOS Article Screen 2" width="883" height="665" /></a><figcaption id="caption-attachment-2125" class="wp-caption-text">Search for &#8216;terminal&#8217;</figcaption></figure></li>
<li>In the terminal window, enter the following command:</li>
</ol>
<pre><code>rpm -q centos-linux-release</code></pre>
<p>Then hit enter.</p>
<figure id="attachment_2126" aria-describedby="caption-attachment-2126" style="width: 872px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen3.png"><img loading="lazy" decoding="async" class="wp-image-2126 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen3.png" alt="CentOS Article Screen 3" width="882" height="666" /></a><figcaption id="caption-attachment-2126" class="wp-caption-text">The rpm command should let you see exactly which version of CentOS is installed</figcaption></figure>
<p>As you can see, the exact version of CentOS (including the major release number, as well as the revision).</p>
<h2>Check CentOS Version Using Your Release File</h2>
<p>You might not know this, but there&#8217;s actually a text file included in your CentOS installation. It&#8217;s located in the &#8216;/etc/&#8217; directory, and it&#8217;s very handy for checking your release version.</p>
<ol>
<li>From the home screen, click &#8216;Activities&#8217; in the top left-hand corner.
<p><figure id="attachment_2124" aria-describedby="caption-attachment-2124" style="width: 872px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png"><img loading="lazy" decoding="async" class="wp-image-2124 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png" alt="CentOS Article Screen 1" width="882" height="665" /></a><figcaption id="caption-attachment-2124" class="wp-caption-text">Click &#8216;activities&#8217; to bring up the search box</figcaption></figure></li>
<li>Now, click the Terminal icon which appears on the left-hand sidebar.
<p><figure id="attachment_2127" aria-describedby="caption-attachment-2127" style="width: 874px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen4.png"><img loading="lazy" decoding="async" class="wp-image-2127 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen4.png" alt="CentOS Article Screen 4" width="884" height="668" /></a><figcaption id="caption-attachment-2127" class="wp-caption-text">This time, we&#8217;re using the Terminal icon (circled in red here)</figcaption></figure></li>
<li>In the window which opens, enter the following command:</li>
</ol>
<pre><code>cat /etc/centos-release</code></pre>
<p>Then hit enter.</p>
<figure id="attachment_2128" aria-describedby="caption-attachment-2128" style="width: 873px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen5.png"><img loading="lazy" decoding="async" class="wp-image-2128 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen5.png" alt="CentOS Article Screen 5" width="883" height="663" /></a><figcaption id="caption-attachment-2128" class="wp-caption-text">The &#8216;cat&#8217; command provides another easy way to view our current version of CentOS</figcaption></figure>
<p>There&#8217;s also a way to find out more details about your release, by using the following command instead:</p>
<pre><code>cat /etc/os-release</code></pre>
<p>And hit enter.</p>
<figure id="attachment_2129" aria-describedby="caption-attachment-2129" style="width: 875px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen6.png"><img loading="lazy" decoding="async" class="wp-image-2129 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen6.png" alt="CentOS Article Screen 6" width="885" height="665" /></a><figcaption id="caption-attachment-2129" class="wp-caption-text">Using the &#8216;os-release&#8217; file provides more information about our current installation</figcaption></figure>
<p>As you can see, this command doesn&#8217;t provide your exact release number, but it does provide other useful information such as the &#8216;Platform_ID&#8217; and the &#8216;Pretty Name&#8217;.</p>
<h2>Check the &#8216;Pretty Name&#8217; Using the GUI</h2>
<p>If you&#8217;re also content just to know which major release of CentOS you&#8217;re using, you can do this using the graphical interface. This method might also be useful if &#8211; for whatever reason &#8211; you can&#8217;t use the terminal.</p>
<ol>
<li>Again, click &#8216;activities&#8217; in the top left-hand corner.
<p><figure id="attachment_2124" aria-describedby="caption-attachment-2124" style="width: 872px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png"><img loading="lazy" decoding="async" class="wp-image-2124 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen1.png" alt="CentOS Article Screen 1" width="882" height="665" /></a><figcaption id="caption-attachment-2124" class="wp-caption-text">Click &#8216;activities&#8217; to bring up the search</figcaption></figure></li>
<li>Then, type &#8216;version&#8217; into the search box which appears.
<p><figure id="attachment_2130" aria-describedby="caption-attachment-2130" style="width: 875px" class="wp-caption alignnone"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen7.png"><img loading="lazy" decoding="async" class="wp-image-2130 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen7.png" alt="CentOS Article Screen 7" width="885" height="666" /></a><figcaption id="caption-attachment-2130" class="wp-caption-text">Typing &#8216;version&#8217; should bring up the &#8216;About&#8217; app</figcaption></figure></li>
<li>You can now see the release of CentOS you&#8217;re currently running. Although less detailed, this method only requires using the GUI.</li>
</ol>
<figure id="attachment_2131" aria-describedby="caption-attachment-2131" style="width: 877px" class="wp-caption aligncenter"><a href="http://codingcampus.net/wp-content/uploads/2022/01/Screen8.png"><img loading="lazy" decoding="async" class="wp-image-2131 size-full" src="http://codingcampus.net/wp-content/uploads/2022/01/Screen8.png" alt="CentOS Article Screen 8" width="887" height="666" /></a><figcaption id="caption-attachment-2131" class="wp-caption-text">Find your CentOS version in the GUI</figcaption></figure>
<p><strong>Bonus Tip:</strong> You can click the &#8216;View Updates&#8217; button in the bottom right-hand area of the above screenshot to begin updating your current installation (if needed).</p>
<p>The post <a href="https://codingcampus.net/how-to-check-centos-version/">How to Check CentOS Version</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-check-centos-version/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1580</post-id>	</item>
		<item>
		<title>Regular Expressions in grep (Regex) (With Examples)</title>
		<link>https://codingcampus.net/regular-expressions-in-grep-regex/</link>
					<comments>https://codingcampus.net/regular-expressions-in-grep-regex/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Sat, 04 Feb 2023 01:36:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=445</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/regular-expressions-in-grep-regex/">Regular Expressions in grep (Regex) (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Linux Regular Expressions (Regex) are special characters that help search data based on matching complex patterns. They are used in many Linux command-line utilities, such as <em>rename</em>, <em>bash</em>, <em>sed</em>, <em>grep</em>, <em>etc</em>. In this guide, we&#8217;ll be focusing on the <em>grep</em> command.</p>
<h3>grep Command Purpose and Syntax</h3>
<p><em>grep</em> searches for patterns in a file(s). <em>patterns</em> refer to one or more patterns separated by newline characters, and grep prints each line that matches a defined pattern.</p>
<pre><code># grep [operators...] patterns [file...]</code></pre>
<h2>Types of Regular Expressions</h2>
<p>There are three main types of Linux regular expressions:</p>
<h2>Basic Regular Expressions</h2>
<p>A Basic Regular Expression (<strong>BRE</strong>) is a regular expression consisting of the exact characters of the string to be matched.</p>
<h3>Basic Regular Expression Operators</h3>
<ul>
<li><strong>. &#8212;</strong> replaces any character</li>
<li><strong>^ &#8212;</strong> matches start of string</li>
<li><strong>$ &#8212;</strong> matches end of string</li>
<li><strong>* &#8212;</strong> matches up zero or more times the preceding character</li>
<li><strong> &#8212;</strong> represent special characters</li>
<li><strong>() &#8212;</strong> groups regular expressions</li>
<li><strong>? &#8212; </strong>matches up exactly one character</li>
</ul>
<h3>Basic Regular Expression &#8211; Example</h3>
<p>In this example, we list all comments in the <em>/etc/adduser.conf</em> file. (Note that the # sign prefaces comments in .conf files).</p>
<pre><code># grep ^# /etc/adduser.conf</code></pre>
<p><img loading="lazy" decoding="async" class="size-full wp-image-20600" src="http://codingcampus.net/wp-content/uploads/2022/07/regular-expressions-in-grep-regex-basic-regular-expression.png" alt="Display all comments (#) in /etc/adduser.conf." width="1431" height="933" /><br />
Display all comments (#) in /etc/adduser.conf.</p>
<h2>Interval Regular Expressions</h2>
<p>An Interval Regular Expression (<strong>IRE</strong>) is a regular expression that reports the number of characters in a string.</p>
<h3>Interval Regular Expression Operators</h3>
<ul>
<li><strong>{n} &#8212;</strong> matches the preceding character appearing &#8216;n&#8217; times exactly</li>
<li><strong>{n,m} &#8212;</strong> matches the preceding character appearing &#8216;n&#8217; times but not more than m</li>
<li><strong>{n, } &#8212;</strong> matches the preceding character only when it appears &#8216;n&#8217; times or more</li>
</ul>
<h3>Interval Regular Expression &#8211; Example</h3>
<p>In this example, we&#8217;ll find all content in the <em>/etc/adduser.conf</em> that contains the &#8216;<strong>l</strong>&#8216; character exactly two times consecutively.</p>
<pre><code># grep -E l{2} /etc/adduser.conf</code></pre>
<figure id="attachment_20861" aria-describedby="caption-attachment-20861" style="width: 1434px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20861" src="http://codingcampus.net/wp-content/uploads/2022/07/regular-expressions-in-grep-regex-interval-regular-expression.png" alt="Display content in the /etc/adduser.conf that contains the ‘l’ character exactly two times consecutively." width="1444" height="725" /><figcaption id="caption-attachment-20861" class="wp-caption-text">Display content in the /etc/adduser.conf that contains the &#8216;l&#8217; character exactly two times consecutively.</figcaption></figure>
<h3>Extended Regular Expressions</h3>
<p>An Extended Regular Expression (<strong>ERE</strong>) is a regular expression that contains more than one expression.</p>
<h3>Extended Regular Expressions Operators</h3>
<p>The extended regular expression contains more than one expression.</p>
<ul>
<li><strong>+  &#8212;</strong> matches one or more occurrences of the previous character</li>
<li><strong>? &#8212;</strong> matches zero or one occurrence of the previous character</li>
</ul>
<h3>Extended Regular Expression &#8211; Example</h3>
<p>In this example, we&#8217;ll search <em>/etc/adduser.conf</em> where character &#8216;<strong>t</strong>&#8216; precedes character &#8216;<strong>a</strong>.&#8217;</p>
<pre><code># grep "t+a" /etc/adduser.con</code></pre>
<figure id="attachment_20863" aria-describedby="caption-attachment-20863" style="width: 1434px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20863" src="http://codingcampus.net/wp-content/uploads/2022/07/regular-expressions-in-grep-regex-extended-regular-expression.png" alt="Display content in the /etc/adduser.conf where character ‘t’ precedes character ‘a.’" width="1444" height="725" /><figcaption id="caption-attachment-20863" class="wp-caption-text">Display content in the /etc/adduser.conf where character &#8216;t&#8217; precedes character &#8216;a.&#8217;</figcaption></figure>
<p>The post <a href="https://codingcampus.net/regular-expressions-in-grep-regex/">Regular Expressions in grep (Regex) (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/regular-expressions-in-grep-regex/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">445</post-id>	</item>
		<item>
		<title>ln Command in Linux &#8211; Create Symbolic Links (With Examples)</title>
		<link>https://codingcampus.net/ln-command-in-linux/</link>
					<comments>https://codingcampus.net/ln-command-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Thu, 02 Feb 2023 17:21:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=439</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/ln-command-in-linux/">ln Command in Linux &#8211; Create Symbolic Links (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The ln command allows you to create a symbolic link. A symbolic link (symlink) is a special type of file that points to a directory or file.</p>
<h2>Types of Symbolic Links</h2>
<p>Before we delve into creating symbolic links, let&#8217;s first explore the two types of symbolic links &#8212; soft links and hard links.</p>
<h3>Soft Links</h3>
<p>Soft links point to the location or path of the original file or directory. Soft links are most often used when you want to quickly access a without typing the entire location. It&#8217;s also important to know if a symbolic link file is deleted, the original file or directory remains. However, the symbolic link will no longer work if the original file is moved or deleted.</p>
<h3>Hard Links</h3>
<p>Hard links, in contrast, point to data physically written to disks. They point to an inode or reference file that points to the data&#8217;s location. In short, this is much like creating a copy of the file in that you are creating a second filename that refers to the <em>inode</em> data of the original file. Hard links are not considered symbolic links in the purest sense of the word and are not often used by average Linux users.</p>
<h2>ln Command Purpose and Syntax</h2>
<p>The ln command allows you to create a hard or soft symbolic link. The syntax for the <em>ln</em> command is:</p>
<pre><code># ln [options] [file/directory] ...  [link name]</code></pre>
<h2>Create a Symbolic Link to a File</h2>
<p>Let&#8217;s create a symbolic link to a file. In our first example, we will create a link on our desktop, <em>/home/mtravisrose/Desktop/blue-link.txt,</em> to a file in the home directory, <em>/home/mtravisrose/blue.txt.</em></p>
<p>Open your terminal and enter:</p>
<pre><code># ln -sv blue.txt /home/mtravisrose/Desktop/blue-link.txt</code></pre>
<figure id="attachment_20553" aria-describedby="caption-attachment-20553" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20553" src="http://codingcampus.net/wp-content/uploads/2022/07/ln-command-in-linux-to-create-symbolic-links-file-example.png" alt="Create a symbolic link - File Example." width="1106" height="777" /><figcaption id="caption-attachment-20553" class="wp-caption-text">Create a symbolic link &#8211; File Example.</figcaption></figure>
<p>Note that <em>blue-link.txt</em> symbolic link was successfully created. The &#8216;<strong>l</strong>&#8216; at the beginning of <em>blue-link.txt &#8211; &gt; blue.txt</em> file listing denotes that the file is a symbolic link file.</p>
<h2>Create a Symbolic Link to a Directory</h2>
<p>Let&#8217;s create a symbolic link to a file. In our first example, we&#8217;re going to create a link on our home directory, <em>/home/mtravisrose/main-ssh-directory</em>, to a directory on our system, <em>/ssh</em>.</p>
<p>Open your terminal and enter:</p>
<pre><code># ln -s /ssh main-ssh-directory</code></pre>
<figure id="attachment_20552" aria-describedby="caption-attachment-20552" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20552" src="http://codingcampus.net/wp-content/uploads/2022/07/ln-command-in-linux-to-create-symbolic-links-directory.png" alt="Create a symbolic link - Directory Example." width="1106" height="777" /><figcaption id="caption-attachment-20552" class="wp-caption-text">Create a symbolic link &#8211; Directory Example.</figcaption></figure>
<p>Note that <em>main-ssh-directory</em> symbolic link was successfully created. The &#8216;<strong>l</strong>&#8216; at the beginning of <em>main-ssh-directory &#8211; &gt; /ssh</em> directory listing denotes that the file is a symbolic link file.</p>
<h3>Create a Hard Link</h3>
<p>Creating hard links in Linux is almost identical to creating soft links. In our example, we&#8217;re going to create a hard link, <em>red.hard</em>, from a file<em>, </em><em>red.txt</em>.</p>
<p>Open your terminal and enter:</p>
<pre><code># ln red.txt red.hard</code></pre>
<figure id="attachment_20551" aria-describedby="caption-attachment-20551" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20551" src="http://codingcampus.net/wp-content/uploads/2022/07/ln-command-in-linux-to-create-symbolic-links-hard-link.png" alt="Create a symbolic link - hard link example." width="1106" height="777" /><figcaption id="caption-attachment-20551" class="wp-caption-text">Create a symbolic link &#8211; Hard Link Example.</figcaption></figure>
<p>You can see that the hard link, <em>red.hard</em>, was created from the file, <em>red.txt</em>. Note that the inode is the same for both files.</p>
<h2>Remove or &#8216;Unlink&#8217; a Symbolic Link</h2>
<p>Soft links can be removed in two separate ways: the <em>rm</em> command and the <em>unlink</em> command.</p>
<h3>Remove a Symbolic Link with <em>rm</em></h3>
<pre><code># rm /home/mtravisrose/Desktop/blue-link.txt</code></pre>
<figure id="attachment_20550" aria-describedby="caption-attachment-20550" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20550" src="http://codingcampus.net/wp-content/uploads/2022/07/ln-command-in-linux-to-create-symbolic-links-remove.png" alt="Remove a symbolic link." width="1106" height="777" /><figcaption id="caption-attachment-20550" class="wp-caption-text">Note that the symbolic link, blue-link.txt, was successfully removed, yet the original file, blue.txt, remains.</figcaption></figure>
<h3>Remove a Symbolic Link with <em>unlink</em></h3>
<pre><code># unlink main-ssh-directory</code></pre>
<figure id="attachment_20549" aria-describedby="caption-attachment-20549" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20549" src="http://codingcampus.net/wp-content/uploads/2022/07/ln-command-in-linux-to-create-symbolic-links-unlink.png" alt="Unlink a symbolic link." width="1106" height="777" /><figcaption id="caption-attachment-20549" class="wp-caption-text">Note that the symbolic link, main-ssh-directory, was successfully removed.</figcaption></figure>
<p>It&#8217;s important to note that only the symbolic link has been removed with both examples, and the actual file or directory remains.</p>
<p>The <em>rm</em> command does not work on hard links. You must use <em>unlink</em>.</p>
<p>The post <a href="https://codingcampus.net/ln-command-in-linux/">ln Command in Linux &#8211; Create Symbolic Links (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/ln-command-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">439</post-id>	</item>
		<item>
		<title>How to Check Ubuntu Version</title>
		<link>https://codingcampus.net/how-to-check-ubuntu-version/</link>
					<comments>https://codingcampus.net/how-to-check-ubuntu-version/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Wed, 01 Feb 2023 23:05:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=427</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-check-ubuntu-version/">How to Check Ubuntu Version</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Ubuntu issues a new Ubuntu release every six months. These releases are supported for nine months. LTS, or Long Term Support, releases, however, are issued every two years and supported for five years.<span id="ezoic-pub-ad-placeholder-158" class="ezoic-adpicker-ad"></span></p>
<p>This article will show you how to find your Ubuntu version using the GUI or command line.</p>
<p><strong>Note:</strong> We&#8217;re using Ubuntu LTS 22.04, codenamed <em>Jammy Jellyfish</em>, for this guide.</p>
<h2>Check Ubuntu Version via the GUI</h2>
<p>Left-click your mouse in the upper-right-hand corner of your screen. Select <strong>Settings</strong>.</p>
<figure id="attachment_20512" aria-describedby="caption-attachment-20512" style="width: 1910px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20512" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-settings.png" alt="Click the upper-right-hand-corner." width="1920" height="1080" /><figcaption id="caption-attachment-20512" class="wp-caption-text">Click the upper-right-hand-corner.</figcaption></figure>
<p>You&#8217;ll see your Ubuntu version and a slew of other system-related info in the <strong>About</strong> window.</p>
<figure id="attachment_20513" aria-describedby="caption-attachment-20513" style="width: 1022px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20513" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-about.png" alt="The Ubuntu About window." width="1032" height="869" /><figcaption id="caption-attachment-20513" class="wp-caption-text">The Ubuntu About window.</figcaption></figure>
<h2>Check Ubuntu Version via the Command Line</h2>
<p>The examples below show you how to check your Ubuntu version from the command line. Open your terminal and run these commands.</p>
<h3>Check Ubuntu Version with hostnamectl</h3>
<pre><code># hostnamectl</code></pre>
<figure id="attachment_20521" aria-describedby="caption-attachment-20521" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20521" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-hostnamectl.png" alt="Output of hostnamectl." width="1106" height="803" /><figcaption id="caption-attachment-20521" class="wp-caption-text">Output of hostnamectl.</figcaption></figure>
<h3>Check Ubuntu Version with /etc/lsb-release</h3>
<pre><code># cat /etc/lsb-release</code></pre>
<figure id="attachment_20522" aria-describedby="caption-attachment-20522" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20522" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-etc-lsb-release.png" alt="Output of cat /etc/lsb-release." width="1106" height="803" /><figcaption id="caption-attachment-20522" class="wp-caption-text">Output of cat /etc/lsb-release.</figcaption></figure>
<h3>Check Ubuntu Version with lsb_release -a</h3>
<pre><code># lsb_release -a</code></pre>
<figure id="attachment_20527" aria-describedby="caption-attachment-20527" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20527" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-ls-b-a-release.png" alt="Output of lsb -a release." width="1106" height="803" /><figcaption id="caption-attachment-20527" class="wp-caption-text">Output of lsb_release -a.</figcaption></figure>
<h3>Check Ubuntu Version with /etc/os-release</h3>
<pre><code># cat /etc/os-release</code></pre>
<figure id="attachment_20534" aria-describedby="caption-attachment-20534" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-20534 size-full" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-etc-os-release-2.png" alt="Output of cat /etc/os-release." width="1106" height="803" /><figcaption id="caption-attachment-20534" class="wp-caption-text">Output of cat /etc/os-release.</figcaption></figure>
<h3>Check Ubuntu Version with /etc/issue</h3>
<pre><code># cat /etc/issue</code></pre>
<figure id="attachment_20529" aria-describedby="caption-attachment-20529" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20529" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-etc-issue-1.png" alt="Output of cat /etc/issue." width="1106" height="803" /><figcaption id="caption-attachment-20529" class="wp-caption-text">Output of cat /etc/issue.</figcaption></figure>
<h3>Check Ubuntu Version with neofetch</h3>
<p>Neofetch is a FOSS command-line utility to &#8216;fetch&#8217; system information.</p>
<p>First, you must install <em>neofetch</em>.</p>
<p>Open your terminal and enter:</p>
<pre><code># apt install neofetch</code></pre>
<p>Next, we run <em>neofetch</em>.</p>
<pre><code># neofetch</code></pre>
<figure id="attachment_20516" aria-describedby="caption-attachment-20516" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-20516" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-check-ubuntu-version-neofetch.png" alt="Output of neofetch." width="1106" height="803" /><figcaption id="caption-attachment-20516" class="wp-caption-text">Output of neofetch.</figcaption></figure>
<p>You&#8217;re presented with a &#8216;pretty&#8217; display of system-related information, including the OS version.</p>
<p>The post <a href="https://codingcampus.net/how-to-check-ubuntu-version/">How to Check Ubuntu Version</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-check-ubuntu-version/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">427</post-id>	</item>
		<item>
		<title>df Command in Linux (With Examples)</title>
		<link>https://codingcampus.net/df-command-in-linux/</link>
					<comments>https://codingcampus.net/df-command-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Thu, 26 Jan 2023 13:43:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=416</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/df-command-in-linux/">df Command in Linux (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The Linux command-line utility, <strong>df</strong> (disk free), is used to display the free disk space of a specific file system. There are options available to display the text you want, as well as filenames or directories to provide information on their filesystems.</p>
<p><strong>Note:</strong> Linux commands featured in this article are distro-independent, meaning they will work on any Linux distro.</p>
<h2>df Command Syntax</h2>
<p>The <strong>df</strong> command displays the amount of free space on the file system containing each file name. If no filename is provided, the free space on all mounted file systems is displayed. The syntax of the <strong>df</strong> command is as follows.</p>
<pre><code># df [option] [file]</code></pre>
<h3>df Columns</h3>
<p>These are the columns usually displayed with the <strong>df</strong> command.</p>
<ul>
<li><strong>File System</strong> &#8211; name of the disk partition.</li>
<li><strong>Size</strong> &#8211; total size of the file system.</li>
<li><strong>Used</strong> &#8211; total amount of space allocated to existing files on the file system.</li>
<li><strong>Available</strong> &#8211; total amount of space available on the file system.</li>
<li><strong>Percentage Used</strong> &#8211; percentage of the available space allocated to files in the file system.</li>
<li><strong>Mounted On</strong> &#8211; directory where the file system appears.</li>
</ul>
<h2>df Command Real-Life Scenarios</h2>
<p>While many options are available with the <strong>df</strong> command, we&#8217;ll only review those most used by Linux admins and users.</p>
<ol>
<li>If no file name is given, <strong>df</strong> displays all the space available on all currently mounted file systems:
<pre><code># df</code></pre>
<p><figure id="attachment_19068" aria-describedby="caption-attachment-19068" style="width: 901px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-19068" src="http://codingcampus.net/wp-content/uploads/2022/07/df-command-in-linux-df.png" alt="Output of df." width="911" height="569" /><figcaption id="caption-attachment-19068" class="wp-caption-text">The output of df.</figcaption></figure></li>
<li>If you specify a particular file directory or a file, <strong>df</strong> shows the mount information of that file or directory:
<pre><code># df filename</code></pre>
<p><figure id="attachment_19069" aria-describedby="caption-attachment-19069" style="width: 901px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-19069" src="http://codingcampus.net/wp-content/uploads/2022/07/df-command-in-linux-file.png" alt="The output of df /home/techobservatory." width="911" height="569" /><figcaption id="caption-attachment-19069" class="wp-caption-text">The output of df /home/techobservatory.</figcaption></figure></li>
<li>To display all mounted filesystems in human-readable format:
<pre><code># df -h</code></pre>
<p><figure id="attachment_19071" aria-describedby="caption-attachment-19071" style="width: 901px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-19071" src="http://codingcampus.net/wp-content/uploads/2022/07/df-command-in-linux-h-1.png" alt="The output of df -h." width="911" height="569" /><figcaption id="caption-attachment-19071" class="wp-caption-text">The output of df -h.</figcaption></figure></li>
<li>You can also use options together with the <strong>df</strong> command. For example, to see your mounted file systems, excluding temporary systems (<em><strong>tmpfs</strong></em>), in human-readable format:
<pre><code># df -hx tmpfs</code></pre>
<p><figure id="attachment_19072" aria-describedby="caption-attachment-19072" style="width: 901px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-19072" src="http://codingcampus.net/wp-content/uploads/2022/07/df-command-in-linux-hx-tmpfs.png" alt="The output of df -hx tmpfs." width="911" height="569" /><figcaption id="caption-attachment-19072" class="wp-caption-text">The output of df -hx tmpfs.</figcaption></figure></li>
</ol>
<p>The post <a href="https://codingcampus.net/df-command-in-linux/">df Command in Linux (With Examples)</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/df-command-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">416</post-id>	</item>
		<item>
		<title>How to Create a File in Linux</title>
		<link>https://codingcampus.net/how-to-create-a-file-in-linux/</link>
					<comments>https://codingcampus.net/how-to-create-a-file-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 02:09:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=400</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-create-a-file-in-linux/">How to Create a File in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Creating files using the command line is an essential skill for Linux users. There are several methods to create a file in Linux quickly. We will be creating text (.txt) files as examples.</p>
<p><strong>Note:</strong> Linux commands featured in this article are distro-independent, meaning they will work on any Linux distro.</p>
<h2>Using the touch Command</h2>
<p>The <strong>touch</strong> command is, arguably, the easiest command to create a new empty file.</p>
<p>To create a file with the <strong>touch</strong> command, from the command line, enter:</p>
<pre><code># touch newfile.txt</code></pre>
<p>Where <em><strong>newfile.txt</strong></em> is the name of the file to be created.</p>
<p>After we create the command, we can verify its existence with the <strong>ls -al</strong> command.</p>
<pre><code># ls -al</code></pre>
<figure id="attachment_18827" aria-describedby="caption-attachment-18827" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18827" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-touch.png" alt="Create the file with the touch command. Verify with ls -al." width="1106" height="621" /><figcaption id="caption-attachment-18827" class="wp-caption-text">The touch command can easily create a file.</figcaption></figure>
<p>Note that you can create multiple files at once using the <strong>touch</strong> command.</p>
<pre><code># touch newfile1.txt newfile2.txt newfile3.txt</code></pre>
<h2>Using the Redirect Operator (&gt;)</h2>
<p>The redirect operator, or right angle bracket, <strong>&gt;</strong> allows Linux users to create a new empty file quickly.</p>
<pre><code># &gt; newfile2.txt</code></pre>
<p>Verify the file was created with the <strong>ls -al</strong> command.</p>
<pre><code># ls -al</code></pre>
<p>Note that you can use the redirect operator, <strong>&gt;</strong>, with other commands to create a new file with the results of a command. For example</p>
<pre><code># ls -al &gt; directorylisting.txt</code></pre>
<p>will create a new file, <em><strong>directorylisting.txt</strong></em>, to output, or &#8216;redirect&#8217;, the directory listing to <em><strong>directorylisting.txt</strong></em> rather than the screen.</p>
<figure id="attachment_18833" aria-describedby="caption-attachment-18833" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18833" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-redirect-operator.png" alt="Create a file with the redirect operator, &gt;. Verify with ls -al." width="1106" height="621" /><figcaption id="caption-attachment-18833" class="wp-caption-text">You can create files with the redirect command (&lt;).</figcaption></figure>
<h2>Using the cat Command</h2>
<p>Although the <strong>cat</strong> command is primarily used to read and concatenate files, it can also be used to create a new file. To use the <strong>cat</strong> command to create a new file, enter <strong>cat</strong>, followed by the redirection operator, <strong>&gt;</strong>, and the name of the file you want to create. Press<strong> &lt;Enter&gt;</strong> and type the text you want (press <strong>&lt;Enter&gt;</strong> for new line). Finally, press <strong>&lt;Ctrl&gt;&lt;D&gt;</strong> to save the file.</p>
<pre><code># cat &gt; newfile3.txt
This is the first line.
This is the second line.
This is the third line.</code></pre>
<p>Verify that the file was created:</p>
<pre><code># ls -al</code></pre>
<figure id="attachment_18850" aria-describedby="caption-attachment-18850" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18850" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-cat.png" alt="Create a file with the cat command and redirect operator, &gt;. Verify with ls -al." width="1106" height="621" /><figcaption id="caption-attachment-18850" class="wp-caption-text">The cat command can be used to create files.</figcaption></figure>
<h2>Using the echo Command</h2>
<p>The <strong>echo</strong> command outputs strings passed as arguments to the standard outputs that can be forwarded to a new file using the redirection operator, <strong>&gt;</strong>. For example:</p>
<pre><code>echo "Let's create a new file." &gt; newfile4.txt</code></pre>
<p>Use the <strong>cat</strong> command to display the new file&#8217;s content.</p>
<pre><code># cat newfile4.txt</code></pre>
<p>Note that you can use the redirect operator twice, <strong>&gt;&gt;</strong>, to append text to the file.</p>
<pre><code>echo "We've create a new file!" &gt;&gt; newfile4.txt</code></pre>
<p>Use the <strong>cat</strong> command to display the new file&#8217;s content.</p>
<pre><code># cat newfile4.txt</code></pre>
<figure id="attachment_18865" aria-describedby="caption-attachment-18865" style="width: 1096px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18865" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-echo.png" alt="Use the echo command to create a file and add and append text." width="1106" height="621" /><figcaption id="caption-attachment-18865" class="wp-caption-text">An echo command example.</figcaption></figure>
<p>Additionally, the <strong>echo</strong> command with the redirection operator, <strong>&gt;</strong>, and no text to create an empty file.</p>
<pre><code># echo &gt; newfile5.txt</code></pre>
<h2>Using the printf Command</h2>
<p>The <strong>printf</strong> command works almost identical to the echo command but has added formatting functionality. In this example, we will create a new file, <strong>newfile5.txt</strong> The file has content. . Use the<strong> ls -al</strong> command to verify the file, and list the file&#8217;s contents.</p>
<pre><code># printf 'The printf command is similar to the echo command. But has additional formating functions.n' &gt; newfile5.txt
# ls -al
# cat newfile5.txt</code></pre>
<p>Note the &#8220;<strong>n</strong>&#8221; in the command above. This signals<strong> printf</strong> to start a new line.</p>
<figure id="attachment_18873" aria-describedby="caption-attachment-18873" style="width: 1343px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18873" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-printf.png" alt="The printf command is almost identical to the echo command." width="1353" height="829" /><figcaption id="caption-attachment-18873" class="wp-caption-text">Create a file using the printf command.</figcaption></figure>
<p>Like the <strong>echo</strong> command, with the <strong>printf</strong> command, you can use double redirect operators, <strong>&gt;&gt;</strong>, append text to the file.</p>
<pre><code># printf 'I told you we could add a new line!n' &gt;&gt; newfile5.txt
# cat newfile5.txt</code></pre>
<figure id="attachment_18874" aria-describedby="caption-attachment-18874" style="width: 1343px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-18874" src="http://codingcampus.net/wp-content/uploads/2022/07/how-to-create-a-file-in-linux-printf-append.png" alt="Just like the echo command, text can be appended using double redirection operators, &gt;&gt;." width="1353" height="829" /><figcaption id="caption-attachment-18874" class="wp-caption-text">Just like the echo command, text can be appended using double redirection operators, &gt;&gt;.</figcaption></figure>
<p>The post <a href="https://codingcampus.net/how-to-create-a-file-in-linux/">How to Create a File in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-create-a-file-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">400</post-id>	</item>
		<item>
		<title>How to Rename Files or Directories in Linux</title>
		<link>https://codingcampus.net/how-to-rename-files-or-directories-in-linux/</link>
					<comments>https://codingcampus.net/how-to-rename-files-or-directories-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Fri, 20 Jan 2023 19:17:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=195</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-rename-files-or-directories-in-linux/">How to Rename Files or Directories in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of the most fundamental tasks you&#8217;ll perform regularly is renaming files as a Linux user. Fortunately, Linux provides methods for renaming files both from the desktop environment, or GUI, and the command line.</p>
<p><strong>Note:</strong> We’re using Zorin OS 16, an Ubuntu-based distro, for this guide. All Linux commands featured in this article are distro-independent, meaning they will work on any Linux distro, except where otherwise noted.</p>
<h2>Renaming Files and Directories from the Linux GUI</h2>
<p>Renaming files via the GUI is straightforward in Linux.</p>
<ol>
<li>Navigate to the folder containing the file or directory you wish to rename on your distro&#8217;s file manager.
<p><figure id="attachment_10695" aria-describedby="caption-attachment-10695" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10695" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-folder.png" alt="Initial folder to rename a file." width="1030" height="676" /><figcaption id="caption-attachment-10695" class="wp-caption-text">Initial folder to rename a file.</figcaption></figure></li>
<li>Select the file you wish to rename. <b>Next, right-click</b> your mouse button and select the <strong>Rename</strong> option from the menu.
<p><figure id="attachment_10698" aria-describedby="caption-attachment-10698" style="width: 1590px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10698" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-rename-file-1.png" alt="Rename orange.txt to purple.txt." width="1600" height="900" /><figcaption id="caption-attachment-10698" class="wp-caption-text">Rename <em>orange.txt</em> to <em>purple.txt</em>.</figcaption></figure></li>
<li>Enter the desired new filename, and click <strong>Rename</strong>. In this example, we&#8217;re renaming the file <em>orange.txt</em> to <em>purple.txt</em>. (Take care not to rename the file extension if that&#8217;s not your intention.)
<p><figure id="attachment_10699" aria-describedby="caption-attachment-10699" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10699" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-orange-to-purple.png" alt="Enter desired filename and click rename." width="1030" height="676" /><figcaption id="caption-attachment-10699" class="wp-caption-text">Enter the desired filename and click Rename.</figcaption></figure></li>
<li>You can see the file <em>orange.txt</em> has been renamed to <em>purple.txt</em>.
<p><figure id="attachment_10701" aria-describedby="caption-attachment-10701" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10701" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-folder-after-file-rename.png" alt="The directory after the file has been renamed." width="1030" height="676" /><figcaption id="caption-attachment-10701" class="wp-caption-text">The directory after the file has been renamed.</figcaption></figure></li>
</ol>
<p>Renaming a folder or directory via the GUI works the same way as renaming a file.</p>
<ol>
<li>Navigate to the folder containing the directory you wish to rename on your Linux distro&#8217;s file manager.
<p><figure id="attachment_10702" aria-describedby="caption-attachment-10702" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10702" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-rename-directory.png" alt="Initial folder to rename a directory.." width="1030" height="676" /><figcaption id="caption-attachment-10702" class="wp-caption-text">Initial folder to rename a directory.</figcaption></figure></li>
<li>Select the directory you wish to rename. <b>Next, right-click</b> your mouse button and select the <strong>Rename</strong> option from the menu.
<p><figure id="attachment_10709" aria-describedby="caption-attachment-10709" style="width: 1590px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10709" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-directory-gui-folder.png" alt="Rename directory sample_directory to Sample-Directory." width="1600" height="900" /><figcaption id="caption-attachment-10709" class="wp-caption-text">Rename directory <em>sample_directory</em> to <em>Sample-Directory</em>.</figcaption></figure></li>
<li>When presented with the option to rename your directory, enter the desired new directory, and click <strong>Rename</strong>. In this example, we&#8217;re renaming the directory <em>sample_directory</em> to <em>Sample-Directory</em>.
<p><figure id="attachment_10710" aria-describedby="caption-attachment-10710" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10710" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-rename-a-directory.png" alt="Enter the desired directory name and click Rename." width="1030" height="676" /><figcaption id="caption-attachment-10710" class="wp-caption-text">Enter the desired directory name and click Rename.</figcaption></figure></li>
<li>You can see your directory has been renamed.
<p><figure id="attachment_10711" aria-describedby="caption-attachment-10711" style="width: 1020px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10711" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-files-gui-folder-after-directory-renamed.png" alt="The folder after the file has been renamed." width="1030" height="676" /><figcaption id="caption-attachment-10711" class="wp-caption-text">The folder after the directory has been renamed.</figcaption></figure></li>
</ol>
<h2>Renaming files and directories using the mv command</h2>
<p>The <strong>mv</strong> command is Linux&#8217;s default command to rename files and directories.</p>
<h3>mv Command Syntax</h3>
<pre><code># mv [options] &lt;current-filename&gt; &lt;new filename&gt;</code></pre>
<p>The mv command is used to move or rename a file.</p>
<h3>Renaming a file with the mv Command</h3>
<p>Open the terminal. Change to the directory containing the file you wish to rename.</p>
<pre><code># cd techobservatory.com</code></pre>
<p>Use the <strong>mv</strong> command to rename the file you want to your desired name. In this example, we&#8217;re renaming the file <em>orange.txt</em> to <em>purple.txt</em>.</p>
<pre><code># mv orange.txt purple.txt</code></pre>
<p>List the directory listing to ensure the file has been renamed.</p>
<pre><code># ls -al</code></pre>
<figure id="attachment_10720" aria-describedby="caption-attachment-10720" style="width: 738px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10720" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-a-file-with-the-mv-command.png" alt="Using the mv command to rename a file." width="748" height="574" /><figcaption id="caption-attachment-10720" class="wp-caption-text">Using the mv command to rename a file.</figcaption></figure>
<p>You can also use the <em><strong>-v</strong></em> or verbose option with the <strong>mv</strong> command to explain what is being done when renaming the file. In this example, we&#8217;re renaming the <em>purple.txt</em> file back to <em>orange.txt</em>.</p>
<pre><code># mv -v purple.txt orange.txt</code></pre>
<p>&nbsp;</p>
<figure id="attachment_10719" aria-describedby="caption-attachment-10719" style="width: 738px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10719" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-a-file-with-the-mv-command-and-verbose-option.png" alt="Using the mv command with the -v option to rename a file." width="748" height="574" /><figcaption id="caption-attachment-10719" class="wp-caption-text">Use the mv command with the -v option to rename a file.</figcaption></figure>
<h3>Renaming a Directory with the mv Command</h3>
<p>Open the terminal.</p>
<p>Change to the directory containing the directory you wish to rename</p>
<pre><code># cd techobservatory.com</code></pre>
<p>Use the mv command to rename the directory you want to your desired directory name. In this example, we&#8217;re renaming the directory sample_directory Sample-Directory.</p>
<pre><code># mv sample_directory Sample-Directory</code></pre>
<p>List the directory to ensure the directory has been renamed.</p>
<pre><code># ls -al</code></pre>
<figure id="attachment_10721" aria-describedby="caption-attachment-10721" style="width: 738px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10721" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-a-directory-with-the-mv-command.png" alt="Using the mv command to rename a directory." width="748" height="574" /><figcaption id="caption-attachment-10721" class="wp-caption-text">Using the mv command to rename a directory.</figcaption></figure>
<p>As the name suggests, the <strong>mv</strong> command can also move files and directories.</p>
<h2>Renaming files and directories using the rename command</h2>
<p>One of the significant drawbacks of the <strong>mv</strong> command to rename files is that, without scripting knowledge, a user can only rename one file at a time. To help combat this problem, Larry Wall, creator of the <strong>PERL</strong> programming language, created <strong>rename</strong>, a command-line utility.</p>
<h3>Installing the rename utility</h3>
<p>Most Linux distros do not come with the <strong>rename</strong> utility, so it must be installed manually.</p>
<p>To install the <strong>rename</strong> utility on Debian, Linux Mint, and Ubuntu-based Linux distros, run the following command:</p>
<pre><code># sudo apt install rename</code></pre>
<p>&nbsp;</p>
<figure id="attachment_10726" aria-describedby="caption-attachment-10726" style="width: 738px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10726" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-install-rename-utility.png" alt="Install the rename utility on a Debian-based system with sudo apt install rename." width="748" height="574" /><figcaption id="caption-attachment-10726" class="wp-caption-text">Install the rename utility on a Debian-based system with apt install rename.</figcaption></figure>
<p>To install the <strong>rename</strong> utility on RHEL-based distros like CentOS, Rocky Linux, and Fedora, run:</p>
<pre><code># sudo yum install rename</code></pre>
<p>To install the <strong>rename</strong> utility on Arch-based distros:</p>
<pre><code># sudo pacman -S rename</code></pre>
<h3>rename Syntax</h3>
<pre><code># rename [options] [PERLEXPRESSION] [files]</code></pre>
<p>The <strong>rename</strong> command renames the filenames supplied according to the rule specified in the first argument (<strong><em>[options]</em></strong>). The <em><strong>[PERLEXPRESSION]</strong></em> argument is a Perl expression that is expected to modify the<em> $_ string</em> in Perl for at least some of the filenames specified. If the expression does not change a given filename, it will not be renamed.</p>
<h3>Renaming Multiple Files with the <strong>rename</strong> command</h3>
<ol>
<li>Open the terminal.</li>
<li>Change to the directory containing the files you wish to <strong>rename</strong>.
<pre><code># cd techobservatory.com</code></pre>
</li>
</ol>
<ul>
<li>Use the <strong>rename</strong> command to rename the files you want to rename. We&#8217;re renaming all files with a <em>.txt</em> extension to a <em>.htm</em> extension in this example.
<pre><code># rename 's/.txt$/.htm/' *</code></pre>
</li>
<li>List the directory to ensure all files with a <em>.txt</em> extension now have a <em>.htm</em> extension.
<pre><code># ls -al</code></pre>
</li>
</ul>
<figure id="attachment_10729" aria-describedby="caption-attachment-10729" style="width: 738px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-10729" src="http://codingcampus.net/wp-content/uploads/2022/05/rename-multiple-files-with-rename.png" alt="Renaming multiple files with the rename utility." width="748" height="574" /><figcaption id="caption-attachment-10729" class="wp-caption-text">Renaming multiple files with the rename utility.</figcaption></figure>
<p>The <strong>rename</strong> utility is a powerful utility that considerably eases many repetitive renaming tasks for Linux users, such as changing the case of multiple files or renaming file extensions, as in the above example. However, much damage can be done with the <strong>rename</strong> utility. Care should be taken when using it.</p>
<h2>Commands Used in This Guide</h2>
<ul>
<li><strong>ls</strong> &#8211; list directory structures.</li>
<li><strong>mv</strong> &#8211; rename or move a file or directory.</li>
<li><strong>rename</strong> &#8211; rename multiple files.</li>
</ul>
<p>The post <a href="https://codingcampus.net/how-to-rename-files-or-directories-in-linux/">How to Rename Files or Directories in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-rename-files-or-directories-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">195</post-id>	</item>
		<item>
		<title>How to Transfer or Share Files Between Windows and Linux</title>
		<link>https://codingcampus.net/how-to-transfer-or-share-files-between-windows-and-linux/</link>
					<comments>https://codingcampus.net/how-to-transfer-or-share-files-between-windows-and-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Mon, 16 Jan 2023 14:43:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=341</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-transfer-or-share-files-between-windows-and-linux/">How to Transfer or Share Files Between Windows and Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To share files between Windows and Linux, it&#8217;s necessary to have <strong>Samba</strong> installed on the Linux distro. Samba is an open-source application suite that implements the Server Message Block (SMB) protocol. This allows seamless interoperability between Linux and Windows.</p>
<p>While you can use these other tools to share files between Windows and Linux machines (e.g. FTP, SFTP, SSH), Samba is preferable as it also allows sharing of printers and makes networking between the Windows and Linux machines transparent. The default port for Samba is port <strong>445</strong>.</p>
<p>This article explains how to configure Windows to access Linux, as well as how to configure Linux to access Windows.</p>
<p>We&#8217;re using Ubuntu LTS 22.04, codenamed Jammy Jellyfish, an Ubuntu-based distro derived from Debian, and Windows 10 for this guide.</p>
<h2>Configure Windows and Enable Sharing</h2>
<ol>
<li>Open <strong>Settings</strong> by clicking on the<strong> Start menu</strong> and searching for &#8220;Settings&#8221;.
<p><figure id="attachment_16965" aria-describedby="caption-attachment-16965" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16965" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-how-to-transfer-or-share-files-between-windows-and-linux-Settings.png" alt="Search for and select Settings from the Windows menu." width="1024" height="768" /><figcaption id="caption-attachment-16965" class="wp-caption-text">Search for and select Settings from the Windows menu.</figcaption></figure></li>
<li>Select <strong>Network &amp; Internet</strong>.
<p><figure id="attachment_16968" aria-describedby="caption-attachment-16968" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16968" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-network-and-internet.png" alt="Select Network and Internet from the Settings menu." width="1024" height="768" /><figcaption id="caption-attachment-16968" class="wp-caption-text">Select Network and Internet.</figcaption></figure></li>
<li>Select the <strong>Network and Sharing Center</strong>.
<p><figure id="attachment_16971" aria-describedby="caption-attachment-16971" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16971" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-select-network-and-sharing.png" alt="Select Network and Sharing." width="1024" height="768" /><figcaption id="caption-attachment-16971" class="wp-caption-text">Select Network and Sharing.</figcaption></figure></li>
<li>Select the <strong>Change advanced sharing settings</strong> option. Check the box next to <strong>Turn on network discovery</strong>. Select <strong>Turn on automatic setup of network connected devices. </strong>Next, click <strong>Turn on file and print sharing</strong>. Click <strong>Save Changes</strong>.
<p><figure id="attachment_16976" aria-describedby="caption-attachment-16976" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16976" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-advanced-settings.png" alt="Select Advanced network sharing and turn on both network discovery and file and print sharing." width="1024" height="768" /><figcaption id="caption-attachment-16976" class="wp-caption-text">Turn on both network discovery and file and print sharing.</figcaption></figure></li>
<li>Right-click anywhere in your folder and choose <strong>New &gt; Folder</strong>. In this instance, the shared folder, <strong>samba-share </strong>(you can choose any name you like), is being created on the desktop.
<p><figure id="attachment_16984" aria-describedby="caption-attachment-16984" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-16984 size-full" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-create-shared-folders-windows.png" alt="Make a new folder in the desired directory. " width="1024" height="768" /><figcaption id="caption-attachment-16984" class="wp-caption-text">Make a new folder in the desired directory.</figcaption></figure></li>
<li>Give your folder a name.
<p><figure id="attachment_16986" aria-describedby="caption-attachment-16986" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16986" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-samba-share.png" alt="Name your new folder." width="1024" height="768" /><figcaption id="caption-attachment-16986" class="wp-caption-text">Name your new folder.</figcaption></figure></li>
<li>Right-click the newly-created folder and choose <strong>Properties</strong>. In the <strong>General</strong> tab, unselect the <strong>Read-only</strong> attribute. Then, click on the <strong>Sharing</strong> tab.
<p><figure id="attachment_16989" aria-describedby="caption-attachment-16989" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16989" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-windows-properties.png" alt="Right-click the new folder and choose Properties." width="1024" height="768" /><figcaption id="caption-attachment-16989" class="wp-caption-text">Right-click the new folder and choose Properties.</figcaption></figure></li>
<li>In the <strong>Sharing</strong> tab, select <strong>Share this folder</strong> and choose <strong>Advanced sharing</strong>, which allows you to choose individual permissions.
<p><figure id="attachment_17725" aria-describedby="caption-attachment-17725" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-17725" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-select-share.png" alt="Select share this folder." width="1024" height="768" /><figcaption id="caption-attachment-17725" class="wp-caption-text">Select share this folder.</figcaption></figure></li>
<li>enter the share name, <strong>samba-share</strong>, and select <strong>Permissions</strong>.
<p><figure id="attachment_16991" aria-describedby="caption-attachment-16991" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16991" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-name-share.png" alt="Under the Sharing tab, choose Advanced sharing." width="1024" height="768" /><figcaption id="caption-attachment-16991" class="wp-caption-text">Under the Sharing tab, choose Advanced sharing.</figcaption></figure></li>
<li>Select the <strong>Permissions</strong> button, and add the Samba user, in this case, <strong>techobservatory</strong>. Give the user <strong>Full Control</strong>.
<p><figure id="attachment_16992" aria-describedby="caption-attachment-16992" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16992" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-user-permissions.png" alt="Select the Permissions button, and add the Samba user." width="1024" height="768" /><figcaption id="caption-attachment-16992" class="wp-caption-text">Select the Permissions button, and add the Samba user.</figcaption></figure></li>
</ol>
<h2>Configure Linux and Enable Sharing</h2>
<ol>
<li>Login to your Linux machine as an admin and launch the terminal.</li>
<li> Since Samba is not generally installed on Linux distros, it must be installed by the Linux user or administrator. To install on Debian- and Ubuntu-based distros:
<pre><code># apt install samba smbclient cifs-utils</code></pre>
<figure id="attachment_16993" aria-describedby="caption-attachment-16993" style="width: 1519px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16993" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-install-samba.png" alt="Install Samba and associateed utilites from the command line." width="1529" height="791" /><figcaption id="caption-attachment-16993" class="wp-caption-text">Install Samba and associated utilities from the command line.</figcaption></figure>
<p>On RHEL- and CentOS-based distros:</p>
<pre><code># rpm -qa samba smbclient cifs-utils</code></pre>
<p>On Arch-based distros:</p>
<pre><code># pacman -Qi samba smbclient cifs-utils</code></pre>
</li>
<li>Click &#8220;Y&#8221; when prompted.</li>
<li>Setup user as a Samba user. A user can only be added as a Samba user if the user already exists on the Linux distro. In this case, <strong>techobservatory</strong>. To add the user as a Samba user:
<pre><code># smbpasswd -a techobservatory</code></pre>
<p><figure id="attachment_16994" aria-describedby="caption-attachment-16994" style="width: 1068px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16994" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-smbpasswd.png" alt="Add the user as a Samba user." width="1078" height="791" /><figcaption id="caption-attachment-16994" class="wp-caption-text">Add the user as a Samba user.</figcaption></figure></li>
<li>Create the directory where you want to mount the share. Note, while we&#8217;re using <em><strong>samba-share</strong> </em>as the share name,  you can choose any name you like.
<pre><code># mkdir /home/techobservatory/samba-share</code></pre>
</li>
<li>Mount the newly-created share, /home/techobservatory/samba-share.
<pre><code># mount.cifs //192.168.1.235/samba-share /home/techobservatory/samba-share -o user=techobservatory</code></pre>
</li>
<li>Make sure the directory was properly mounted:
<pre><code># df</code></pre>
<p><figure id="attachment_16995" aria-describedby="caption-attachment-16995" style="width: 1376px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16995" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-mount-samba-share.png" alt="Mount samba-share." width="1386" height="791" /><figcaption id="caption-attachment-16995" class="wp-caption-text">Mount samba-share.</figcaption></figure></li>
<li>Next, edit the /etc/samba/smb.conf file. Add the following entries to the end of the file:
<pre><code>[samba-share]
path = /home/techobservatory/samba-share
available = yes
valid users = techobservatory
read only = no
browsable = yes
public = yes
writable = yes</code></pre>
<p><figure id="attachment_16996" aria-describedby="caption-attachment-16996" style="width: 1068px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16996" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-smb.conf_.png" alt="Edit /etc/samba/smb.conf and add the provided entries. Save the file." width="1078" height="791" /><figcaption id="caption-attachment-16996" class="wp-caption-text">Edit /etc/samba/smb.conf and add the provided entries. Save the file.</figcaption></figure></li>
<li>We&#8217;ll have to restart the samba service for the changes in the /etc/samba/smb.conf. We&#8217;ll also enable it so that it starts every time, as well as check the status.
<pre><code># systemctl restart smbd

# systemctl enable smbd

# systemctl status smbd</code></pre>
<p><figure id="attachment_16997" aria-describedby="caption-attachment-16997" style="width: 1255px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16997" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-enable-samba.png" alt="Start, enable and check the status of Samba." width="1265" height="837" /><figcaption id="caption-attachment-16997" class="wp-caption-text">Start, enable and check the status of Samba.</figcaption></figure></li>
</ol>
<h2>Real-Life Scenario &#8211; Access Windows from Linux</h2>
<ol>
<li>From the Linux desktop, launch the File Manager.</li>
<li>In the address field, enter <strong>smb://&lt;IP address&gt;/&lt;Shared folder&gt;</strong> (<strong>smb://192.168.1.235/samba-share</strong>).
<p><figure id="attachment_17000" aria-describedby="caption-attachment-17000" style="width: 932px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-17000" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-enter-windows-share-address.png" alt="Enter smb://&lt;IP address&gt;/&lt;Shared folder&gt; in the Connect To: box and click Connect." width="942" height="602" /><figcaption id="caption-attachment-17000" class="wp-caption-text">Enter smb:/// in the Connect to Server box and click Connect.</figcaption></figure></li>
<li>If prompted, enter the username and password.
<p><figure id="attachment_16999" aria-describedby="caption-attachment-16999" style="width: 632px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16999" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-enter-password.png" alt="If prompted, enter the username and password." width="642" height="482" /><figcaption id="caption-attachment-16999" class="wp-caption-text">If prompted, enter the username and password.</figcaption></figure></li>
<li> Files and directories can be created, deleted, and modified by the user, <strong>techobservatory</strong>.
<p><figure id="attachment_17002" aria-describedby="caption-attachment-17002" style="width: 932px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-17002" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-access-windows-share.png" alt="The Windows share, samba-share, is accessible from the Linux machine." width="942" height="602" /><figcaption id="caption-attachment-17002" class="wp-caption-text">The Windows share, samba-share, is accessible from the Linux machine.</figcaption></figure></li>
</ol>
<h2>Real-Life Scenario &#8211; Access Linux from Windows</h2>
<ol>
<li>On Windows, launch <strong>File Explorer</strong></li>
<li>In the address field, enter <strong>//&lt;IP address&gt;/&lt;Shared folder&gt;</strong> (<strong>//192.168.1.135/samba-share</strong>).
<p><figure id="attachment_17003" aria-describedby="caption-attachment-17003" style="width: 1014px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-17003" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-or-share-files-between-windows-and-linux-linux-share.png" alt="how-to-transfer-or-share-files-between-windows-and-linux-" width="1024" height="768" /><figcaption id="caption-attachment-17003" class="wp-caption-text">The Linux share, <strong>samba-share</strong>, is accessible from the Windows machine.</figcaption></figure></li>
<li>The Linux share, <strong>samba-share</strong>, is accessible from the Windows machine. Files and directories can be created, deleted, and modified by the user, <strong>techobservatory</strong>.</li>
</ol>
<h2>Commands Used In This Article</h2>
<ul>
<li><strong>systemctl</strong> &#8211; control the systemd system and service manager.<br />
<strong>df</strong> &#8211; report file disk space usage.<br />
<strong>mkdir</strong> &#8211; make directory.<br />
<strong>mount</strong> &#8211; mount a filesystem.<br />
<strong>smbpasswd</strong> &#8211; change a user&#8217;s SMB password.<br />
<strong>apt</strong> – Debian- and Ubuntu-based command-line interface for the package management system.<br />
<strong>rpm</strong> – (Remote Package Manager) package manager to install applications and packages on RHEL- and CentOS-based distros.<br />
<strong>pacman</strong> – package manager to install applications on Arch-based systems.</li>
</ul>
<p>The post <a href="https://codingcampus.net/how-to-transfer-or-share-files-between-windows-and-linux/">How to Transfer or Share Files Between Windows and Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-transfer-or-share-files-between-windows-and-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">341</post-id>	</item>
		<item>
		<title>How to Use SFTP Commands to Transfer Files in Linux</title>
		<link>https://codingcampus.net/how-to-use-sftp-commands-to-transfer-files-in-linux/</link>
					<comments>https://codingcampus.net/how-to-use-sftp-commands-to-transfer-files-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Kenneth Stenberg]]></dc:creator>
		<pubDate>Mon, 16 Jan 2023 14:07:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://codingcampus.net/?p=388</guid>

					<description><![CDATA[<p>The post <a href="https://codingcampus.net/how-to-use-sftp-commands-to-transfer-files-in-linux/">How to Use SFTP Commands to Transfer Files in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>SFTP, or <strong>S</strong>ecure <strong>F</strong>ile <strong>T</strong>ransfer <strong>P</strong>rotocol, uses secure shell encryption to provide security to send and receive files over the internet or a network. SFTP uses the same port as SSH for file transfers: <strong>22</strong>. Since SFTP is packet-based instead of text-based, it&#8217;s more secure and faster than most other file transfer protocols and uses fewer CPU resources. SFTP allows secure file transfers between different filesystems like Windows, macOS, Unix, etc.</p>
<p>Note: We&#8217;re using Ubuntu LTS 22.04, codenamed Jammy Jellyfish, an Ubuntu-based distro derived from Debian, for this guide.</p>
<p>Also, note that while we&#8217;re using the <strong>sftp</strong> command and the Linux file manager in this guide, many Linux administrators and users prefer using third-party FTP/SFTP clients such as <strong>FileZilla</strong> to send and receive files via SFTP, citing the ease of use of these FOSS clients.</p>
<figure id="attachment_16420" aria-describedby="caption-attachment-16420" style="width: 1146px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16420" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-filezilla.png" alt="Many users like third-party FOSS clients to send and receive files via SFTP." width="1156" height="773" /><figcaption id="caption-attachment-16420" class="wp-caption-text">Many users like third-party FOSS clients to send and receive files via SFTP.</figcaption></figure>
<h2>Install OpenSSH</h2>
<p>On many Linux distros, <strong>OpenSSH</strong> is installed by default.<strong>OpenSSH</strong> is the de facto standard open-source implementation of the SSH protocol used by most operating systems, including most Linux distros and Microsoft Windows.</p>
<p>To check if <strong>OpenSSH</strong> is installed on your Debian- or Ubuntu-based distro, enter the following from the terminal:</p>
<pre><code># dpkg -l grep ssh</code></pre>
<p>On RHEL- and CentOS-based distros:</p>
<pre><code># rpm -qa openssh</code></pre>
<p>On Arch-based distros:</p>
<pre><code># pacman -Qi openssh</code></pre>
<p>On OpenSUSE-based distros:</p>
<pre><code># zypper search -i openssh</code></pre>
<p>If no <strong>OpenSSH</strong> packages (<em><strong>openssh*</strong></em>) are listed, <strong>OpenSSH</strong> needs to be installed. <strong>OpenSSH</strong> can be installed with a single command-line entry.</p>
<p>To install <strong>OpenSSH</strong> on Debian- and Ubuntu-based distros:</p>
<pre><code># apt install openssh-server openssh-client</code></pre>
<p>&nbsp;</p>
<figure id="attachment_16320" aria-describedby="caption-attachment-16320" style="width: 1189px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16320" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-install-openssh.png" alt="Use the apt install command to install OpenSSH on Debian/Ubuntu-based distros." width="1199" height="679" /><figcaption id="caption-attachment-16320" class="wp-caption-text">Use the apt install command to install OpenSSH on Debian/Ubuntu-based distros.</figcaption></figure>
<p>On RHEL- and CentOS-based distros:</p>
<pre><code># yum install openssh</code></pre>
<p>On Arch-based distros:</p>
<pre><code># pacman -S openssh</code></pre>
<p>On OpenSUSE-based distros:</p>
<pre><code># zypper install openssh-server</code></pre>
<h2>Configure OpenSSH</h2>
<p>Now that the <strong>OpenSSH</strong> server, client, and SFTP server, along with dependent packages, are installed (these dependencies, <em>libcor0.8</em>, <em>lifgido2-1</em>, <em>ssh-import-id</em>, and <em>openssh-sftp-server</em> are automatically included when specifying <em>openssh-server</em> in the command line), we need to configure <strong>OpenSSH</strong>. Configuration of <strong>OpenSSH</strong> on a Linux distro consists of four separate steps:</p>
<ul>
<li>Create SFTP Group and User(s)</li>
<li>Create SFTP Default Directory and Set Permissions</li>
<li>Configure the SFTP Server Configuration File</li>
<li>Restart OpenSSH</li>
</ul>
<p><strong>Note:</strong> The steps below need only be run on the distro serving as the SFTP server, not on client machines connecting to the SFTP server.</p>
<h3>Create the SFTP Group and User(s)</h3>
<p>In this example, the SFTP user id being created is <em><strong>sftp-user</strong></em>. The SFTP group is <strong><em>sftp-group</em></strong>.</p>
<ol>
<li>Launch the terminal.</li>
<li>Create the SFTP group, <em><strong>sftp-group</strong></em>.
<pre><code># addgroup sftp-group</code></pre>
</li>
<li>Create the SFTP user.<em><strong> sftp-user</strong></em>, and add them to the newly-created SFTP group, <em><strong>sftp-group</strong></em>.
<pre><code># sudo useradd -G sftp-group -d /sftp/sftp-user -s /sbin/nologin sftp-user</code></pre>
<p>Explanation of operators used:</p>
<p><em><strong>-G sftp-group</strong></em>:  add the user to the group <em><strong>sftp-group</strong></em>.<br />
<em><strong>-d /sftp/sftp-user</strong></em>:  specify the home directory of the user, <em><strong>sftp-user</strong></em>.<br />
<em><strong>-s /sbin/nolgin</strong></em>:  set the user, <em><strong>stfp-user</strong></em>, default shell to <em><strong>/sbin/nologin/</strong></em>. This means <em><strong>sftp-user</strong></em> will not be able to log in via SSH, only via SFTP.</li>
<li>Set the password for the user, <em><strong>sftp-user</strong></em>, with the <em><strong>passwd</strong></em> command.
<pre><code># passwd sftp-user</code></pre>
<p>&nbsp;</p>
<figure id="attachment_16360" aria-describedby="caption-attachment-16360" style="width: 984px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16360" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-create-group-and-user.png" alt="Create the group, sftp-group, and the user, sftp-group. Verify." width="994" height="595" /><figcaption id="caption-attachment-16360" class="wp-caption-text">Create the group, sftp-group, and the user, sftp-group. Verify.</figcaption></figure>
<p>Also, in this example,<em><strong> /sftp</strong></em> is the default root directory for SFTP users, and <em><strong>/sftp/&lt;username&gt;</strong></em> the home directory for each SFTP user (in this instance, <em><strong>sftp-user</strong></em>). When SFTP users login via SFTP, their default directory will be <em><strong>/sftp/&lt;username&gt;</strong></em>.</li>
</ol>
<h3>Create the SFTP Default Directory and Set Permissions</h3>
<ol>
<li>Create the /sftp/sftp-users/uploads directory.
<pre><code># mkdir -p /sftp/sftp-users/uploads</code></pre>
<p>Note that the <em><strong>-p</strong></em> option creates the parent directories if they don&#8217;t already exist. So the <strong>/sftp</strong> and <em><strong>/sftp/sftp-users/</strong></em> directories are created along with <em><strong>/sftp/sftp-sftp-user/uploads</strong></em>.</li>
<li>Set the owner of the <em><strong>/sftp/sftp-users</strong></em> directory as <em><strong>root</strong></em> and give access to members of the group, <em><strong>sftp-group</strong></em>. Since <em><strong>/sftp</strong></em> is a root directory, <em><strong>root</strong></em> is the owner by default.
<pre><code># chown -R root.sftp-group /sftp/sftp-user</code></pre>
</li>
<li>Set the owner of the <em><strong>/sftp/sftp-users</strong></em> directory as <em><strong>sftp-user</strong></em> and give access to members of the group, <em><strong>sftp-group</strong></em>.
<pre><code># chown -R sftp-user.sftp-group /sftp/sftp-user/uploads</code></pre>
</li>
<li>Give read and execute permissions to members of the group, <em><strong>sftp-group</strong></em>.
<pre><code># chmod g+rx /sftp/sftp-user</code></pre>
</li>
<li>Next, let&#8217;s verify that the <em><strong>/sftp</strong></em> subdirectory structure was created correctly and that ownership/permissions were correctly set.
<pre><code># ls -Ral /sftp</code></pre>
<figure id="attachment_16379" aria-describedby="caption-attachment-16379" style="width: 988px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16379" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-verify-directories.png" alt="Verify correct directory structure, ownership and permissions with the command: ls Ral /sftp." width="998" height="595" /><figcaption id="caption-attachment-16379" class="wp-caption-text">Verify correct directory structure, ownership, and permissions with the command: ls Ral /sftp.</figcaption></figure>
<p>With the permissions set above SFTP users (<em><strong>sftp-user</strong></em>) can read and copy from their SFTP home directory, <strong>/sftp/sftp-user</strong>, but cannot copy or write files to the directory. The only directory that the SFTP user can write files to is the <em><strong>uploads</strong></em> directory, <em><strong>/sftp/sftp-user/uploads</strong></em>.</li>
</ol>
<h3>Configure the SFTP Server Configuration File</h3>
<p>Next, we need to configure the SFTP server configuration file, <em><strong>/etc/ssh/sshd_config</strong></em>.</p>
<ol>
<li>To edit <em><strong>/etc/ssh/ssd_config,</strong></em> we must open it with a command-line text editor. In this case, that editor is <strong>Vim</strong>.
<pre><code># vi /etc/ssh/sshd_config</code></pre>
</li>
<li>Add the following entries at the end of the file (under the <strong>Subsystem sftp /usr/lib/openssh/sftp-server)</strong> line.
<pre><code>Match group sftp-group
ChrootDirectory /sftp/%u
X11Forwarding no
AllowTcpForwarding no
PermitTTY no
ForceCommand internal-sftp</code></pre>
</li>
<li>Save the <em><strong>/etc/ssh/sshd_config</strong></em> file.
<p><figure id="attachment_16384" aria-describedby="caption-attachment-16384" style="width: 926px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16384" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-edit-the-openssh-config-file..png" alt="Add the provided entries to the end of the /etc/ssh/sshd_config file, save and exit." width="936" height="429" /><figcaption id="caption-attachment-16384" class="wp-caption-text">Add the provided entries to the end of the /etc/ssh/sshd_config file, save and exit.</figcaption></figure></li>
</ol>
<h3>Restart OpenSSH</h3>
<p>Now that the necessary entries are in <em><strong>/etc/ssh/sshd_config</strong></em>, restart the <strong>OpenSSH</strong> server, (<strong>sshd</strong> daemon) for the changes to take effect.</p>
<pre><code># systemctl restart sshd</code></pre>
<p>Note that even if the <strong>OpenSSH</strong> server is not running, the <em><strong>restart</strong></em> option will still start it.</p>
<p>Now, check that the <strong>OpenSSH</strong> server is running.</p>
<pre><code># systemctl status sshd</code></pre>
<figure id="attachment_16389" aria-describedby="caption-attachment-16389" style="width: 904px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-16389 size-full" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-verify-openssh-is-running..png" alt="Check the status of OpenSSH." width="914" height="532" /><figcaption id="caption-attachment-16389" class="wp-caption-text">Check the status of OpenSSH.</figcaption></figure>
<h2>Real-Life Scenario &#8211; Send and Receive Files via SFTP using the GUI</h2>
<p>In this scenario, the file, <em><strong>blue.txt</strong></em>, will be downloaded from the SFTP server to the client machine via drag-n-drop. Transferring files using SFTP via the GUI is much the same as <a href="https://codingcampus.net/how-to-move-files-and-directories-in-linux/" target="_blank" rel="noopener">copying files locally</a>.</p>
<ol>
<li>Launch the distro&#8217;s file manager (in this case, <strong>Nautilus</strong>).</li>
<li>Navigate to <strong>Other Locations</strong>.</li>
<li>Enter the SFTP server&#8217;s hostname or IP address in the <strong>Connect to Server</strong> box at the bottom of the file manager. In this instance, <em><strong>sftp://192.168.1.80</strong></em>. Note the <em><strong>sftp://</strong></em> prefix. This is mandatory.</li>
<li>Click <strong>Connect</strong>.
<p><figure id="attachment_16449" aria-describedby="caption-attachment-16449" style="width: 820px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16449" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-navigate-to-other-locations.png" alt="Don't forget to preface the hostname or IP address with sftp:// when connecting to the SFTP server." width="830" height="598" /><figcaption id="caption-attachment-16449" class="wp-caption-text">Don&#8217;t forget to preface the hostname or IP address with sftp:// when connecting to the SFTP server.</figcaption></figure></li>
<li>When the authentication window appears, enter the user id, <em><strong>sftp-user</strong></em>, and password in the appropriate boxes. Click <strong>Connect</strong>.
<p><figure id="attachment_16448" aria-describedby="caption-attachment-16448" style="width: 349px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16448" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-enter-user-id-password.png" alt="Enter the requested credentials when the Authentication window appears." width="359" height="337" /><figcaption id="caption-attachment-16448" class="wp-caption-text">Enter the requested credentials when the Authentication window appears.</figcaption></figure></li>
<li>When the SFTP server directory opens, the desired file, <strong><em>blue.txt</em></strong>, is in the directory.
<p><figure id="attachment_16458" aria-describedby="caption-attachment-16458" style="width: 816px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16458" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-sftp-server-directory.png" alt="The file to be copied, blue.txt, is seen in the SFTP server directory." width="826" height="594" /><figcaption id="caption-attachment-16458" class="wp-caption-text">The file to be copied, blue.txt, is seen in the SFTP server directory.</figcaption></figure></li>
<li>Launch another file manager window and navigate where the file, <em><strong>blue.txt</strong></em>, is to be copied (<strong>Home / techobservatory downloads</strong>).
<p><figure id="attachment_16459" aria-describedby="caption-attachment-16459" style="width: 816px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16459" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-target-directory.png" alt="Open the target directory on the client machine." width="826" height="594" /><figcaption id="caption-attachment-16459" class="wp-caption-text">Open the target directory on the client machine.</figcaption></figure></li>
<li>Select the file, <em><strong>blue.txt</strong></em>, in the SFTP server directory and drag-n-drop it into the desired directory.</li>
<li>The file, <em><strong>blue.txt</strong></em>, was successfully downloaded to the desired directory, <em><strong>Home / techobservatory downloads</strong></em>, on the client machine.
<p><figure id="attachment_16462" aria-describedby="caption-attachment-16462" style="width: 816px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16462" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-file-downloaded.png" alt="The file, blue.txt, was successfully downloaded to the client machine." width="826" height="594" /><figcaption id="caption-attachment-16462" class="wp-caption-text">The file, blue.txt, was successfully downloaded to the client machine.</figcaption></figure></li>
</ol>
<div class="mceTemp"></div>
<h2>Real-Life Scenario &#8211; Send and Receive Files via SFTP using the Command Line</h2>
<p>In this scenario, the file, <em><strong>pink.txt</strong></em>, will be sent <strong>from the client machine to the SFTP server</strong> via the command line.</p>
<ol>
<li>Launch the terminal.</li>
<li>Enter<em><strong> sftp &lt;sftp user&gt;@&lt;server&gt;</strong></em>. In this case, <em><strong>sftp-user@192.168.1.80</strong></em>. Note that the hostname can be used as well as the IP address.
<pre><code># sftp sftp-user@192.168.1.80</code></pre>
</li>
<li>At the SFTP prompt, change to the uploads directory.
<pre><code>sftp&gt; cd uploads</code></pre>
</li>
<li>Send the file, <em><strong>pink.txt</strong></em>, to the SFTP server.
<pre><code>sftp&gt; put pink.txt</code></pre>
<p>The file&#8217;s transfer progress is displayed on the screen.</li>
<li>Verify that the file, <em><strong>pink.txt</strong></em>, is in the directory.
<pre><code>sftp&gt; dir</code></pre>
</li>
<li>Exit SFTP.
<pre><code>sftp&gt; exit</code></pre>
<p><figure id="attachment_16452" aria-describedby="caption-attachment-16452" style="width: 908px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16452" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-send-a-file-to-sftp-server.png" alt="Upload the file, pink.txt, to the SFTP folder." width="918" height="595" /><figcaption id="caption-attachment-16452" class="wp-caption-text">Upload the file, pink.txt, to the SFTP folder.</figcaption></figure></li>
<li>Close the terminal.</li>
</ol>
<p>In this scenario, the file, <em><strong>brown.txt</strong></em>, will be copied <strong>from the SFTP server to the client machine</strong> via the command line.</p>
<ol>
<li>Launch the terminal.</li>
<li>Enter<em><strong> sftp &lt;sftp user&gt;@&lt;server&gt;</strong></em>. In this case, <em><strong>sftp-user@192.168.1.80</strong></em>. Note that the hostname can be used as well as the IP address).
<pre><code># sftp sftp-user@192.168.1.80</code></pre>
</li>
<li>At the SFTP prompt, make sure the file to be copied, <em><strong>brown.txt</strong></em>, from the SFTP server to the client machine is present on the SFTP server.
<pre><code>sftp&gt; dir</code></pre>
</li>
<li>Copy the file, <em><strong>brown.txt</strong></em>, to the client machine.
<pre><code>sftp&gt; get brown.txt</code></pre>
</li>
<li>After the file, <em><strong>brown.txt</strong></em> is successfully retrieved, the SFTP prompt will reappear.</li>
<li>Exit SFTP.
<pre><code>sftp&gt; exit</code></pre>
<p><figure id="attachment_16455" aria-describedby="caption-attachment-16455" style="width: 904px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-16455" src="http://codingcampus.net/wp-content/uploads/2022/06/how-to-transfer-linux-files-using-sftp-file-copied-from-the-sftp-server.png" alt="Download the file, brown.txt, to the client machine." width="914" height="595" /><figcaption id="caption-attachment-16455" class="wp-caption-text">Download the file, brown.txt, to the client machine.</figcaption></figure></li>
<li>Close the terminal.</li>
</ol>
<h2>Commands Used in This Article</h2>
<h3>Linux Commands Used</h3>
<ul>
<li><strong>ls</strong> – list directory contents.</li>
<li><strong>apt</strong> – Debian- and Ubuntu-based command-line interface for the package management system.</li>
<li><strong>rpm</strong> – (Remote Package Manager) package manager to install applications and packages on RHEL- and CentOS-based distros.</li>
<li><strong>pacman</strong> – package manager to install applications on Arch-based systems.</li>
<li><strong>useradd</strong> – add a user.</li>
<li><strong>addgroup</strong> – add a group.</li>
<li><strong>passwd</strong> – set or change a user&#8217;s password.</li>
<li><strong>dpkg</strong> – package manager for Debian- and Ubuntu-based distros.</li>
<li><strong>mkdir</strong> – make a directory.</li>
<li><strong>chown</strong> – change ownership of a file or directory.</li>
<li><strong>chmod</strong> – change file mode bits.</li>
<li><strong>sftp</strong> – launch the <strong>OpenSSH</strong> client.</li>
<li><strong>systemctl</strong> – control the systemd system and service manager.</li>
<li><strong>vi</strong> – launch the <strong>Vim</strong> text editor.</li>
</ul>
<h3>SFTP Commands Used</h3>
<ul>
<li><strong>dir</strong> – list directory contents.</li>
<li><strong>cd</strong> – change directory.</li>
<li><strong>exit</strong> – exit SFTP. bye and quit can also be used.</li>
<li><strong>put</strong> – copy a file to the SFTP server.</li>
<li><strong>get</strong> – retrieve a file from the SFTP server.</li>
</ul>
<p>The post <a href="https://codingcampus.net/how-to-use-sftp-commands-to-transfer-files-in-linux/">How to Use SFTP Commands to Transfer Files in Linux</a> appeared first on <a href="https://codingcampus.net">Coding Campus</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://codingcampus.net/how-to-use-sftp-commands-to-transfer-files-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">388</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 

Served from: codingcampus.net @ 2026-06-05 09:04:46 by W3 Total Cache
-->