{"id":355,"date":"2024-03-10T14:38:48","date_gmt":"2024-03-10T14:38:48","guid":{"rendered":"https:\/\/www.vpsjungle.in\/tutorials\/?p=355"},"modified":"2024-03-10T16:01:31","modified_gmt":"2024-03-10T16:01:31","slug":"basic-linux-commands-for-beginners","status":"publish","type":"post","link":"https:\/\/www.vpsjungle.in\/tutorials\/basic-linux-commands-for-beginners\/","title":{"rendered":"Basic Linux Commands for Beginners: Friendly Explanation and Article"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#what-is-linux\">What Is Linux?<\/a><\/li><li><a href=\"#linux-commands\">Linux Commands<\/a><ul><li><a href=\"#basic-commands\">Basic Commands<\/a><\/li><\/ul><\/li><li><a href=\"#intermediate-commands\">Intermediate Commands<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-linux\">What Is Linux?<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/maker.pro\/storage\/vDDbslT\/vDDbslTDGt8itE6C6f8K3X8FPFQenq5iOl1ZfW8z.jpeg\" alt=\"\"\/><\/figure>\n\n\n\n<p><a href=\"https:\/\/www.vpsjungle.in\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.vpsjungle.in\/\" rel=\"noreferrer noopener nofollow\">Linux<\/a> is an operating system&#8217;s kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called \u201cdistros\u201d.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu Linux<\/li>\n\n\n\n<li>Red Hat Enterprise Linux<\/li>\n\n\n\n<li>Linux Mint<\/li>\n\n\n\n<li>Debian<\/li>\n\n\n\n<li>Fedora<\/li>\n<\/ul>\n\n\n\n<p>Linux is Mainly used in servers. About 90% of the internet is powered by Linux servers. This is because Linux is fast, secure, and free! The main problem of using Windows servers are their cost. This is solved by using Linux servers. The OS that runs in about 80% of the smartphones in the world, Android, is also made from the Linux kernel. Most of the viruses in the world run on Windows, but not on Linux!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"linux-commands\">Linux Commands<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"597\" src=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/03\/Linux-software-programming-coding-1024x597.webp\" alt=\"\" class=\"wp-image-359\" srcset=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/03\/Linux-software-programming-coding-1024x597.webp 1024w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/03\/Linux-software-programming-coding-300x175.webp 300w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/03\/Linux-software-programming-coding-768x448.webp 768w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/03\/Linux-software-programming-coding.webp 1283w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"basic-commands\"><strong>Basic Commands<\/strong><\/h3>\n\n\n\n<p><strong>1. pwd<\/strong> \u2014 When you first open the terminal, you are in the home directory of your user. To know which directory you are in, you can use the <strong>\u201cpwd\u201d<\/strong> command. It gives us the absolute path, which means the path that starts from the root. The root is the base of the Linux file system. It is denoted by a forward slash( \/ ). The user directory is usually something like &#8220;\/home\/username&#8221;.<\/p>\n\n\n\n<p><strong>2. ls\u00a0<\/strong>\u2014 Use the <strong>&#8220;ls&#8221;<\/strong> command to know what files are in the directory you are in. You can see all the hidden files by using the command <strong>\u201cls -a\u201d<\/strong>.<\/p>\n\n\n\n<p><strong>3. cd<\/strong> \u2014 Use the <strong>&#8220;cd&#8221;<\/strong> command to go to a directory. For example, if you are in the home folder, and you want to go to the downloads folder, then you can type in <strong>\u201ccd Downloads\u201d<\/strong>. Remember, this command is case sensitive, and you have to type in the name of the folder exactly as it is. <\/p>\n\n\n\n<p>But there is a problem with these commands. Imagine you have a folder named \u201cRaspberry Pi\u201d. In this case, when you type in <strong>\u201ccd Raspberry Pi\u201d<\/strong>, the shell will take the second argument of the command as a different one, so you will get an error saying that the directory does not exist. Here, you can use a backward slash. That is, you can use <strong>\u201ccd Raspberry\\ Pi\u201d<\/strong> in this case. Spaces are denoted like this: If you just type <strong>\u201ccd\u201d<\/strong> and press enter, it takes you to the home directory. To go back from a folder to the folder before that, you can type \u201c<strong>cd<\/strong> ..\u201d . The two dots represent back.<\/p>\n\n\n\n<p><strong>4. mkdir &amp; rmdir <\/strong>\u2014 Use the <strong>mkdir<\/strong> command when you need to create a folder or a directory. For example, if you want to make a directory called \u201cDIY\u201d, then you can type <strong>\u201cmkdir DIY<\/strong>\u201d. Remember, as told before, if you want to create a directory named \u201cDIY Hacking\u201d, then you can type \u201cmkdir <strong>DIY\\ Hacking<\/strong>\u201d. Use <strong>rmdir<\/strong> to delete a directory. But <strong>rmdir<\/strong> can only be used to delete an empty directory. To delete a directory containing files, use <strong>rm<\/strong>.<\/p>\n\n\n\n<p><strong>5. rm<\/strong> &#8211; Use the <strong>rm<\/strong> command to delete files and directories. \u00a0Use &#8220;<strong>rm -r<\/strong>&#8221; to delete just the directory. It deletes both the folder and the files it contains when using only\u00a0the <strong>rm<\/strong> command.<\/p>\n\n\n\n<p><strong>6. touch<\/strong> \u2014 The<strong> touch<\/strong> command is used to create a file. It can be anything, from an empty txt file to an empty zip file. For example, \u201c<strong>touch new.txt<\/strong>\u201d.<\/p>\n\n\n\n<p><strong>7. man &amp; &#8211;help<\/strong> \u2014 To know more about a command and how to use it, use the <strong>man<\/strong> command. It shows the manual pages of the command. For example, \u201c<strong>man cd<\/strong>\u201d shows the manual pages of the <strong>cd <\/strong>command. Typing in the command name and the argument helps it show which ways the command can be used (e.g., <strong>cd \u2013help<\/strong>).<\/p>\n\n\n\n<p><strong>8. cp<\/strong> \u2014 Use the <strong>cp <\/strong>command to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.<\/p>\n\n\n\n<p><strong>9. mv<\/strong> \u2014 Use the <strong>mv<\/strong> command to move files through the command line. We can also use the <strong>mv<\/strong> command to rename a file. For example, if we want to rename the file \u201c<strong>text<\/strong>\u201d to \u201c<strong>new<\/strong>\u201d, we can use \u201c<strong>mv text new<\/strong>\u201d. It takes the two arguments, just like the<strong> cp<\/strong> command.<\/p>\n\n\n\n<p><strong>10. locate<\/strong> \u2014 The <strong>locate<\/strong> command is used to locate a file in a Linux system, just like the search command in Windows. This command is useful when you don&#8217;t know where a file is saved or the actual name of the file. <\/p>\n\n\n\n<p>Using the -i argument with the command helps to ignore the case (it doesn&#8217;t matter if it is uppercase or lowercase). So, if you want a file that has the word \u201chello\u201d, it gives the list of all the files in your Linux system containing the word &#8220;hello&#8221; when you type in \u201c<strong>locate -i hello<\/strong>\u201d. If you remember two words, you can separate them using an asterisk (*). For example, to locate a file containing the words &#8220;hello&#8221; and &#8220;this&#8221;, you can use the command \u201c<strong>locate -i *hello*this\u201d.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"intermediate-commands\"><strong>Intermediate Commands<\/strong><\/h2>\n\n\n\n<p><div id=\"app\"><main class=\"pb-32 md:pb-0\"><div><div class=\"bg-slate-100 relative container mx-auto clear-both py-4 px-4\"><div class=\"flex flex-wrap clearfix mb-4\"><div class=\"w-full md:w-auto md:flex-1 flex flex-wrap md:pr-4 overflow-hidden md:order-1\"><div class=\"project-content w-full flex flex-wrap pt-6 pb-12 px-4 xl:px-8 font-inter bg-white relative mt-[10px] before:content-[''] before:absolute before:bottom-full before:right-0 before:left-0 before:h-[10px] before:bg-gradient-to-l before:from-teal-500 before:to-aegean-300\"><div id=\"project-contents\" class=\"w-full\"><div class=\"overflow-x-auto\"><p><b>1. echo <\/b>\u2014 The &#8220;<b>echo<\/b>&#8221; command helps us move some data,  usually text into a file. For example, if you want to create a new text  file or add to an already made text file, you just need to type in, \u201c<b>echo hello, my name is alok >> new.txt<\/b>\u201d.  You do not need to separate the spaces by using the backward slash  here, because we put in two triangular brackets when we finish what we  need to write.<b>2. cat <\/b>\u2014 Use the <b>cat<\/b> command to display the contents of a file. It is usually used to easily view programs.<\/p><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/main><\/div><strong>3. nano, vi, jed \u2014 nano<\/strong> and <strong>vi<\/strong> are already installed text editors in the Linux command line. The <strong>nano<\/strong> command is a good text editor that denotes keywords with color and can recognize most languages. And <strong>vi<\/strong> is simpler than <strong>nano<\/strong>. You can create a new file or modify a file using this editor. <\/p>\n\n\n\n<p>For example, if you need to make a new file named <strong>&#8220;check.txt<\/strong>&#8220;, you can create it by using the command \u201c<strong>nano check.txt<\/strong>\u201d. You can save your files after editing by using the sequence Ctrl+X, then Y (or N for no). In my experience, using <strong>nano <\/strong>for HTML editing doesn&#8217;t seem as good, because of its color, so I recommend <strong>jed <\/strong>text editor. We will come to installing packages soon.<\/p>\n\n\n\n<p><strong>4. sudo<\/strong> \u2014 A widely used command in the Linux command line, <strong>sudo<\/strong> stands for &#8220;SuperUser Do&#8221;. So, if you want any command to be done with administrative or root privileges, you can use the <strong>sudo<\/strong> command. For example, if you want to edit a file like <strong>viz. alsa-base.conf<\/strong>, which needs root permissions, you can use the command \u2013 <strong>sudo nano alsa-base.conf<\/strong>. You can enter the root command line using the command \u201c<strong>sudo bash<\/strong>\u201d, then type in your user password. You can also use the command \u201c<strong>su<\/strong>\u201d to do this, but you need to set a root password before that. For that, you can use the command \u201c<strong>sudo passwd<\/strong>\u201d(not misspelled, it is <strong>passwd<\/strong>). Then type in the new root password.<\/p>\n\n\n\n<p><strong>5. df <\/strong>\u2014 Use the <strong>df <\/strong>command to see the available disk space in each of the partitions in your system. You can just type in <strong>df<\/strong> in the command line and you can see each mounted partition and their used\/available space in % and in KBs. If you want it shown in megabytes, you can use the command \u201c<strong>df -m<\/strong>\u201d.<\/p>\n\n\n\n<p><strong>6. du<\/strong> \u2014 Use <strong>du<\/strong> to know the disk usage of a file in your system. If you want to know the disk usage for a particular folder or file in Linux, you can type in the command <strong>df<\/strong> and the name of the folder or file. For example, if you want to know the disk space used by the documents folder in Linux, you can use the command \u201c<strong>du Documents<\/strong>\u201d. You can also use the command \u201c<strong>ls -lah<\/strong>\u201d to view the file sizes of all the files in a folder.<\/p>\n\n\n\n<p><strong>7. tar<\/strong> \u2014 Use <strong>tar<\/strong> to work with tarballs (or files compressed in a tarball archive) in the Linux command line. It has a long list of uses. It can be used to compress and uncompress different types of tar archives like <strong>.tar, .tar.gz, .tar.bz2<\/strong>,etc. It works on the basis of the arguments given to it. For example, &#8220;<strong>tar -cvf<\/strong>&#8221; for creating a <strong>.tar<\/strong> archive, &#8211;<strong>xvf<\/strong> to untar a tar archive, &#8211;<strong>tvf<\/strong> to list the contents of the archive, etc.<\/p>\n\n\n\n<p><strong>8. zip, unzip<\/strong> \u2014 Use <strong>zip<\/strong> to compress files into a zip archive, and <strong>unzip<\/strong> to extract files from a zip archive.<\/p>\n\n\n\n<p><strong>9. hostname<\/strong> \u2014 Use <strong>hostname<\/strong> to know your name in your host or network. Basically, it displays your hostname and IP address. Just typing \u201c<strong>hostname<\/strong>\u201d gives the output. Typing in \u201c<strong>hostname -I<\/strong>\u201d gives you your IP address in your network.<\/p>\n\n\n\n<p><strong>10. ping<\/strong> \u2014 Use <strong>ping<\/strong> to check your connection to a server. Wikipedia says, &#8220;<strong>Ping<\/strong> is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network&#8221;. Simply, when you type in, for example, \u201c<strong>ping google.com<\/strong>\u201d, it checks if it can connect to the server and come back. It measures this round-trip time and gives you the details about it. The use of this command for simple users like us is to check your internet connection. If it pings the Google server (in this case), you can confirm that your internet connection is active!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is Linux? Linux is an operating system&#8217;s kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":361,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-355","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands"],"_links":{"self":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/comments?post=355"}],"version-history":[{"count":5,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/355\/revisions"}],"predecessor-version":[{"id":365,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/355\/revisions\/365"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/media\/361"}],"wp:attachment":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/media?parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/categories?post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/tags?post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}