<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankur Gupta</title>
    <description>The latest articles on DEV Community by Ankur Gupta (@originalankur).</description>
    <link>https://dev.to/originalankur</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F24044%2Fc5f1022e-597d-41bb-9d16-c83db5616162.jpg</url>
      <title>DEV Community: Ankur Gupta</title>
      <link>https://dev.to/originalankur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/originalankur"/>
    <language>en</language>
    <item>
      <title>Simple Unix Commands every developer should know</title>
      <dc:creator>Ankur Gupta</dc:creator>
      <pubDate>Thu, 22 Jul 2021 13:19:57 +0000</pubDate>
      <link>https://dev.to/originalankur/simple-unix-commands-every-developer-should-know-102f</link>
      <guid>https://dev.to/originalankur/simple-unix-commands-every-developer-should-know-102f</guid>
      <description>&lt;p&gt;If you are new to Linux or any Unix operating system here is a list of must know commands that can help you in every day task&lt;/p&gt;

&lt;h2&gt;
  
  
  cat
&lt;/h2&gt;

&lt;p&gt;Shows the content of a file. Run cat /etc/hosts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is the output on my computer. /etc/hosts is the path of the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  mkdir
&lt;/h2&gt;

&lt;p&gt;Make/Create a directory. Run &lt;code&gt;mkdir a&lt;/code&gt; &lt;code&gt;mkdir a/b&lt;/code&gt; &lt;code&gt;mkdir a/b/c&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;this will create the directory a  and in it will be directory b and then c in b directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  pwd
&lt;/h2&gt;

&lt;p&gt;print working directory. This commands shows the current directory you are in, output from my machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expanse@Ankurs-Mac-mini ~ % pwd 
/Users/expanse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I am in expanse directory which is in the Users directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  cd
&lt;/h2&gt;

&lt;p&gt;cd allows you to navigate from one directory to another. You can give an absolute path or&lt;br&gt;
relative path. Relative path is the location of the directory from your current folder.&lt;br&gt;
Let us try to navigate the directory created above aka a b and c&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd a&lt;/code&gt; - Enters directory a and this is relative path from current directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd b&lt;/code&gt; - Enters directory b from current directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd /Users/expanse/a/b/c&lt;/code&gt; - Enter directory c using absolute path aka the complete path on the filesystem.&lt;/p&gt;

&lt;p&gt;you can use &lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd ..&lt;/code&gt; to go to parent directory from current directory &lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd -&lt;/code&gt; to go back to previous directory before you entered this one.&lt;/p&gt;

&lt;p&gt;cd without any argument goes to the home directory of the user.&lt;/p&gt;
&lt;h2&gt;
  
  
  free
&lt;/h2&gt;

&lt;p&gt;free tells you how much of free memory is there on the system. e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@linux:~$ free
              total        used        free      shared  buff/cache   available
Mem:        8167616     3140156      795416        1156     4232044     4723404
Swap:             0           0           0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this show you how much of free Mem and swap space is there. To know the same in MB and GB do this &lt;/p&gt;

&lt;p&gt;&lt;code&gt;free -mh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@linux:~$ free
total        used        free      shared  buff/cache   available
Mem:           7.8G        3.0G        776M        1.1M        4.0G        4.5G
Swap:            0B          0B          0B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  df
&lt;/h2&gt;

&lt;p&gt;df tell you how much disk space is free in every partition.  e.g. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;df -h&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@deploy:~$ df -h 
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           798M  960K  797M   1% /run
/dev/vda1        78G   61G   17G  79% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0      100M  100M     0 100% /snap/core/11316
/dev/loop2      100M  100M     0 100% /snap/core/11187
/dev/loop1       43M   43M     0 100% /snap/certbot/1201
/dev/loop4       62M   62M     0 100% /snap/core20/1026
/dev/vda15      105M  8.8M   96M   9% /boot/efi
tmpfs           798M     0  798M   0% /run/user/1000
/dev/loop5       43M   43M     0 100% /snap/certbot/1280
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  head
&lt;/h2&gt;

&lt;p&gt;head allows you to display the first few lines of a file. I have a file with all rss feeds of tennis websites.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@linux:~$ head tennisnews.txt 
http://news.bbc.co.uk/rss/sportonline_world_edition/tennis/rss091.xml
http://sports.espn.go.com/espn/rss/tennis/news?null
http://www.tennis-x.com/tennisxnews.xml
http://www.atpworldtour.com/en/media/rss-feed/xml-feed
http://straightsets.blogs.nytimes.com/feed/
http://feeds.tennis.com/concrete-elbow-tignor
http://www.guardian.co.uk/sport/tennis/rss
http://feeds.feedburner.com/tennisx
http://bleacherreport.com/articles/feed?tag_id=12
http://rss.cnn.com/rss/edition_tennis.rss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;how about if I want to display only the top 10 lines?.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@linux:~$ head -n 5 tennisnews.txt 
http://news.bbc.co.uk/rss/sportonline_world_edition/tennis/rss091.xml
http://sports.espn.go.com/espn/rss/tennis/news?null
http://www.tennis-x.com/tennisxnews.xml
http://www.atpworldtour.com/en/media/rss-feed/xml-feed
http://straightsets.blogs.nytimes.com/feed/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  watch
&lt;/h2&gt;

&lt;p&gt;watch allows you to run a command again and again periodically. Say that your ram's is getting utilised completely and you want to monitor the change or growth every 3-4 seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@deploy:~$ watch -n 3 free -m
Every 3.0s: free -m                                                                                     total        used        free      shared  buff/cache   available
Mem:           7976        3068         722           1        4185        4610
Swap:             0           0           0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;screen&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;say you want to run a command and let it run even after you have existed the terminal aka run the program in background without the terminal running. Use the command screen &lt;/p&gt;

&lt;p&gt;Run screen and you will be greeted by a copyright message, &lt;code&gt;[Press Space or Return to end.]&lt;/code&gt; and you will see a normal shell prompt. Here you can simply run a script and exit screen by entering the command &lt;code&gt;ctrl + ad&lt;/code&gt; and to enter the screen again simply type &lt;code&gt;screen -r -d&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  | and grep
&lt;/h2&gt;

&lt;p&gt;say you have a file with thousands of lines and want to find amongst that a word. We have seen that we can print the content of a file with cat. grep allows you to find the existence of a word in a line. | will allow you to take the output of one and make it the input of another. What the hell am I talking?.  e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy@deploy:~$ cat tennisnews.txt | grep swordsmaster
http://blog.xuite.net/swordsmaster/tennis/rss.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so | made the output of tennisnews.txt as the input of grep.&lt;/p&gt;

</description>
      <category>unix</category>
      <category>linux</category>
      <category>commandline</category>
    </item>
  </channel>
</rss>
