<?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: Shishir</title>
    <description>The latest articles on DEV Community by Shishir (@shishpt).</description>
    <link>https://dev.to/shishpt</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%2F388481%2F56316db3-cc33-4fab-8753-1f3d01456bfd.jpg</url>
      <title>DEV Community: Shishir</title>
      <link>https://dev.to/shishpt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shishpt"/>
    <language>en</language>
    <item>
      <title>Terminal commands for newbs</title>
      <dc:creator>Shishir</dc:creator>
      <pubDate>Tue, 19 Jan 2021 12:59:47 +0000</pubDate>
      <link>https://dev.to/shishpt/terminal-commands-for-newbs-el1</link>
      <guid>https://dev.to/shishpt/terminal-commands-for-newbs-el1</guid>
      <description>&lt;h1&gt;
  
  
  Linux Terminal Tutorial
&lt;/h1&gt;

&lt;p&gt;At 1 time we have all been interested in the idea of using a Linux distro for a variety of reasons.  Whether it be customization, privacy or just the idea of the operating system being free of charge, it sounds like a great idea until that dark cloud known as the Terminal turns its ugly head.&lt;/p&gt;

&lt;p&gt;The commands used within the Terminal might seem scary and confusing but the more you work with it the easier it becomes to read and understand.&lt;/p&gt;

&lt;p&gt;To begin we will open the Terminal.  From here we will take a look at our Linux system to familiarize ourselves and to gather information that will prove useful to us.&lt;/p&gt;

&lt;h3&gt;
  
  
  LS
&lt;/h3&gt;

&lt;p&gt;We would use the command "ls" to see what files and directories are listed in the current directory&lt;/p&gt;

&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;List files and directories&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  CD
&lt;/h3&gt;

&lt;p&gt;"CD" will allow us to change into a different directory by providing the path to where we want to go.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Change Directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /etc/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  PWD
&lt;/h3&gt;

&lt;p&gt;As we navigate to different parts of our OS we might find ourselves lost and not knowing what directory we're in.  This is where "PWD" comes in handy.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Print Working Directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pwd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  MKDIR
&lt;/h3&gt;

&lt;p&gt;If we wanted to create a folder from Terminal we would use the "mkdir" command to do so followed by whatever we wanted to name the folder.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Make Directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  TOUCH
&lt;/h3&gt;

&lt;p&gt;If we continue with our create directory example and we cd into our newly created directory, we would want to create a file.  We can do so with the "TOUCH" command.  We follow the command with the name of the file and whatever file extension needed.  Below we will create a text file.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Creation of a file&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  VIM
&lt;/h3&gt;

&lt;p&gt;Now that we have created our file, we want to edit that file.  To do so we will use the command vim.  This will open the editor within the Terminal.  Be sure to follow the command with the path or name of your file.  To add text to this file we will first need to press 'i' (for insert) this will allow us to enter edit mode.  Once we have edited our file we can save it by leaving the editing mode by pressing 'Escape' then save it by pressing ':' and then typing 'wq' 'w' is to save and 'q' is to quit.  If we did not want to save and edit the editor we would press 'Escape' then ':' and 'q!' this will allow us to quit the editor without saving the changes we made.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;A text editor that is based on VI.  It is used heavily by developers and system administrators.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  CAT
&lt;/h3&gt;

&lt;p&gt;Now that we have our file.  If we wanted to view the contents of that file without using the editor then the 'CAT' command comes in handy.  It will show the contents of the file within the terminal.  This is useful for small files where you might need to copy a line or 2.  be sure to add the path or file name after the command.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition
&lt;/h4&gt;

&lt;p&gt;Derived from the word "concatenate" cat will list the contents of the file in the Terminal window.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  GREP
&lt;/h3&gt;

&lt;p&gt;Grep is used to find matching strings within a file and proves to be very useful.  When paired with the right tags it can be extremely helpful. In our example we will use 'grep' in basic way to find a specific word we created in our file. We will work with the term "hello there"&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep hello /usr/$USER/desktop/test/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  CP
&lt;/h3&gt;

&lt;p&gt;With our test.txt file if we wanted to duplicate this file we could do so with the 'cp' command.  We would follow 'cp' with the path to the filename if it isn't in the current directory  then leave a space and the path to the destination ending with the new name of the file.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Copy a file or directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;File&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp test.txt test2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;File (copy to another location)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp test.txt /usr/$USER/Desktop/test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Folder (We use the -r to copy the contents of the folder as well)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp -r /usr/$USER/Desktop/test /usr/$USER/Documents/test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  MV
&lt;/h3&gt;

&lt;p&gt;If we take the File (copy to another location) example from above let us try to move the test.txt from within the test folder to the desktop and call it testNew.txt.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Move a file or directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv /usr/$USER/desktop/test/test.txt /usr/$USER/desktop/testNew.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  FIND
&lt;/h3&gt;

&lt;p&gt;Find is a command that comes in very handy when we have a hard time finding our file if we do not know the exact location of the file.  We can use this command by being in a parent folder and using the command followed by the file name.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;To locate a file or directory.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find test.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  RM
&lt;/h3&gt;

