

{"id":109678,"date":"2022-08-12T10:00:15","date_gmt":"2022-08-12T04:30:15","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=109678"},"modified":"2022-08-12T10:01:33","modified_gmt":"2022-08-12T04:31:33","slug":"file-managment-linux","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/","title":{"rendered":"File Management in Linux"},"content":{"rendered":"<p>By the end of this article, you will become a pro at managing files through the terminal in Linux. Yes, you read that right, we are going to learn file management system in Linux. We will be going through various linux file management commands like PWD, cd, cat, ls, rm, mv, cp and so many more. So buckle up and read right to the end with full attention.<\/p>\n<h3>Managing files through the terminal<\/h3>\n<p>We all know that there are 2 ways to do almost anything in Linux, one is the GUI and the other is the terminal. we also know that the command line or the terminal is what makes Linux stand out. To sum up the terminal in one sentence: it is a lean mean coding machine.<\/p>\n<p>The Terminal is all about efficiency and productivity rather than the GIU where you have to click many buttons and navigate through different items. However, in the terminal, there are no extra Clicks on nicks!<\/p>\n<p>Just like in every other operating system like Windows and Mac OS we can control and manage files like creating, removing deleting, copying, cutting, and pasting using the GUI.<\/p>\n<p>Since Linux is all about unorthodox methods, let us look into how to manage files using the terminal using various different commands like PWD ( present working directory), Cat ( concatenate), ls ( listing), cp ( copying), rm dir ( remove directory), mk dir ( make directory) and so many other.<\/p>\n<h3>Linux file system<\/h3>\n<p>Before we take a look into the different commands I mention area for managing the file system. Let&#8217;s take a moment and have an overview of the main file types in the Linux file system.<\/p>\n<h4>1. Linux Regular files<\/h4>\n<p>This type is the most common file type in the Linux file system. regular files contain program instructions human-readable text and ASCII characters.<\/p>\n<p>Some examples of regular files are simple text files PDF files zipped or compressed files binary files or other files like \u201c.png\u201d,\u201d.mp4\u201d, \u201cjpeg\u201d, \u201c.gif\u201d, and many more.<\/p>\n<h4>2. Linux Special files<\/h4>\n<p>Special files are the files that represent physical devices for any input and output devices like printers, CD drives, keyboards, mice, etc.<\/p>\n<h4>3. Linux Directories<\/h4>\n<p>directory basically means folder and works just like the folders that are present in the Windows operating system. a directory is a special type of file that stores both regular and special files in a hierarchical order. this hierarchy starts from the root directory which is denoted by a slash (\/).<\/p>\n<p>let us take a look at the hierarchy of the directories in the Linux file system. if I navigate to the root directory using the \u201ccd ..\u201d command (which we will learn later) and use the LS command (which we shall learn later) to list the directories in the root directory I will get the following output:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/LS-command-slash.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109800\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/LS-command-slash.webp\" alt=\"LS command slash\" width=\"981\" height=\"96\" \/><\/a><\/p>\n<p>All of the files that are in dark blue are the already prepackaged directories, and the directories shown in other different colors are the directories I created later on. Let us understand what each directory is and its usage.<\/p>\n<p>1. The \u201croot\u201d directory is the home directory for the root user<\/p>\n<p>2. that \u201c\/dev\u201d directory contains the device files such as \/dev\/sda<\/p>\n<p>3. the \u201c\/boot\u201d directory contains static boot files<\/p>\n<p>4. The \u201c\/usr\u201d directory contains the application and user utilities<\/p>\n<p>5. \u201c\/var\u201d directory contains the log files of various system applications<\/p>\n<p>6. The \u201c\/etc\u201d directory contains all system configuration files<\/p>\n<p>7. The \u201c\/home\u201d directory contains user folders like the desktop and music<\/p>\n<p>8. \u201c\/opt\u201d directory contains add-on application packages<\/p>\n<p>9. The \u201c\/media\u201d contains files for removable devices such as CD drivers<\/p>\n<p>10. The \u201c\/proc\u201d directory holds information on currently running processes<\/p>\n<p>11. \u201c\/bin\u201d directory contains the user command binary files<\/p>\n<p>12. The \u201c\/lib\u201d directory contains shared library images and kernel modules<\/p>\n<p>13. The \u201c\/mnt\u201d directory contains subdirectories that act as temporary Mount points for mounting devices such as cd-roms<\/p>\n<p>Now that you have proper knowledge of the Linux file system, let us now see and explore the commands for managing files in Linux.<\/p>\n<p>In this article, I am using the Ubuntu 20.04 operating system. nonetheless, all of the commands in this article are standard in all distributions of Linux and come pre-installed so there is no hassle in installing them<\/p>\n<h3>Linux PWD command<\/h3>\n<p>The PWD command is an abbreviation for \u201cPresent Working Directory\u201d. This command is very straightforward and simple, it prints out the path of your current directory, starting all the way from the root directory.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-pwd-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109801\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-pwd-command.webp\" alt=\"linux pwd command\" width=\"607\" height=\"372\" \/><\/a><\/p>\n<p>The PWD command is so simple, that it does not have any other variations or options!<\/p>\n<h3>Linux CD command<\/h3>\n<p>The \u201ccd\u201d command is used to navigate through the files. Just like in GUI, you press the directory you want to go, cd does the same, but in the terminal. The cd command is the abbreviation for \u2018Change Directory\u2019.<\/p>\n<p>If you simply type \u2018cd\u2019, you will go back to the home directory, no matter where you are.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/cd-command-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109802\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/cd-command-1.webp\" alt=\"cd command\" width=\"545\" height=\"170\" \/><\/a><\/p>\n<p>If you press \u201ccd ..\u201d, this command will take you to the previous directory or parent directory. You can go all the way back to the root directory using this command.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/cd.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109803\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/cd.webp\" alt=\"cd\" width=\"478\" height=\"346\" \/><\/a><\/p>\n<p>Ok, we have seen how to go to the home directory and how to go back, but how do you go forward, well once you are in a directory, you can simply type the command \u201ccd &lt;subdirectory&gt;\u201d. This command will take you to the subdirectory you have specified.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-cd.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109804\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-cd.webp\" alt=\"linux cd\" width=\"546\" height=\"404\" \/><\/a><\/p>\n<p>If you look at the above method of going to the directory \u2018cars\u2019 from the root directory, it is a very long process, I had to use the cd command 4 times. The previous method was on par with the GUI, where you go to the directory and press on the subdirectory.<\/p>\n<p>However, remember when I said the terminal is all about efficiency? Well, there is a way you can even go 100 directories deep from the home directory just by using 1 single cd command! You can do so by using the following syntax: \u201ccd &lt;directory path&gt;\u201d If you specify the path of the directory to cd, it will take you directly there with no additional stops in between.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-cd-command-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109867\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-cd-command-1.webp\" alt=\"linux cd command\" width=\"825\" height=\"191\" \/><\/a><\/p>\n<p>Take that GUI!!<\/p>\n<h3>Linux LS command<\/h3>\n<p>Ok, now you can check your present working directory and navigate through the files. But what if you need to list out the files or subdirectories present in a directory? That is exactly where the ls command comes to help. The ls command stands for \u201clist\u201d<\/p>\n<p>To list the contents of a directory, you can simply use the ls command:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-2.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109806\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-2.webp\" alt=\"ls command\" width=\"842\" height=\"173\" \/><\/a><\/p>\n<p>But this is too cheap and simple for the terminal and ls command to hand, their simple goal is to be better than the GUI, and that is exactly where the different options of the ls command come into the picture.<\/p>\n<p>We can use various options to specify the output. Let us look at the options used with the ls command:<\/p>\n<h4>1. -a<\/h4>\n<p>This option enlists the entire list of the current directory including the hidden files.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-a.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109807\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-a.webp\" alt=\"ls command a\" width=\"773\" height=\"99\" \/><\/a><\/p>\n<h4>2. ~<\/h4>\n<p>This option lists the contents of the home directory, irrespective of your present working directory.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-tilde.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109808\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-tilde.webp\" alt=\"ls command tilde\" width=\"797\" height=\"122\" \/><\/a><\/p>\n<h4>3. -lh<\/h4>\n<p>This option will show you the file sizes in a human-readable format. By default the ls command will show the size of files in bytes, which is very hard to understand, Hence we use the option \u201c-h\u201d to print the sizes in Megabytes.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lh.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109809\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lh.webp\" alt=\"ls command lh\" width=\"780\" height=\"337\" \/><\/a><\/p>\n<h4>4. -lhS<\/h4>\n<p>This option displays the file in descending order of their size.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lhs.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109810\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lhs.webp\" alt=\"ls command lhs\" width=\"823\" height=\"361\" \/><\/a><\/p>\n<h4>5. -l &#8211; -block- size=&lt;size&gt;<\/h4>\n<p>This option displays the files in a specific size format.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-block-size.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109811\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-block-size.webp\" alt=\"ls command block size\" width=\"827\" height=\"373\" \/><\/a><\/p>\n<h4>6. -d*\/<\/h4>\n<p>This option displays only the subdirectories and not the regular files.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-d.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109812\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-d.webp\" alt=\"ls command d\" width=\"609\" height=\"96\" \/><\/a><\/p>\n<h4>7. -m<\/h4>\n<p>This option prints out the directories and files separated by a comma.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-m.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109813\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-m.webp\" alt=\"ls command m\" width=\"926\" height=\"116\" \/><\/a><\/p>\n<h4>8. -n<\/h4>\n<p>This option prints the group ID and owner ID instead of their names.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-n.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109814\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-n.webp\" alt=\"ls command n\" width=\"752\" height=\"372\" \/><\/a><\/p>\n<h4>9. &#8211;color &lt;value&gt;<\/h4>\n<p>This option prints the list as colored or discolored<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-color.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109815\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-color.webp\" alt=\"ls command color\" width=\"952\" height=\"195\" \/><\/a><\/p>\n<h4>10. -p<\/h4>\n<p>This option identifies the directories easily by marking the directories with a slash sign.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-p.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109816\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-p.webp\" alt=\"ls command p\" width=\"1027\" height=\"121\" \/><\/a><\/p>\n<h4>11. -li<\/h4>\n<p>This option prints the index number if the file system is the file is displayed in the first column.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-li.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109817\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-li.webp\" alt=\"ls command li\" width=\"830\" height=\"325\" \/><\/a><\/p>\n<h4>12. -r<\/h4>\n<p>This option prints the list in reverse order.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-r.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109818\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-r.webp\" alt=\"ls command r\" width=\"968\" height=\"121\" \/><\/a><\/p>\n<h4>13. -R<\/h4>\n<p>This option displays the content of the sub-directories also.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-ls-command-r.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109819\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-ls-command-r.webp\" alt=\"linux ls command r\" width=\"867\" height=\"274\" \/><\/a><\/p>\n<h4>14. -lX<\/h4>\n<p>This option groups the files with the same extensions together in the list.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lx.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109820\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-lx.webp\" alt=\"ls command lx\" width=\"815\" height=\"355\" \/><\/a><\/p>\n<h4>15. -Q<\/h4>\n<p>This option adds quotation marks to all directories and files.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-q.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109821\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-q.webp\" alt=\"ls command q\" width=\"1063\" height=\"120\" \/><\/a><\/p>\n<h4>16. -l<\/h4>\n<p>This option shows the list in a long list format<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-l.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109822\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/ls-command-l.webp\" alt=\"ls command l\" width=\"822\" height=\"355\" \/><\/a><\/p>\n<h4>17. ..\/<\/h4>\n<p>This option lists the contents of the parent directory<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/list-content-of-parent-directory.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109823\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/list-content-of-parent-directory.webp\" alt=\"list content of parent directory\" width=\"938\" height=\"215\" \/><\/a><\/p>\n<p>In the above output, even though I moved to the directory \u201cDataFlair\u201d, using the command \u201cls ..\/\u201d printed the content of the \u201cDesktop\u201d directory, which is the parent directory of the \u201cDataFlair\u201d directory.<\/p>\n<h4>18. &#8211;version<\/h4>\n<p>This option prints information about the version of ls you are using.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/version-of-ls.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109824\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/version-of-ls.webp\" alt=\"version of ls\" width=\"874\" height=\"204\" \/><\/a><\/p>\n<h4>19. &#8211;help<\/h4>\n<p>This option prints out all of the commands and information regarding them<\/p>\n<h4>20. -g<\/h4>\n<p>This option displays the files excluding the column of information regarding the group and user.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/files-excluding-user-group.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109825\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/files-excluding-user-group.webp\" alt=\"files excluding user group\" width=\"752\" height=\"367\" \/><\/a><\/p>\n<h4>21. -lt<\/h4>\n<p>This option sorts the list by displaying the recently modified field at the top.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/recently-modified-on-top.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109826\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/recently-modified-on-top.webp\" alt=\"recently modified on top\" width=\"780\" height=\"335\" \/><\/a><\/p>\n<h4>22. \/<\/h4>\n<p>This option lists the files in the root directory<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/files-in-root-directory-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109827\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/files-in-root-directory-1.webp\" alt=\"files in root directory\" width=\"981\" height=\"96\" \/><\/a><\/p>\n<h4>23. *<\/h4>\n<p>This option lists the contents of the directory along with its subdirectories. It is exactly the same as the option \u201c-R\u201d<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/directories-with-subdirectories.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109828\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/directories-with-subdirectories.webp\" alt=\"directories with subdirectories\" width=\"874\" height=\"240\" \/><\/a><\/p>\n<p>Take that GUI!!<\/p>\n<p>If at all you feel lost while using these commands and need help, you can use the command \u201cls -h\u201d to display the help menu.<\/p>\n<h3>Linux Touch command<\/h3>\n<p>Now that you can list the contents of a file, can you make one? Who said you can\u2019t? Using the touch command, you can create any file (remember, file and not a directory) by simply using the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">touch &lt;filname&gt;<\/pre>\n<p>For example, the command \u201ctouch ubuntu.txt\u201d will create a text file with the name ubuntu. You can create any type of file using the touch command, like \u201c.odt\u201d, \u201c.doc\u201d, \u201c.ott\u201d. \u201c.html\u201d, \u201c.sh\u201d, \u201c.xml\u201d, \u201c.c\u201d, \u201cfodt\u201d, \u201c.uot\u201d, \u201c.rtf\u201d, \u201c.dot\u201d and many more.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/touch-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109829\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/touch-command.webp\" alt=\"touch command\" width=\"660\" height=\"125\" \/><\/a><\/p>\n<p>After creating the file, you can use the ls command to verify if it has been created successfully.<\/p>\n<h3>Linux CAT command<\/h3>\n<p>So you have created your file and now you need to open it and write something down. How are you going to do it? Use the GUI? NOPE! NEVER! We use the cat command. The cat command is an abbreviation of con<strong>cat<\/strong>enate.<\/p>\n<p>The cat command is a command-line-based utility that helps in many tasks like reading files, writing in files, viewing the content of files, concatenating files, redirecting output in the terminal and so many more things.<\/p>\n<p>If you simply use the cat command, using the syntax \u201ccat &lt;filename&gt;\u201d, it will only display the contents of a file. If the file is empty and has no content, it will show nothing:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/empty-file.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109830\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/empty-file.webp\" alt=\"empty file\" width=\"890\" height=\"142\" \/><\/a><\/p>\n<p>So how do you write in the file using the cat command? If you want to add some new lines or write in an already existing file, you can do so by using the syntax: cat &gt;&gt; &lt;filename&gt;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/add-content-using-cat.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109831\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/add-content-using-cat.webp\" alt=\"add content using cat\" width=\"985\" height=\"141\" \/><\/a><\/p>\n<p>Once you finish writing and want to save your work, press \u201cctrl\u201d + \u2018\u201cd\u201d. Now you can use the simple cat command to check if your work has been successfully saved or not.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/checking-cat-content.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109832\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/checking-cat-content.webp\" alt=\"checking cat content\" width=\"1093\" height=\"156\" \/><\/a><\/p>\n<p>And voila created and saved! But wait, that is not the only feature of the cat command, it has so many other features too. You can directly create a file and start writing in it, instead of just creating a file using the touch command! Let us look at some of the features of the cat command.<\/p>\n<h4>Creating a file with the cat command<\/h4>\n<p>If you want to create a file using cat straight in the terminal and not using the GUI, you can do it by using the syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cat &gt;&lt;filename&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/Creating-a-file-with-the-cat-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109833\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/Creating-a-file-with-the-cat-command.webp\" alt=\"Creating a file with the cat command\" width=\"768\" height=\"92\" \/><\/a><\/p>\n<p>Once you enter the command, the cursor will go to the next line and wait for your input. You can enter what you choose to write in the file you just created.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/Creating-a-file-with-cat-command-.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109834\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/Creating-a-file-with-cat-command-.webp\" alt=\"Creating a file with cat command\" width=\"780\" height=\"98\" \/><\/a><\/p>\n<p>After you finish writing, you can press \u201cctrl\u201d + \u201cd\u201d to save your work in the file you just created.<\/p>\n<h4>Displaying line numbers<\/h4>\n<p>If you want to display the line number of the content in a file, you can do so by using the option \u201c-n\u201d like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cat -n &lt;filename&gt;<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-line-numbers-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109835\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-line-numbers-1.webp\" alt=\"displaying line numbers\" width=\"746\" height=\"122\" \/><\/a><\/h4>\n<h4>Displaying the tab-separated lines<\/h4>\n<p>To display or highlight the tab spaces in the file with \u201c^I\u201d, use the option \u201c-T\u201d like this: cat -T &lt;filename&gt;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-the-tab-separated-lines-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109836\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-the-tab-separated-lines-1.webp\" alt=\"displaying the tab separated lines\" width=\"780\" height=\"136\" \/><\/a><\/p>\n<h4>Displaying multiple files at once<\/h4>\n<p>Another way to show the contents of multiple files is to cat each of them individually such that they are separated by a semicolon. Use the following syntax: cat &lt;file1&gt;; cat &lt;file2&gt;; cat &lt;file3&gt; and so on<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-multiple-files-at-once-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109837\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-multiple-files-at-once-1.webp\" alt=\"displaying multiple files at once\" width=\"913\" height=\"248\" \/><\/a><\/p>\n<h4>Using the redirecting operator<\/h4>\n<p>If you want to write the contents of a specific file to another file (new or existing), you can do so by using the redirection operator (&gt;) in the syntax: cat &lt;old file&gt; &gt; &lt;new file&gt;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/using-the-redirecting-operator-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109839\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/using-the-redirecting-operator-1.webp\" alt=\"using the redirecting operator\" width=\"956\" height=\"210\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>If you enter the name of an already existing file and it already had contents in it, cat will override them with no warning, so choose the file name carefully<\/p>\n<h4>Appending with redirecting operator<\/h4>\n<p>If you want to append the content of 1 file to the contents of another existing file, you can do so by using the \u201c&gt;&gt;\u201d symbol like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cat &lt;file 1&gt; &gt;&gt; &lt;file2&gt;<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/appending-with-redirecting-operator-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109840\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/appending-with-redirecting-operator-1.webp\" alt=\"appending with redirecting operator\" width=\"928\" height=\"192\" \/><\/a><\/h4>\n<h4>Redirecting multiple files<\/h4>\n<p>If you want to combine more than 1 file together in a single new file, you can do it by using the redirecting operator like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cat &lt;file 1&gt; &lt;file 2&gt; &lt;file 3&gt; &lt;file 4&gt; &gt; &lt;new file&gt;<\/pre>\n<p>This command will copy all the files (file 1, file 2, file 3, and file4) into the new file.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/redirecting-multiple-files-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109838\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/redirecting-multiple-files-1.webp\" alt=\"redirecting multiple files\" width=\"969\" height=\"312\" \/><\/a><\/p>\n<h4>Writing in an already existing file<\/h4>\n<p>If you want to add some new lines or write in an already existing file, you can do so by using the syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cat &gt;&gt; &lt;filename&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/writing-in-an-already-existing-file-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109841\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/writing-in-an-already-existing-file-1.webp\" alt=\"writing in an already existing file\" width=\"776\" height=\"218\" \/><\/a><\/p>\n<p>Once you finish writing the text and want to save and exit, press \u201cctrl\u201d + \u201cD\u201d<\/p>\n<h4>Displaying content in reverse order<\/h4>\n<p>To display the contents of a file in reverse order, use the syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">tac &lt;filename&gt;<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-content-in-reverse-order-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109842\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/displaying-content-in-reverse-order-1.webp\" alt=\"displaying content in reverse order\" width=\"696\" height=\"151\" \/><\/a><\/h4>\n<h4>Suppressing empty line<\/h4>\n<p>If you don\u2019t want the empty lines in your file to be shown in your output, you can suppress them by using the \u201c-s\u201d option like this: cat -s &lt;file name&gt;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/suppressing-empty-line-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109843\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/suppressing-empty-line-1.webp\" alt=\"suppressing empty line\" width=\"687\" height=\"348\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/suppressing-the-empty-line.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109844\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/suppressing-the-empty-line.webp\" alt=\"suppressing the empty line\" width=\"809\" height=\"216\" \/><\/a><\/p>\n<p>Once again, if you feel lost about any of the options used with the cat command, you can always type the command \u201ccat -h\u201d to print out the help menu or \u201cman cat\u201d to display the entire manual of the cat command.<\/p>\n<h3>Linux MV command<\/h3>\n<p>Now that you have created your file, say you have created it in the wrong directory, and now have to move it to some other location. This is where the mv command comes to help. The mv command is the abbreviation for Move.<\/p>\n<p>The mv command is really efficient and powerful, yet remains simple. You can not only move files from one location to another but also rename them.<\/p>\n<p>To move a file from 1 location to another, you use the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mv &lt;filename&gt; &lt;destination path&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109845\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command.webp\" alt=\"mv command\" width=\"970\" height=\"239\" \/><\/a><\/p>\n<p>In the above output, I have moved the file \u201cubuntu.txt\u201d to the subdirectory \u201ccars\u201d from the Desktop.<\/p>\n<p>In the above example, I had was in the directory of the file that had to be moved. Let us try doing the reverse, moving the file to the directory I am in.<\/p>\n<p>To do that, you have to follow the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mv &lt;path of file&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-mv-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109846\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-mv-command.webp\" alt=\"linux mv command\" width=\"922\" height=\"405\" \/><\/a><\/p>\n<p>In the above output, the file \u201cubuntu.txt\u201d has been moved from the subdirectory \u201ccars\u201d to Desktop, with me being in the Desktop directory and not directory \u201ccars\u201d<\/p>\n<p>What if you want to rename the file? To rename a file using the mv command, use the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mv &lt;oldname&gt; &lt;newname&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command-in-linux.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109847\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command-in-linux.webp\" alt=\"mv command in linux\" width=\"780\" height=\"212\" \/><\/a><\/p>\n<p>In the above output, I have renamed the file \u201cnew.txt\u201d to \u201cferrari.txt\u201d.<\/p>\n<p>If you want even more efficiency, you can even move and rename a file at the same time in 1 single command! To do so, use the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mv &lt;oldname&gt; &lt;path of new location&gt; &lt;new name&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command-linux.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109848\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/mv-command-linux.webp\" alt=\"mv command linux\" width=\"952\" height=\"212\" \/><\/a><\/p>\n<p>In the above output, I renamed the file \u201cnew.txt\u201d to \u201cferrari.txt\u201d and moved it to the subdirectory \u201ccars\u201d just using 1 single command.<\/p>\n<p>Tell me, if you had to do the above example, how many clicks would it have taken, first renaming, then pressing \u201cctrl\u201d + \u201cx\u201d and then go the specific directory and then press \u201cctrl\u201d + \u201cv\u201d. See? that is exactly why the terminal is God tier!<\/p>\n<h3>Linux CP command<\/h3>\n<p>Not only you just moving the files from one location to another using the terminal, but you can also copy files from one directory to another. In fact in the GUI, once you copy, you even have to paste it back. But in the terminal, the cp command does the pasting job.<\/p>\n<p>The cp command is very powerful and efficient as you can copy 1 file into another, many files into 1 directory, and also 1 directory into another directory. Let us look into the syntax along with an example for each of the above-mentioned tasks<\/p>\n<h4>1. Copying a file to another file (2 file names)<\/h4>\n<p>As we have seen, to copy the contents of 1 source file to a destination file we need only 2 files names:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cp &lt;options&gt; &lt;source file&gt; &lt;destination file&gt;<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-a-file-to-another-file.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109850\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-a-file-to-another-file.webp\" alt=\"copying a file to another file\" width=\"1060\" height=\"208\" \/><\/a><\/h4>\n<h4>2. Copying one or more files to a directory (More than one argument)<\/h4>\n<p>to copy the contents of multiple source files to a destination file, we need to enter the names of the multiple files followed by the destination directory:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cp &lt;options&gt;&lt;source file1&gt;&lt;source file2&gt; &lt; destination directory&gt;<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-one-or-more-files-to-a-directory.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109851\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-one-or-more-files-to-a-directory.webp\" alt=\"copying one or more files to a directory\" width=\"906\" height=\"312\" \/><\/a><\/h4>\n<h4>3. Copying entire directories into a directory (2 directory names)<\/h4>\n<p>to copy the contents of a source directory to a destination directory, we need to enter the names of the source and destination directories:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cp -R &lt;source directory&gt; &lt;destination directory&gt;<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-entire-directories-into-a-directory.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109852\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/copying-entire-directories-into-a-directory.webp\" alt=\"copying entire directories into a directory\" width=\"985\" height=\"280\" \/><\/a><\/p>\n<p>You must note that if the destination file or directory does not exist, the cp command will automatically create it for you. However, if it already exists, it will overwrite the contents. Hence you must select the name of the destination with care.<\/p>\n<p>Here are 2 precautions you can take to avoid overwriting while copying data<\/p>\n<h4>1. Asking before overwriting<\/h4>\n<p>If you are not sure, if the destination file exists already and has contents you feel are important, you can make cp to prompt you to allow overwriting or not by using the option \u201c-i\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/asking-before-overwriting.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109853\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/asking-before-overwriting.webp\" alt=\"asking before overwriting\" width=\"933\" height=\"118\" \/><\/a><\/p>\n<h4>2. Completely Avoid overwriting<\/h4>\n<p>If you completely want to avoid overwriting and don\u2019t want to overwrite the existing files, use the option \u201c-n\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/completely-avoid-overwriting.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109854\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/completely-avoid-overwriting.webp\" alt=\"completely avoid overwriting\" width=\"847\" height=\"56\" \/><\/a><\/p>\n<h3>Linux MKDIR command<\/h3>\n<p>We learned how to create file, it is only fair to learn how to make directories too. To make directories we use the mkdir command with the following syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mkdir &lt;name of directory&gt;<\/pre>\n<p>The mkdir command is an abbreviation for Make Directory.<\/p>\n<p>To make a directory in a specific parent directory, you must first be there.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/specific-parent-directory.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109855\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/specific-parent-directory.webp\" alt=\"specific parent directory\" width=\"921\" height=\"183\" \/><\/a><\/p>\n<p>If you feel lazy to go to that specific directory to create a subdirectory in it, you can create a directory anywhere, just by writing its path, no matter where you are (on the computer).<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-mkdir.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109856\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-mkdir.webp\" alt=\"linux mkdir\" width=\"1005\" height=\"183\" \/><\/a><\/p>\n<p>In the above output, I created the directory \u201cBMW_pictures\u201d in the path \u201c\/home\/gopikiran\/Desktop\/cars\u201d even though I was in the path \u201c\/home\/gopikiran\/Desktop\/DataFlair\u201d (different directories).<\/p>\n<h3>Linux RMDIR command<\/h3>\n<p>Need to remove a created directory, rmdir does just that. Rmdir is the abbreviation for Remove Directory. It functions exactly like the mkdir command.<\/p>\n<p>If you simply used the syntax: rmdir &lt;directory name&gt;, you will remove the directory with that specific name, only if it is there in the directory you are currently in.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/rmdir-command-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109857\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/rmdir-command-1.webp\" alt=\"rmdir command\" width=\"871\" height=\"175\" \/><\/a><\/p>\n<p>If you use the syntax: rmdir &lt;path of directory&gt;, you will remove that specified directory regardless of which directory you are currently in.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-rmdir-command-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109858\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-rmdir-command-1.webp\" alt=\"linux rmdir command\" width=\"976\" height=\"188\" \/><\/a><\/p>\n<p>In the above output, I removed the directory \u201cBMW_pictures\u201d in the path \u201c\/home\/gopikiran\/Desktop\/cars\u201d even though I was in the path \u201c\/home\/gopikiran\/Desktop\/DataFlair\u201d (different directories).<\/p>\n<h3>Linux RM command<\/h3>\n<p>The rm command is the rmdir command on steroids. The rmdir command can perform actions only on directories, whereas the rm command can perform actions on both files and directories. Rm stands for Remove.<\/p>\n<p>To remove a file use the syntax:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\u201crm &lt;filename&gt;\u201d<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/rm-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109859\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/rm-command.webp\" alt=\"rm command\" width=\"707\" height=\"177\" \/><\/a><\/p>\n<p>To delete a directory use the syntax: \u201crm -R &lt;directory name&gt;\u201d The option \u201c-R\u201d means recursively.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-rm-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109860\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-rm-command.webp\" alt=\"linux rm command\" width=\"700\" height=\"177\" \/><\/a><\/p>\n<h3>Linux FIND and LOCATE commands<\/h3>\n<p>The last thing you need to know to become a pro in managing your files using the terminal in Linux is the find the files or directories you have created. That is exactly what the commands find and located do. First, let us take the case of the find command<\/p>\n<h4>Linux find command<\/h4>\n<p>The find command searches for a file in a particular location. It takes two arguments: the search path or directory and the file to be searched. The syntax of the find command is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\u201cfind &lt;path&gt; -name &lt;file or directoryname&gt;\u201d<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/find-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109861\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/find-command.webp\" alt=\"find command\" width=\"838\" height=\"157\" \/><\/a><\/h4>\n<h4>Linux locate command<\/h4>\n<p>The find command is very similar to the find command, except locate only takes 1 argument: the filename<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/locate-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109862\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/locate-command.webp\" alt=\"locate command\" width=\"776\" height=\"165\" \/><\/a><\/p>\n<p>The locate command searches the entire system for that file or directory you specified. The locate command is much faster than the find command, but the find command is much more powerful because it works in situations where the locate command fails to give desirable results.<\/p>\n<h3>Linux wc command<\/h3>\n<p>Here is a bonus command for sticking around till the end: The wc command is a very handy and powerful tool that helps in the process of counting the lines, words, and characters in a file. The wc command is usually used by piping it to some main command.<\/p>\n<p>By default, the wc command prints the number of lines, number of characters, and the number of words one after the other separated by a space<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/wc-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109863\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/wc-command.webp\" alt=\"wc command\" width=\"593\" height=\"312\" \/><\/a><\/p>\n<p>In the above output, there are 8 words, 8 lines and 62 characters.<\/p>\n<p>Remember when I told that the wc command was powerful? Well, it can even tell you the count of lines, words and characters in multiple files.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-wc-command.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109864\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/linux-wc-command.webp\" alt=\"linux wc command\" width=\"790\" height=\"156\" \/><\/a><\/p>\n<p>You can also use the wc command by piping it, here\u2019s an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/wc-command-linux.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109865\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/wc-command-linux.webp\" alt=\"wc command linux\" width=\"704\" height=\"146\" \/><\/a><\/p>\n<p>Let us look at some of the options that are used with the wc command:<\/p>\n<h4>1. -c<\/h4>\n<p>This option prints the count of the bytes.<\/p>\n<h4>2. -m<\/h4>\n<p>This option prints the count so the characters.<\/p>\n<h4>3. -l<\/h4>\n<p>This option prints the count of the lines.<\/p>\n<h4>4. -w<\/h4>\n<p>This option prints the count of the words.<\/p>\n<h4>5. -L<\/h4>\n<p>This option prints the maximum display width.<\/p>\n<h3>Metacharacters or wildcards in Linux<\/h3>\n<p>Just like In the card game \u2018UNO\u2019, the wildcard takes any card you want it to be, Linux also has a wildcard that is denoted by an asterisk. These wildcards are technically called metacharacters.<\/p>\n<p>You can use these when you are targeting a large group of files. For example, if you want to operate some command on all the \u2018.txt\u2019 files in a &#8216;specific directory, it would be time-consuming to list every single \u2018.txt\u2019 file (that is even if you remember them) instead, you can use the wildcard to target all the \u2018.txt\u2019 files by using the wild cars as shown \u201c*.txt\u201d.<\/p>\n<p>You can also use metacharacters to target a specific name. For example, if you want to target all the files starting with \u201cUbuntu\u201d, you can use the wildcard as shown: \u201cUbuntu.*\u201d, this will select all types of files with names starting with \u201cUbuntu\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/metacharacters-in-linux.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-109866\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/metacharacters-in-linux.webp\" alt=\"metacharacters in linux\" width=\"763\" height=\"189\" \/><\/a><\/p>\n<p>In the above output, I have listed only \u201c.txt\u201d files and \u201c.odt\u201d files separately by using the wildcard (*).<\/p>\n<h3>Summary<\/h3>\n<p>As you have seen linux file management system and managing files and directories is much more efficient and simple using the terminal than the GUI. You have now learned how to manage files using the following commands: pwd, cd, ls, cat, mv, cp, mkdir, rmdir, rm, find and locate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By the end of this article, you will become a pro at managing files through the terminal in Linux. Yes, you read that right, we are going to learn file management system in Linux.&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":109799,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[26966,26963,26962,26965,26964],"class_list":["post-109678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux-directories","tag-linux-file-management-system","tag-linux-file-system","tag-linux-regular-files","tag-linux-special-files"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>File Management in Linux - DataFlair<\/title>\n<meta name=\"description\" content=\"See Linux File management system. Learn managing files through the terminal in Linux &amp; various commands like PWD, cd, cat, ls, rm, mv, cp etc\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/file-managment-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"File Management in Linux - DataFlair\" \/>\n<meta property=\"og:description\" content=\"See Linux File management system. Learn managing files through the terminal in Linux &amp; various commands like PWD, cd, cat, ls, rm, mv, cp etc\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/file-managment-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-12T04:30:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-12T04:31:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"31 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"File Management in Linux - DataFlair","description":"See Linux File management system. Learn managing files through the terminal in Linux & various commands like PWD, cd, cat, ls, rm, mv, cp etc","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/","og_locale":"en_US","og_type":"article","og_title":"File Management in Linux - DataFlair","og_description":"See Linux File management system. Learn managing files through the terminal in Linux & various commands like PWD, cd, cat, ls, rm, mv, cp etc","og_url":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-08-12T04:30:15+00:00","article_modified_time":"2022-08-12T04:31:33+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"31 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"File Management in Linux","datePublished":"2022-08-12T04:30:15+00:00","dateModified":"2022-08-12T04:31:33+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/"},"wordCount":3834,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp","keywords":["linux directories","linux file management system","linux file system","linux regular files","Linux special files"],"articleSection":["Linux Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/file-managment-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/","url":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/","name":"File Management in Linux - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp","datePublished":"2022-08-12T04:30:15+00:00","dateModified":"2022-08-12T04:31:33+00:00","description":"See Linux File management system. Learn managing files through the terminal in Linux & various commands like PWD, cd, cat, ls, rm, mv, cp etc","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/file-managment-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/05\/file-management-in-linux.webp","width":1200,"height":628,"caption":"file management in linux"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/file-managment-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Linux Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/linux\/"},{"@type":"ListItem","position":3,"name":"File Management in Linux"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/109678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=109678"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/109678\/revisions"}],"predecessor-version":[{"id":109870,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/109678\/revisions\/109870"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/109799"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=109678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=109678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=109678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}