Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

Commands for files and directories in Linux What are they, what are they for and which are the most important?

Know what are the commands in Linux files and directories it will help you to run this operating system in a more secure way now save steps in your work.

For it, you need to know what the Linux file and directory commands are all about and what they are for in a terminal. This information can be found, in a detailed and simple way, in the next paragraphs.

Also you will be able to know the main commands that you can use for Linux files and directories, which we will show you with their syntax explained in an easy way. Check out.

What are Linux file and directory commands and what is their use?

The commands for Linux files and directories They are commands that are executed from a terminal so that the operating system performs certain actions on the directories and files. In this way you can know any type of detailed information that contain the same, show you the path in the form of a tree, permanently delete them and change their names, among other things. They are characterized by being intended for handling of the files and files that are inside the system.

Know the main commands for Linux files and directories that you can use

Know the main commands for Linux files and directories that you can use

We will show you below the main commands that you can use in Linux for files and directories:

  • basename: As with the previous command, this tool allows you to know the name, but of a file. Its use is basename [opciones] Ruta/al/archivo [ingresar un sufijo (jpg, txt, entre otros)].
  • cat: This command is used to group the content of several elements and to concatenate all the data within certain files. Its syntax is cat OPCIONES ARCHIVO1 ARCHIVO2 you can use the>,
  • cd: It is used to navigate the directory tree, find information within them and change from one file to another. Its syntax is cd [opción] DIRECTORIOIf no argument is added, the operating system will automatically go to the user’s home directory.
  • chroot: It is used to execute a command by means of a root change. That is, it is used to carry out an action within the root directory other than the one where the user is located.
  • cmp: This command is used to compare files and find detailed information byte by byte.
  • comm: If what you want is to compare the files that are classified according to the command line it uses, you will have to use this command. The options you will have are 3 to hide single lines of the files.
  • cp: It is one of the most used commands, since it allows copying directories and files defining a destination to host the new element. Its use is cp [opciones] Archivo de origen Directorio de destino.
  • cut: This command is used in a Linux terminal to extract the content of a file by lines.
  • diff: You can compare directories and files using this command as follows diff [opciones] Archivonúmero1 Archivonúmero2.
  • dirname: This command is used to obtain information about the file path without displaying the file name.
  • file: You will be able to obtain information about a file when you use this command in a Linux terminal.
  • ln: If you are looking to create a link to a directory or file, you will have to use this command with the syntax ln [opciones] ruta/quetiene/elarchivodeorigen.
  • ls: In this case, this command is used to list the content within a specific directory. Its use is ls [opciones] Nombre del DIRECTORIO.
  • lsof: When you need to know all the files that you have open in the Linux terminal, you will have to execute this command.
  • md5sum: This command is useful for calculating sums of MD5 type controls.
  • mkdir: When you need to create a directory from scratch you should use this command. It also allows you to create more than one file at the same time by entering the terminal mkdir [opción] DIRECTORIO número 1 DIRECTORIO número2.
  • mkdirhier: If what you are looking for is to generate a hierarchy within a directory, you must use this command as follows mkdirhier [opción]/home/user/directorio1/directorio2/directorio3/directorio4
  • mv: It is another of the commands that are most used in Linux, since it allows you to move the directories and files to different destinations. Used with this structure mv [opción] nombre de origen y destino.
  • paste: You will be able to use this command in a console of the operating system with a Linux environment when you need to group the content of a file into columns. Its syntax is paste [opciones] Nombre de archivo1 Nombre de archivo2.
  • pwd: This command is used to know the name of the file.
  • rename: Its name indicates everything, this command is executed in a Linux terminal when a file needs to be renamed.
  • rm: You must be careful when you execute this command, since it is in charge of permanently deleting a directory or file. Its use is rm [opciones] Nombre del directorio o del archivo.
  • rmdir: In case you need to delete a directory completely, you will have to use this command to execute it in a Linux terminal. You must bear in mind that this action is direct, since it does not request confirmation of the deletion.
  • shred: Shred is used to permanently delete any type of file.
  • sort: It is used to give an order to the files by means of a list. It is also used to randomize, numerically or reverse the outputs of the program.
  • split: You will be able to split a file when you use this command. Its results will show you subfiles if you use the structure split [opciones] [INPUT [prefijo]].
  • stat: In case you need to work with the date and time in the files, you will have to use this tool in the Linux terminal.
  • touch: This function is used to change the time and date of the accesses to the different files that you have saved. The syntax for this command is touch [opciones] Nombre del archivo.
  • tree: If you are one of the users who like to see the directories in the form of a tree, you will have to use this command to know the schema in a synthetic way. Its use is tree [opción] [DIRECTORIO]
  • uniq: This useful tool allows you to permanently delete files that have duplicates in the operating system. You can also use it to output this program.