Basic Linux Commands For Beginners
Tags: beginners, linux, tutorial, codenewbie
Published: 2020-08-19 06:44:09

<!-- wp:paragraph -->
<p><strong><em>All Linux commands are case sensitive</em>.</strong>&nbsp;The commands get executed when you press enter key after typing the command. The output of the command will be shown in the terminal itself.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Linux includes a lot of commands. In this Linux commands cheat sheet, I will take you through the most important ones so that you get familiar with them and can easily work on the Linux terminal.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To execute the commands, you will need a computer running Ubuntu or any other Linux distros. In Ubuntu, you can launch the terminal by pressing button Ctrl-Alt-T or by clicking the ‘Activities’ button at the top left of the screen and typing ‘shell’ or ‘terminal’ or other common synonyms.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you don’t have Linux OS, but you want to practice Linux commands, you can use any online Linux terminal. Many Linux terminals are available online free of cost to practice Linux commands.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Complete List Of Linux Commands</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3>Basic Linux Commands</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>#1) pwd:&nbsp;</strong>pwd command prints the current working directory. It will give you the absolute path i.e. from the root till the current directory in which you are in. This command helps you avoid getting lost in the terminal window. You will know in which directory you are.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>By default, the present working directory is the home directory when you have opened the terminal for the first time.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>pwd</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125533,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/1Command-pwd.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/1Command-pwd.png" alt="1Command pwd" class="wp-image-125533"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>#2) whoami:&nbsp;</strong>This command will display the username for the user who is currently logged in to the Linux terminal.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>whoami</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125534,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/2-Command-whoami.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/2-Command-whoami.png" alt="whoami command" class="wp-image-125534"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>#3) clear:&nbsp;</strong>When the terminal gets filled up with lots of commands and their output, you can use clear command to clear up your terminal.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>#4) exit:&nbsp;</strong>exit command will simply close off the terminal session.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Linux Commands To Display Date, Time, Calendar</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>#1) date:&nbsp;</strong>This command displays the current time and date.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>date</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125535,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/3-Command-date.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/3-Command-date.png" alt="Command date" class="wp-image-125535"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>#2) cal:&nbsp;</strong>cal stands for the calendar. By default, the cal command will display the calendar of the current month. At the time of writing this article, the current month was March 2020 and hence in the output, you can see that it has shown March 2020 calendar.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>cal</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125536,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/4-Command-cal.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/4-Command-cal.png" alt="Command cal" class="wp-image-125536"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li>If you want to display the calendar of the whole current year, you can give command&nbsp;<strong>‘cal -y’</strong>.</li><li>You can also specify the year.&nbsp;<strong>For Example,</strong>&nbsp;if you want to see the calendar of 2019, you can give command&nbsp;<strong>‘cal 2019’ –&nbsp;</strong>This will display the calendar of the year 2019.</li><li>Also, if you want to see the calendar of a specific month of a specific year, say January 2019, you can execute command&nbsp;<strong>‘cal 1 2019’ –&nbsp;</strong>this will show January 2019 calendar. Here, ‘1’ denotes the first month of the year i.e. January.</li><li>You can also see the calendar of three months together –the previous month, current month, and next month. The command for this operation is&nbsp;<strong>‘cal -3’</strong></li></ul>
<!-- /wp:list -->

