<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lokesh Gulghane on Medium]]></title>
        <description><![CDATA[Stories by Lokesh Gulghane on Medium]]></description>
        <link>https://medium.com/@lokeshgulghane1005?source=rss-7a05994a84fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*halFEpuMe5TZ-_dH</url>
            <title>Stories by Lokesh Gulghane on Medium</title>
            <link>https://medium.com/@lokeshgulghane1005?source=rss-7a05994a84fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:36:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lokeshgulghane1005/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Linux Commands for Beginners: A Simple Guide]]></title>
            <link>https://medium.com/@lokeshgulghane1005/linux-commands-for-beginners-a-simple-guide-1165763b7f4c?source=rss-7a05994a84fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1165763b7f4c</guid>
            <category><![CDATA[basic-linux-commands]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-commands]]></category>
            <dc:creator><![CDATA[Lokesh Gulghane]]></dc:creator>
            <pubDate>Sun, 25 Oct 2026 18:16:37 GMT</pubDate>
            <atom:updated>2026-10-25T18:19:11.526Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first opened the Linux terminal, I had no idea what to type. This guide fixes that. It covers the commands you’ll actually use, from basic to advanced, in plain language. You don’t need to memorize anything. Just try them out and come back whenever you need a reminder.</p><p><strong>Tip:</strong> if you ever get stuck, type man command or command --help. For example, man ls.</p><h3>1. Basic Commands</h3><h4>Moving around</h4><pre>pwd          # show where you are<br>ls           # list files<br>ls -l        # list with details<br>ls -a        # show hidden files<br>cd folder    # go into a folder<br>cd ..        # go back one folder<br>cd ~         # go to your home folder</pre><h4>Working with files and folders</h4><pre>touch a.txt         # create an empty file<br>mkdir myfolder      # create a folder<br>cp a.txt b.txt      # copy a file<br>mv a.txt docs/      # move a file<br>mv old.txt new.txt  # rename a file<br>rm a.txt            # delete a file<br>rm -r myfolder      # delete a folder</pre><p><strong>Be careful:</strong> rm has no recycle bin. Deleted files are gone for good.</p><h4>Reading files</h4><pre>cat a.txt         # show the whole file<br>less a.txt        # scroll through a file (press q to quit)<br>head a.txt        # show the first 10 lines<br>tail a.txt        # show the last 10 lines<br>tail -f app.log   # watch a file update live<br>wc -l a.txt       # count lines</pre><h4>Getting help</h4><pre>man ls        # open the manual<br>ls --help     # quick help<br>history       # see your old commands<br>clear         # clean the screen</pre><h3>2. Intermediate Commands</h3><h4>Searching</h4><pre>find . -name &quot;*.txt&quot;     # find files by name<br>grep &quot;error&quot; app.log     # find text inside a file<br>grep -i &quot;error&quot; app.log  # ignore capital letters<br>grep -r &quot;hello&quot; .        # search in all files in a folder</pre><p>Simple way to remember: <strong>find</strong> looks for files, <strong>grep</strong> looks inside files.</p><h4>Pipes and redirection</h4><p>A pipe (|) sends the output of one command into another.</p><pre>ls | grep &quot;.txt&quot;          # list files, then filter them<br>echo &quot;hello&quot; &gt; a.txt      # write to a file (replaces old content)<br>echo &quot;world&quot; &gt;&gt; a.txt     # add to the end of a file<br>sort names.txt | uniq     # sort, then remove duplicates</pre><h4>Permissions</h4><p>When you run ls -l, you see letters like rwxr-xr--. They mean read (r), write (w), and execute (x) for the owner, the group, and everyone else.</p><pre>chmod +x script.sh      # make a file runnable<br>chmod 755 script.sh     # owner can do all, others can read and run<br>chown alice a.txt       # change the file owner</pre><h4>Users</h4><pre>whoami                  # your username<br>sudo command            # run a command as admin<br>useradd -m bob          # create a user<br>passwd bob              # set their password</pre><h4>System information</h4><pre>df -h         # disk space<br>du -sh *      # size of each item in this folder<br>free -h       # memory usage<br>uptime        # how long the system has been on<br>uname -a      # system info</pre><h4>Processes</h4><pre>ps aux          # show running programs<br>top             # live view of running programs<br>kill 1234       # stop a program (use its ID)<br>kill -9 1234    # force stop<br>command &amp;       # run in the background</pre><h4>Zip and unzip</h4><pre>tar -czvf backup.tar.gz folder/   # make a compressed archive<br>tar -xzvf backup.tar.gz           # extract it<br>zip -r backup.zip folder/         # make a zip file<br>unzip backup.zip                  # open a zip fil</pre><h4>Installing software</h4><pre># Ubuntu / Debian<br>sudo apt update<br>sudo apt install nginx</pre><pre># Fedora<br>sudo dnf install nginx</pre><pre># Arch<br>sudo pacman -S nginx</pre><h3>3. Advanced Commands</h3><h4>Networking</h4><pre>ip addr                      # see your IP address<br>ping google.com              # check your connection<br>curl https://example.com     # get a web page<br>wget https://site/file.zip   # download a file<br>ssh user@server              # log in to another computer<br>scp a.txt user@server:/tmp   # copy a file to another computer<br>rsync -avz src/ user@server:/dest/   # sync folders quickly<br>ss -tuln                     # see open ports</pre><h4>Services</h4><pre>systemctl status nginx       # check a service<br>sudo systemctl start nginx   # start it<br>sudo systemctl stop nginx    # stop it<br>sudo systemctl restart nginx # restart it<br>sudo systemctl enable nginx  # start it on every boot<br>journalctl -u nginx          # read its logs</pre><h4>Disks</h4><pre>lsblk                       # list disks<br>sudo mount /dev/sdb1 /mnt   # attach a disk<br>sudo umount /mnt            # detach it<br>ln -s target linkname       # create a shortcut</pre><p><strong>Careful:</strong> commands like mkfs, fdisk, and dd can erase a whole disk. Double-check before using them.</p><h4>Scheduling tasks with cron</h4><pre>crontab -e     # edit your scheduled tasks<br>crontab -l     # list them</pre><p>Example: run a backup every day at 2:30 AM.</p><pre>30 2 * * * /home/me/backup.sh</pre><h4>Security</h4><pre>sudo ufw status            # firewall status<br>sudo ufw allow 22/tcp      # allow SSH<br>ssh-keygen -t ed25519      # create an SSH key<br>sha256sum file.iso         # check a file&#39;s checksum<br>last                       # see recent logins</pre><h3>4. Fun and Useful: Make Linux Talk with espeak-ng</h3><p>Here’s one that most guides skip. <strong>espeak-ng</strong> is a text-to-speech tool. It reads text out loud, right from the terminal.</p><h4>Install it</h4><pre>sudo apt install espeak-ng      # Ubuntu / Debian<br>sudo dnf install espeak-ng      # Fedora<br>sudo pacman -S espeak-ng        # Arch</pre><h4>Use it</h4><pre>espeak-ng &quot;Hello, world&quot;            # say something<br>espeak-ng -s 130 &quot;Speak slowly&quot;     # change speed (words per minute)<br>espeak-ng -p 70 &quot;Higher pitch&quot;      # change pitch (0 to 99)<br>espeak-ng -v en-us &quot;American voice&quot; # choose a voice or language<br>espeak-ng -f story.txt              # read a text file out loud<br>espeak-ng &quot;Save me&quot; -w out.wav      # save the speech as an audio file<br>espeak-ng --voices                  # list all available voices<br>echo &quot;Hello&quot; | espeak-ng            # read text from a pipe</pre><p>You don’t need to know every command. Learn the basics well, and look up the rest when you need them. Everyone does, even experts.</p><p>If this guide helped you, share it with a friend who is learning Linux. And if you know a command I missed, tell me in the comments.</p><p>Have a great day and keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1165763b7f4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why unordered_map<pair<int, int>, int> Doesn't Compile in C++]]></title>
            <link>https://medium.com/@lokeshgulghane1005/why-unordered-map-pair-int-int-int-doesnt-compile-in-c-2134bedc4aa2?source=rss-7a05994a84fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2134bedc4aa2</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[cpp-programming]]></category>
            <category><![CDATA[stl]]></category>
            <category><![CDATA[unordered-map]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lokesh Gulghane]]></dc:creator>
            <pubDate>Sat, 18 Jul 2026 14:20:50 GMT</pubDate>
            <atom:updated>2026-10-25T18:23:29.913Z</atom:updated>
            <content:encoded><![CDATA[<p>A few days ago, I was solving a DSA problem where I wanted to use a pair&lt;int, int&gt; as the key in an unordered_map.</p><p>Naturally, I wrote:</p><pre>unordered_map&lt;pair&lt;int, int&gt;, int&gt; mp;</pre><p>I expected it to compile because this works without any issues:</p><pre>map&lt;pair&lt;int, int&gt;, int&gt; mp;</pre><p>Instead, the compiler threw a long error message. At first, I thought I had made a syntax mistake, but the real reason is much more interesting.</p><p>Let’s see why this happens.</p><h3>Why does map work?</h3><p>std::map stores elements in sorted order. To keep the elements sorted, it only needs a way to compare two keys.</p><p>Fortunately, std::pair already supports comparison.</p><pre>pair&lt;int, int&gt; a = {1, 2};<br>pair&lt;int, int&gt; b = {1, 3};</pre><pre>cout &lt;&lt; (a &lt; b);   // true</pre><p>That’s enough for map.</p><pre>map&lt;pair&lt;int, int&gt;, int&gt; mp;</pre><p>No extra work is required.</p><h3>Why doesn’t unordered_map work?</h3><p>unordered_map works completely differently.</p><p>Instead of comparing keys, it stores them in buckets. To decide which bucket a key belongs to, it first computes a hash value.</p><p>The process looks like this:</p><pre>Key<br> │<br> ▼<br>Hash Function<br> │<br> ▼<br>Hash Value<br> │<br> ▼<br>Bucket</pre><p>So whenever you create an unordered_map, the container must know how to hash the key.</p><p>For an int, that&#39;s easy because the standard library already provides:</p><pre>std::hash&lt;int&gt;</pre><p>For a string, it provides:</p><pre>std::hash&lt;string&gt;</pre><p>But for pair&lt;int, int&gt;?</p><p>There isn’t one.</p><p>That’s exactly why this doesn’t compile:</p><pre>unordered_map&lt;pair&lt;int, int&gt;, int&gt; mp;</pre><p>The compiler tries to find</p><pre>std::hash&lt;pair&lt;int, int&gt;&gt;</pre><p>but it doesn’t exist in the standard library.</p><h3>How do we fix it?</h3><p>We simply provide our own hash function.</p><pre>#include &lt;iostream&gt;<br>#include &lt;unordered_map&gt;</pre><pre>using namespace std;struct PairHash { //convert a pair&lt;int,int&gt; into a single hash value<br>    size_t operator()(const pair&lt;int, int&gt;&amp; p) const {<br>        return hash&lt;int&gt;()(p.first) ^<br>               (hash&lt;int&gt;()(p.second) &lt;&lt; 1);<br>    }<br>};int main() {<br>    unordered_map&lt;pair&lt;int, int&gt;, int, PairHash&gt; mp;    mp[{1, 2}] = 10;<br>    mp[{3, 4}] = 20;    cout &lt;&lt; mp[{1, 2}] &lt;&lt; &#39;\n&#39;;<br>}</pre><p>Now the compiler knows how to generate a hash value for every pair.</p><h3>Why do we combine the hashes?</h3><p>A pair contains two values, but unordered_map needs a single hash value.</p><p>One simple approach is:</p><pre>hash&lt;int&gt;()(p.first) ^<br>(hash&lt;int&gt;()(p.second) &lt;&lt; 1)</pre><p>Here we hash both integers separately and combine them using XOR (^).</p><p>There are more advanced hash-combining techniques, but this one is good enough for most competitive programming and interview problems.</p><h3>A common misconception</h3><p>Many people think unordered_map should automatically support pair because pair is part of the standard library.</p><p>That sounds reasonable, but unordered_map doesn&#39;t just need a key type—it needs a way to hash that key. Since the standard library doesn&#39;t provide a default hash for std::pair, you have to provide one yourself.</p><h3>Final thoughts</h3><p>This is one of those compiler errors that looks scary at first but has a simple explanation.</p><ul><li>map needs comparison.</li><li>pair already supports comparison.</li><li>unordered_map needs hashing.</li><li>pair doesn&#39;t have a default hash.</li><li>Writing a custom hash solves the problem.</li></ul><p>Once you understand this difference, the error message suddenly makes a lot more sense.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2134bedc4aa2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>