&lt;p&gt;With our newly made files and folders let us end this part of the command tutorial and clean up what we have created.  Overall we might have 2 files on our desktop.  An empty folder on our desktop and a folder in Documents which has a file inside of it.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Remove a file or directory&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;Remove the text files on the desktop&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm /usr/$USER/desktop/*.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Remove the test folder from desktop&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -r /usr/$USER/desktop/test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Remove the test folder from Documents&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -r /usr/$USER/Documents/test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The commands we have looked at so far alot of them relate to desktop management, in the next part we will look at commands that the operating system utilize and some of the tools that we can use.&lt;/p&gt;

&lt;h3&gt;
  
  
  DF -H
&lt;/h3&gt;

&lt;p&gt;When we want to see how much disk space we have available on not just our operating system but any drives we have connected to our system we would use the 'df' tag.&lt;/p&gt;

&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Free Disk Space the '-h' refers to a tag that will made the output more readable to the human eye.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  DU -H
&lt;/h3&gt;

&lt;p&gt;If we wanted to get an overview of the size of files and directories we have within a folder we can get that information via the 'du -h' command.  Again the '-h' is for human readable.  This command would be run within the folder we want the information for.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Disk usage &lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;du -h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  WHOAMI
&lt;/h3&gt;

&lt;p&gt;If we wanted to know the active username that was being used in the Terminal session 'whoami' is perfect.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Who Am I logged in as?&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;whoami
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  WHEREIS
&lt;/h3&gt;

&lt;p&gt;There are some applications that might be hard to locate.  'whereis' plays a role to help us find a system application we might have a tough time locating.  We will search for Python in this example&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Where is a system application located&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;whereis python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  MORE
&lt;/h3&gt;

&lt;p&gt;There are certain files that we might come across that contain more information than can be displayed on the screen.  For this we have the 'more' command.  This command will allow us to scroll through the file and with certain tags we're given more flexibility.  Let us take a look at our bash file.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;-d will provide us with with some navigation.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;more -d /etc/bash.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  TOP
&lt;/h3&gt;

&lt;p&gt;When we need to troubleshoot or if we're just curious to know how much cpu power is being used for a specific application we can use the 'top' command to provide us with that information.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Information related to the CPU.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  KILL
&lt;/h3&gt;

&lt;p&gt;We would use the 'KILL' command if we notice a program that was not responding or if it was taking up too much CPU usage.  How we would address it would be to use the 'top' command we learned in the previous example to help us identify the process that needs to be closed.  We would identify the process number by looking at the PID column and matching it to the process in question.  We would then quit out of 'top' and use the 'kill' command followed by the Process ID.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Used to terminate a process.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kill (PID)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  APT
&lt;/h3&gt;

&lt;p&gt;Apt allows us to manage our packages on our Linux system; it is Debian based and supports those distros of Linux that are under the Debian umbrella, such as Ubuntu.  We will install a package that will be used in the next example called "cowsay".&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Advanced Package Tool, used in the Terminal to interact with the packaging system.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install cowsay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  COWSAY
&lt;/h3&gt;

&lt;p&gt;Cowsay is a fun little app that allows you to have messages output by a ASCII generated cow.  You will need to install the application first which we have done in the previous example.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Allows you to add a message to an ASCII generated cow.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cowsay Look mom Im Linuxing!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  PING
&lt;/h3&gt;

&lt;p&gt;Ping is a command that is used to see if our computer can connect to a specific site.  It is used to help identify issues with network stability. If ping can connect to the site we're provided with information with how fast it was to ping the site.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;To reach a specific internet address with specifics on time and data packet health.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;p&gt;ping google DNS&lt;br&gt;
    ping 8.8.8.8&lt;/p&gt;
&lt;h3&gt;
  
  
  NMAP
&lt;/h3&gt;

&lt;p&gt;This tool gives us a glimpse into what ports are open on our machines.  This proves useful when it comes to security and network troubleshooting.  &lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;A network map of open ports on the device.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nmap (ip address)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  CHMOD
&lt;/h3&gt;

&lt;p&gt;CHMOD acts as a gatekeeper regarding the permissions of the file. Extensive reading should be done on this topic before modifying the permissions of a folder or file as it can cause major issues if done incorrectly.  Overall the settings for CHMOD has 3 permission categories.  First the owner, then the group and then everyone else.  &lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;Modifies the permissions of a file or folder&lt;/p&gt;
&lt;h3&gt;
  
  
  CHOWN
&lt;/h3&gt;

&lt;p&gt;You might find yourself with a set of files that belong to a variety of different users.  The likely scenario that can cause this is transferring files between computers.  To use this command we would need to use 'sudo' then 'chwon' followed by the user we want to own the file or directory and then the name of the directory or file.  &lt;/p&gt;
&lt;h4&gt;
  
  
  Defintion:
&lt;/h4&gt;

&lt;p&gt;Change of Ownership&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown (username) (filename)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  EXIT
&lt;/h3&gt;

&lt;p&gt;When we're finished using the Terminal and we want to close it we would use the 'exit' command.&lt;/p&gt;
&lt;h4&gt;
  
  
  Definition:
&lt;/h4&gt;

&lt;p&gt;To quit the Terminal&lt;/p&gt;
&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;quit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And there we have it, a look into Terminal commands for beginners.  Hopefully this article proved useful and encourages you to play around and get familiar with the Terminal and tools and commands that it has to offer.&lt;/p&gt;

</description>
      <category>student</category>
      <category>bash</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