<!-- wp:image {"id":125537,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/5-cal-3.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/5-cal-3.png" alt="cal -3 command" class="wp-image-125537"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Commands To Navigate The Linux File System</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The Linux file system has a tree-like structure which is also called a directory tree. It is used to organize information.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The directory tree is very similar to a family tree and so it's a directory or a file having the parent. However, each directory or a file has exactly one parent.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Now, we will take a look at how the Linux file system is structured. First, we have the root directory which is the first or the top-most directory in our tree.&nbsp;It is represented by a forward slash (/). Under the root, you will find many subdirectories.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Let us look at some important subdirectories:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><strong>Bin</strong>: This directory contains executable programs and commands that can be used by all the users on the system.</li><li><strong>Opt:&nbsp;</strong>This stands for optional. This directory contains commercial software products that are not installed by default on your system.&nbsp;<strong>For Example,</strong>&nbsp;if you are using ubuntu, you must have noticed that Google Chrome is not installed by default on your system and if you want to install Google Chrome, you will find it located underneath the Opt directory.</li><li><strong>Temp:&nbsp;</strong>temp stands for temporary. In this directory, you will find temporary files.</li><li><strong>Var:&nbsp;</strong>It contains variable data that frequently changes over time. These include log files, email pools, and user databases.</li><li><strong>Home:&nbsp;</strong>Linux is a multi-user environment which means that many users can access a system simultaneously. Each user is allocated a dietary inside the home directory.</li></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Now, let us learn commands that will help us to navigate the directory tree.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(i) pwd:&nbsp;</strong>We have already discussed this command above in detail.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(ii) ls:</strong>&nbsp;ls stands for list.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>The syntax for ls command is:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:preformatted -->
<pre class="wp-block-preformatted"><em>ls [OPTIONS] [FILES]</em></pre>
<!-- /wp:preformatted -->

<!-- wp:paragraph -->
<p>This command lists the directory content. If you simply execute ls command without giving any options and files, it will list in alphabetical order all the directories and files that are underneath your current working directory.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125538,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/6-ls.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/6-ls.png" alt="ls command" class="wp-image-125538"/></a></figure>
<!-- /wp:image -->

<!-- wp:image {"id":125539,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/7-ls-output.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/7-ls-output.png" alt="ls output" class="wp-image-125539"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>You can use the ls command with various options and arguments:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>a) ls -l</strong><strong>:</strong>&nbsp;This shows the content with a detailed listing. -l stands for the long option.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>b) ls -lh:&nbsp;</strong>It is used to display the human-friendly file sizes. -h stands for humans.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>c) Ls -lha</strong>:&nbsp;This command is used to display all hidden files. -a includes hidden files.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Example for these commands:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>ls<br>ls -l<br>ls -lh<br>ls -lha</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":127125,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/ls-command.jpg"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/ls-command.jpg" alt="ls command" class="wp-image-127125"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>d) ls /:&nbsp;</strong>As / represents a root directory, this command will show all the files and folders present inside the root directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>e) ls ~:&nbsp;</strong>As ~ represents the home directory, so this command will display the contents of your home directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>ls ~</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125541,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/9-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/9-1.png" alt="Command: ls" class="wp-image-125541"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>f) ls ..:&nbsp;</strong>This command will display the contents of the parent directory because .. represents the parent directory. Suppose, right now I am in the test directory inside my home directory. If I execute command ls .. here then it will display the contents of the parent directory of test which is my home directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Commands executed in below example:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>ls ~<br>cd test<br>pwd<br>ls ..</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125542,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/10-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/10-1.png" alt="ls .." class="wp-image-125542"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>g)</strong>&nbsp;You can also list the contents of a file by giving its absolute pathname.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>ls /home/cpf657/kaushapx/test/parent</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125545,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/11-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/11-1.png" alt="Command: ls /home/cpf657/kaushapx/test/parent" class="wp-image-125545"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Similarly, you can also use a relative pathname.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(iii) cd:&nbsp;</strong>Another useful command in navigating through the filesystem is cd. cd stands for change directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Suppose I am in my home directory right now and want to navigate to a directory named ‘test’ which is present inside my home directory, so I will use&nbsp;<strong>cd test</strong>&nbsp;<strong>c</strong><strong>ommand:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>cd test<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125546,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/12-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/12-1.png" alt="cd test command" class="wp-image-125546"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>To go to a level up, you need to execute&nbsp;<strong>cd ..</strong>&nbsp;<strong>command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>cd..<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125547,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/13-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/13-1.png" alt="cd .." class="wp-image-125547"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can also navigate to any directory using its absolute pathname.&nbsp;<strong>For Example,</strong>&nbsp;suppose that right now I am in the test directory under my home. Now, I want to switch to another directory called test1 which is present inside my home directory. So, I will use the cd command along with the absolute path of the test1 directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>cd /home/cpf657/kaushapx/test1<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125548,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/14-1.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/14-1.png" alt="cd command along with the absolute path of test1 directory" class="wp-image-125548"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>There are many options that we can use with the cd command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>cd /</strong>:&nbsp;The first option that is very useful is space forward slash. So, as you know that Slash represents the root directory,&nbsp;<strong>cd /&nbsp;</strong>will take you directly to the root directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>cd /<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125549,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/15.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/15.png" alt="cd /" class="wp-image-125549"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>cd ~</strong>&nbsp;:&nbsp;The second option that you can use is cd Tilda i.e.&nbsp;<strong>cd ~</strong>. This will take you to the home directory as you can see below screenshot.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>cd test<br>pwd<br>cd ~<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125550,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/16.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/16.png" alt="cd ~" class="wp-image-125550"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>cd ..</strong>:&nbsp;Another option that you can use with cd command is cd two dots i.e. cd ..</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The two dots represent the parent directory, so you will go one step backward in the directory tree by using cd ..&nbsp;<strong>command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>cd ..<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125551,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/17.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/17.png" alt="cd .. command" class="wp-image-125551"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>If you type cd two dots again and again and again, you will eventually go to your root directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to go to some other directory inside the parent directory, then also you can use this&nbsp;<strong>command like below:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>cd ../directory1<br>pwd</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125552,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/18.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/18.png" alt="cd ../directory1" class="wp-image-125552"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>cd –</strong>:&nbsp;the cd space dash command takes you to the previous working directory.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Other Useful Linux Commands</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>(i) w:&nbsp;</strong>This command will display the information on currently logged in users.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>w</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125553,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/19.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/19.png" alt="w" class="wp-image-125553"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(ii) uname:&nbsp;</strong>This command displays the information on the Linux computer on which you are working. There are different options with which you can use this command.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>uname -a:&nbsp;</strong>To display all the information about the Linux computer.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>uname -a</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125554,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/20.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/20.png" alt="uname -a" class="wp-image-125554"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>uname -s:&nbsp;</strong>To display the type of kernel.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>uname -s</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125556,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/21.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/21.png" alt="uname -s" class="wp-image-125556"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>uname -r:&nbsp;</strong>To display the kernel release information.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>uname -r</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125557,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/22.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/22.png" alt="uname -r" class="wp-image-125557"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>uname -v :&nbsp;</strong>To display the kernel version.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>uname -v</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125558,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/23.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/23.png" alt="uname -v" class="wp-image-125558"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(iii) top:&nbsp;</strong>This command will display the real-time data about your Linux machine. It shows the status summary, for how long the computer is running, average load, number of tasks running, CPU information, memory information, the status of processes, etc. You need to press Q to exit from top command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em><strong>Command:&nbsp;</strong>top</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125559,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/24.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/24.png" alt="top" class="wp-image-125559"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(iv) tar:&nbsp;</strong>tar stands for tape archive. This command is used for creating an archive file comprised of many other files, or it can also be used for extracting files from an archive file.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>First, let us see how to create an archived file. Suppose, I am currently at a directory called ‘parent’. Inside this parent directory, I have another directory called ‘directory1’ which contains two text files as shown in the below screenshot.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>pwd<br>ls<br>ls directory1</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125560,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/25.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/25.png" alt="tar" class="wp-image-125560"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now, I will use the tar command to archive all the files in directory1 using the below command:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>tar -cvf testarchive.tar directory1/</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125561,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/26.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/26.png" alt="tar -cvf testarchive.tar directory1" class="wp-image-125561"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>As you can see in the above screenshot that I have used three&nbsp;<strong>options: -c -v and -f</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>-c</strong>&nbsp;is the create option which is used to create the archive file.</li><li><strong>-v</strong>&nbsp;is the verbose option which will list the files in the terminal window that have been added to the archive window, as you can see in the above screenshot.</li><li><strong>-f</strong>&nbsp;option is used to give the desired name to the archive file. The filename should follow immediately after -f option.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>In the above example, the archive file is created, but it's not compressed.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>There are two options to compress the archive file. These are:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>-z</strong>: This is the gzip option. It instructs the tar to use gzip utility to compress the archive file. It offers decent compression and reasonable speed. It’s better to add the suffix ‘.gz’ after the filename so that when someone tries to extract files from the archive, they can easily get to know the kind of compress.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>tar -cvzf testarchive.tar.gz directory1/</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125562,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/27.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/27.png" alt="-z command" class="wp-image-125562"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>-j:&nbsp;</strong>This is the bzip2 option. It uses a superior compression algorithm for compression. It offers better compression and slower speed. It’s better to add ‘.bz2’ the suffix after the filename so that when someone tries to extract files from the archive, they can easily get to know the kind of compress.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>tar -cvjf testarchive.tar.bz2 directory1/</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125563,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/28.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/28.png" alt="ii. -j" class="wp-image-125563"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now, let’s discuss the command for extracting files from an archive file. We need to use&nbsp;<strong>-x</strong>&nbsp;i.e. extract option for this purpose. The -v and -f options behave in the same way in this case as they did for the archive.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>tar -xvf testarchive.tar</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125565,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/29.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/29.png" alt="tar -xvf testarchive.tar" class="wp-image-125565"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>For extracting the files from a .tar.gz archive, you need to use -z option and for extracting the files from. tar.bz2 archive, you need to use -j option.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Commands:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>tar -xvzf testarchive.tar.gz<br>tar -xvjf testarchive.tar.bz2</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125564,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/30.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/30.png" alt="extracting the files from a .tar.gz archive" class="wp-image-125564"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(v) tail:&nbsp;</strong>This command is used to enlist the last 10 lines of a file. By default, it shows the last 10 lines, but if you want to specify the number of lines then you can use -n option.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The syntax is&nbsp;<strong>tail &lt;filename&gt;&nbsp;</strong>, or&nbsp;<strong>tail -n &lt;number of lines&gt; &lt;filename&gt;</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>tail DemoFile.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125566,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/31.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/31.png" alt="extracting the files from a .tar.gz archive" class="wp-image-125566"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Command:</strong><em>&nbsp;tail -n 5 DemoFile.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125567,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/32.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/32.png" alt="tail -n 5 DemoFile.txt" class="wp-image-125567"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(vi) sudo:&nbsp;</strong>sudo stands for the superuser do. This command is used to perform the actions that need root or superuser permissions, like changing the password for another user, etc.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(vii) ps:&nbsp;</strong>This command enlists the processes that are running in the current shell.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>ps</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125568,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/33.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/33.png" alt="ps" class="wp-image-125568"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>If you want to see the processes running for a particular user, you need to use&nbsp;<strong>-u</strong>&nbsp;(user) option in the command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>ps -u kaushapx</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125569,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/34.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/34.png" alt="ps -u kaushapx" class="wp-image-125569"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>To display every process that is running, you need to use&nbsp;<strong>-e</strong>&nbsp;(every) option i.e.&nbsp;<strong>ps -e&nbsp;</strong>in the command<strong>.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(viii) ping:&nbsp;</strong>This is a highly useful command for troubleshooting network issues. It allows you to check whether you have network connectivity with another network machine.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The syntax for this command is&nbsp;<strong>ping &lt;ip_address_of_machine or device_name&gt;</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You need to press Ctrl+C to stop the output of the ping command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Example,</strong>&nbsp;let us try to ping google's website to check whether its reachable or not.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>ping www.google.com</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125570,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/35.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/35.png" alt="ping example" class="wp-image-125570"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can see in the above example that the Google IP address 216.58.192.196 has responded to the ping request and started sending packets of 64 bytes.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The sequence numbers through ICMP protocol (seq=1, seq=2, and so on) tells you that there are no missed responses or packet loss. The&nbsp;<strong>ttl</strong>&nbsp;is the time to live for a packet and this is mainly for avoiding any network flooding issues.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Time is the duration it takes for the request to reach from your computer to google and then back to your computer. The shorter it is, the faster it is. In the end, the highlighted part is the summary which shows the ping statistics that can be used to monitor any network connectivity issues.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to ping for a specific number of times only, you can use -c (count) option. And, If you want to hear a ping, you can use -a (audible) option.&nbsp;<strong>For Example,</strong>&nbsp;ping -ac 6 www.google.com</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(ix) passwd:&nbsp;</strong>This command allows you to change the password. If you are changing it for yourself you just need to type passwd command alone. But, if you are changing it for someone else, you need to use this command along with sudo command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For changing your own password:&nbsp;<strong>passwd</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For changing another user password:&nbsp;<strong>sudo passwd &lt;username&gt;</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>sudo passwd mary</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125571,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/36.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/36.png" alt="passwd" class="wp-image-125571"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(x) mv:&nbsp;</strong>This is a very important command. mv stands for move. This command lets you move files and folders from one directory to another. You can also rename the files with the help of this command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For moving a file to a new location in your filesystem,</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:&nbsp;</strong><strong>mv [filename] [destination-directory]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mv DemoFile.txt /home/cpf657/kaushapx/test/parent/directory2</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125572,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/37.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/37.png" alt="mv" class="wp-image-125572"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>If you just want to rename a file, then you can use the following syntax.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax: mv [filename] [new_filename]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mv DemoFile.txt Hello.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125573,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/38.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/38.png" alt="mv DemoFile.txt Hello.txt" class="wp-image-125573"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can also achieve file move and rename in one go as can be seen in the below example:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mv Hello.txt /home/cpf657/kaushapx/test/parent/directory1/DemoFile.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125574,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/39.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/39.png" alt="achieve file move and rename" class="wp-image-125574"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xi) mkdir:&nbsp;</strong>mkdir stands for make directory. This command is used for creating new directories in the filesystem.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax: mkdir [options…] [directories …]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to create a new directory inside the current directory, you can give only the directory name in the command. Otherwise, you need to give the path of the new directory.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125575,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/40.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/40.png" alt="mkdir" class="wp-image-125575"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>Some options that can be used with mkdir command are as follows:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>–version</strong>: It displays the version and license information.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mkdir –version</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125577,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/41.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/41.png" alt="--version" class="wp-image-125577"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>–help:&nbsp;</strong>This shows all the information regarding mkdir command.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mkdir –help</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125578,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/42.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/42.png" alt="--help" class="wp-image-125578"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li>–<strong>v:&nbsp;</strong>This is the verbose option. It will display a message for the created directory.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mkdir -v test3Dir</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125579,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/43.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/43.png" alt="-v test3Dir" class="wp-image-125579"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>-p:&nbsp;</strong>This option is used to create parent directories in the case when it does not exist for the newly-created directory.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mkdir -vp parent2/child2</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125580,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/44.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/44.png" alt="-vp parent2" class="wp-image-125580"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>-m:&nbsp;</strong>This option is used to set up permissions for the newly-created directory.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>mkdir -m a=rwx [directories]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Suppose you only want to give read permission to a directory, then you can use the following command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>mkdir -vm a=r readOnlyDir</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125581,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/45.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/45.png" alt="-m" class="wp-image-125581"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can see in the above screenshot that the readOnlyDir is the directory with read-only permissions (dr–r–r–)</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xii) alias:&nbsp;</strong>This command is used to give your name to a command or a combination of commands.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax: alias [-p] [name[=value] … ]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Example,</strong>&nbsp;if you want to rename mv command to move, you can do it as follows.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>alias mv=move</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125582,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/46.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/46.png" alt="alias" class="wp-image-125582"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xiii) cat:</strong>&nbsp;cat stands for concatenate. This command reads data from a file and displays its content as the output on the terminal window.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Let us see some variations of this command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><strong>cat filename:&nbsp;</strong>This command will show the contents of a given file as output in the terminal window.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>cat LearnLinuxCommands.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125583,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/47.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/47.png" alt="cat filename" class="wp-image-125583"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>cat file1 file2:&nbsp;</strong>This command will concatenate the contents of two files and will show in the output.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>cat LearnLinuxCommands.txt DemoFile.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125584,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/48.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/48.png" alt="cat file1 file2" class="wp-image-125584"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>cat -n filename:&nbsp;</strong>To display the contents of a file along with its line numbers.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>cat -n Demofile.txt</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125585,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/49.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/49.png" alt="cat -n filename" class="wp-image-125585"/></a></figure>
<!-- /wp:image -->

