【 Manage Files and Directories in Linux 】 Step by Step Guide ▷ 2022

or managing all kinds of within the OS is not complicated if you know the commands you have at your disposal. Once you know how to move around the terminal you will be one step away from making all the modifications you want.

Therefore, you will be able to copy, open, delete or edit them in a few steps. For this You will have to use the information that you will find in the following paragraphs of this article.

You will also find all the information related to the step by step that you must do to perfectly manage those of Linux.

What should we take into account when managing Linux files?

To open the terminal in Linux you will need to press the key combination Ctrl + Alt + T. Keep in mind that everything you see inside this terminal is seen as a file, including the connected physical elements. On the other hand, if you are new to linux remember that the OS interprets lowercase and uppercase differently. So that, when writing the title of the files this writing must be as exact as possible. That without forgetting to space correctly with bars, points and quotation marks.

Another aspect that you should take into account is that the (files that order other files or directories) start from a base directory or “root”, as it is also known. The latter will always be symbolized with a bar /. If you do not want complications when operating, The easiest is to enable the “root” user. This represents the home directory of the administrator of the whole system. You will visualize it with a hash or pound # being very useful to avoid several limitations.

What are the main commands used in managing files and directories in Linux?

The main commands that you will have to use to work with files and directories in Linux are:

  • exit: This is a very used and useful command because it helps you to log out of the user you are using.
  • touch: Using this application you will be able to generate a file or file from scratch, completely empty.
  • ls: a basic resource to list the files inside the container file or directory in which it is located.
  • cat: you will be able to use this command when you want to open the content of a file. It is also widely used and easy to implement.
  • cop: this command is used to duplicate files as many times as you need and in the direction you want. To make it easier to remember, it comes from English “copy”.
  • mv: In the case that you do not need to copy a file, but to change its location, you will have to use this argument. In addition, it is valid to modify the title of the files.
  • mkdir: helps to form or generate a new directory, or a set of them, from the current location.
  • pwd: shows the full path that has taken you to the directory where you are at the time of using it.
  • clear: means clean in English and it is what it executes, a complete cleaning of the terminal, leaving it empty for new commands.
  • sherd: End forever with a file or file that you want to remove from the OS. It acts very similar to
  • rmdir: used to remove blank directories that do not have any content. This works the opposite of rm either sherd which exterminates entire files or directories.
  • more or less: with this command you will be able to view without altering the content of a certain file.
  • ln: thanks to this argument you will be able to generate hard links or symbolic links of the files. Thus producing labels for a certain file.
  • Help: This is a very nice tool that shows you a simplified listing of all the commands you can run in the terminal.
See also  【Make Expense Control Sheet in Excel】Step by Step Guide ▷ 2022

Learn step by step how to perfectly manage files in Linux

We will show you below the step by step that you have to do to manage the files in Linux:

View Files within a directory

You should follow this guide:

  • once you’ve open terminala convenient way to see all the files inside a directory or folder is with ls, preceded by the exact name of the directory. For example, /mydocuments ls.
  • such a command will list the internal files one by one
  • And if you want to see the files in the directory where you are currently put ls -lh.
  • But if you need to display hidden files use ls -a.

delete files

To delete files you will have to do this step by step:

  • If you only need to remove a file inside the directoryyou will have to enter it.
  • Then you will have to establish The ubication, that is, what directory it is in. Then you must write the file title divided like this example: rm /mydocuments /my.example.

You should keep in mind that rm–r deletes all files and directories repeatedly and indefinitely and that the argument rm–f either rm–fr kills files and directories without confirmation. Therefore, these last methods should only be used when you are completely sure, otherwise you will lose all the information.

Edit files (cat or nano)

To carry out this task, you will have to take into account the following:

  • The argument cat It has multiple editing uses, from merging to creating new files. For example, if you want to generate a new file and then edit the text, you’ll have to use cat next to the file title. An example of this would be: cat example.de
  • You will then have to continue writing on the other lines by pressing Enter each time and when you want to finish, you will have to press Ctrl+D.
See also  【 Create Files in Linux 】 Step by Step Guide ▷ 2022

In the case of a more complete text file editor, you can use elder brother and then the file name. For example, nano example.de

change directory

When you want to change directory in Linux, you will have to follow this guide:

  • Write the command CD.
  • Beside CD you must place a bar /then he current directory in which you are, another bar / and the new directory to which you want to move. Resulting in the command cd /mydocuments/newdocuments

if you use cd . . will move to the parent directory, if it exists, and with cd – the program will redirect you to the previous directory. You can also use just cd / to locate you in the root directory.

Delete Directory

If what you are looking for is to delete a directory, you will have to proceed as follows:

  • place rmdir continuing with the writing of the title of the directory that you want to delete. In this way it will remain rmdir documents to delete.
  • In this way will forever throw away blank directories that you do not require

Like other delete commands, the rmdir does not ask for request to be executed, so you should make sure before deleting a directory.

Delete files within an archive

In case you need to delete one or more files within a folder, you will have to do the following:

  • The safest way to delete a file is through the command This overwrites it up to 25 times, being able to completely alter the content. if you write sherd -or you will delete complete files without the possibility of restoring them, something similar to rmbut more effective.
  • So you will have to write sherd -or plus the name of the corresponding file. This will look like this: sherd -u /mydocuments either sherd –u/mydocuments/example.de.
  • Another command you can use is sherd-fuz followed by the name of the file to promote deletion. If you need help, you will have to write sherd help.

create new file

When you need to create a new file, follow this step by step:

  • Since the objective is to generate a new blank file from the current location, you will have to use the command touch. For this, you will have to write it followed by the name you need to give to the new file, for example: touch example.de
  • Keep in mind that it works the same way to modify time and date. In this case you will have to enter touch –t followed by the date and time (month, day, year, hour and minute together) and file title, so you will have touch –t 073020201640 example.of.
See also  【Share Video to YouTube】Step by Step Guide ▷ 2022

create new directory

To create a new directory, do the following:

  • Just use the command mkdir, remembering that you must place the directory in which you are. Then, you will have to enter the slash and the name of the new directory that you want to create. An example of this is mkrdir /mydocuments/exampleofnewdocument.
  • You can also generate an entire directory tree using the option mkdir -p.
  • Also, with the alternative mkdirhier You will be able to establish a defined hierarchy in the directories.

Copy files and directories

When you need to copy files and directories, follow the steps below:

  • To duplicate an original file in a destination file, you will have to write cop, then you will have to put the source directory, the file title, the destination directory and finally the file title. For example, cp /mydocuments/example.de/newdocuments/example.de.

But if what you want is to copy the entire directory completely, you can use cp -r.

View content of a file

If what you need is to see the content of a file, pay attention to this guide:

  • when you enter cat You will be able to see the content of a file in simple terms, but it will not be able to page or modify its data.
  • if you place cat followed by the title of an existing file cat example.de you will make the full screen print.
  • Instead, if you use the argument more or less, you will have a more optimal display, paginated and with the function of going back and forward. For this, you will have to write more either less before the file title. It will be like this: more example.of either less example.de.
Loading Facebook Comments ...
Loading Disqus Comments ...