<!-- wp:list -->
<ul><li><strong>cat &gt;newFileName:&nbsp;</strong>This command is used to create a new file.</li><li><strong>cat [source_filename] &gt; [destination_filename]:&nbsp;</strong>This command is used to copy the contents of one file to another. Note that it will replace the contents of the destination file with the contents of the source file.</li><li><strong>cat [file1] &gt;&gt; [file2]:&nbsp;</strong>This command will append the contents of file1 to the end of contents of file2.</li><li><strong>tac filename:&nbsp;</strong>This command will show the contents of a file in reverse order.</li><li><strong>cat -E filename:&nbsp;</strong>This command is used to highlight the end of the line.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p><strong>(xiv) chmod:&nbsp;</strong>This command is used to set permissions on a file or directory. If you will perform ls -l on any file or directory, you will see initial characters on the output like -rwxrwxrwx. The first character ‘–‘ tells here that it’s a file if it display ‘d’ then it means that it’s a directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The next three characters represent the permissions for the user, the next represents permissions of the group and the last three represent permissions for others. r means to read, w means write and x means execute. If in place of rwx, you anywhere see -, then it means that file permission is not granted.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To set permission, you need to use the chmod command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>There are a total of eight digits that represent different levels of permission.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>0:</strong>&nbsp;No permission<br><strong>1:</strong>&nbsp;execute<br><strong>2:</strong>&nbsp;write<br><strong>3:</strong>&nbsp;write and execute<br><strong>4:</strong>&nbsp;read<br><strong>5:</strong>&nbsp;read and execute<br><strong>6:</strong>&nbsp;read and write<br><strong>7:</strong>&nbsp;read, write and execute</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Suppose I want to use read, write and execute permission for myself (7), read-only permission for the group (4) and read &amp; execute permission for others(5), I will use 745.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>ls -l DemoFile.txt<br>chmod -R 745 DemoFile.txt<br>ls -l DemoFile.txt</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125586,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/50.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/50.png" alt="chmod" class="wp-image-125586"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xv) chown:&nbsp;</strong>chown stands for change owner. With this command, you can change the owner and a group owner for a file.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax: chown [OPTION]… [OWNER][:[GROUP]] FILE…</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to change the owner of the file, you can use this command as:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>chown [owner_name] [file_name]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you want to change group owner, then you will need to use this command with sudo command as:</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>sudo chown [name_of_owner]:[name_of_group] [filename]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xvi) df:&nbsp;</strong>This command shows the size, used space, available space, use percentage, and mounted on details for the filesystems of your computer.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>-h and -x are human-readable and exclude options respectively. -h shows the size in a human-readable format (Gb and Mb). -x option is used to exclude any filesystem that you are not interested in.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In this example below, I have excluded squashfs.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong><em>&nbsp;df -h -x squashes</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":126770,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/df-h-x-squashfs.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/df-h-x-squashfs.png" alt="df -h -x squashfs" class="wp-image-126770"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xvii) diff:&nbsp;</strong>diff stands for the difference. This command is used to compare two text files and show differences between them.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>diff [option] filename1 filename2</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>diff file1 file2</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125588,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/52.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/52.png" alt="diff" class="wp-image-125588"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>You can use certain options with this command, like&nbsp;<strong>-y</strong>&nbsp;for side by side comparison,&nbsp;<strong>-W</strong>&nbsp;for specifying line width to avoid any wraparounds,&nbsp;<strong>–suppress-common-lines</strong>&nbsp;for suppressing common lines between two files in the diff output.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>diff -y -W 70 file1 file2</em></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>diff -y -W&nbsp; 70 file1 file2 –suppress-common-lines</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125589,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/53.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/53.png" alt="--suppress-common-lines" class="wp-image-125589"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xviii) echo:&nbsp;</strong>echo command will print the text on the terminal window. You can also pass environment variables in echo command, as seen below.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>echo Hello World<br>echo $USER<br>echo $PATH<br>echo $HOME</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125590,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/54.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/54.png" alt="echo command" class="wp-image-125590"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xix) find:&nbsp;</strong>This command is used to search for files and directories in a filesystem. You can find by providing file name, directory name, create date, modified date, file owner, file permissions, etc. You can also use wildcards in the search expression.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>find [start search from this point] [search expression] [-options] [what to find]</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>find . -name “*file*”</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125591,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/55.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/55.png" alt="find command" class="wp-image-125591"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In the above example, this command has searched for all the files in the current directory (.), which contains the string ‘file’(*file*) in their file names (-name option).</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Try to use find –help to explore the various options that this command provides.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xx) Kill:&nbsp;</strong>This is a built-in command in Linux that is used to terminate a process manually. You need to supply the process id (PID) to the kill command to terminate a process.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>kill PID</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xxi) history:&nbsp;</strong>This command will show the commands that you have previously executed on the command line. To view the history of all the commands, you need to simply type&nbsp;<strong>history.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Example,&nbsp;</strong>If I want to see the last 10 commands I have executed, I will use below command as</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>history 10</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125592,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/56.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/56.png" alt="history command" class="wp-image-125592"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>On the extreme left, you can see the numbers like 1033, 1034,.. These are the event numbers. This can be different for different computers. You can use these event numbers to repeat a specific command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>!EventNumber</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Example,</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>!1033</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125593,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/57.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/57.png" alt="!1033" class="wp-image-125593"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>If you want to repeat last executed command, simply type&nbsp;<strong>!!</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xxii) head:&nbsp;</strong>The head command shows the top 10 lines of a file. To view the specific number of top lines, use -n option.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>head -n 3 file2</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125594,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/58.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/58.png" alt="head" class="wp-image-125594"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xxiii) gzip:&nbsp;</strong>This command is used to compress a file.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>gzip [-options] filename</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Example,&nbsp;</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>gzip -v file1</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125595,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/59.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/59.png" alt="gzip" class="wp-image-125595"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Use gzip –help to explore various options for gzip command.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>(xxiv) Groups:&nbsp;</strong>This command displays the group names in which the user is a member.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax:</strong>&nbsp;<strong>groups username</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:</strong>&nbsp;<em>groups kaushapx</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125596,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/60.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/60.png" alt="Groups" class="wp-image-125596"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xxv) free:&nbsp;</strong>This command tells us about the RAM and swap memory usage (used, free, shared, buffers, cached) within your computer.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Command:&nbsp;</strong><em>free -h</em></p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":125597,"linkDestination":"custom"} -->
<figure class="wp-block-image"><a href="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/61.png"><img src="https://cdn.softwaretestinghelp.com/wp-content/qa/uploads/2020/04/61.png" alt="free -h" class="wp-image-125597"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>(xxvi) less:&nbsp;</strong>This is a very useful command which you can use to view the contents of a file on the Linux terminal itself without opening the file in the editor.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Syntax: less file_name</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You need to press :q to come out from the output of less command.</p>
<!-- /wp:paragraph -->