Anyone new to the Linux environment must be familiar with basic directory navigation and file management commands. On Linux, each command is used for a specific purpose that works well for the given task. The ‘mc’ tool, known as Midnight Commander, is a file manager used for Linux terminals. It acts as a good front end for executing all commands related to file management.
This article will teach you how to manage files using commands like ls, cd, rm, etc., and how to install the Midnight Commander file manager on CentOS 8.
The following commands are used for file management under CentOS 8.
List files – using the ls command
The ‘ls’ command is used to list directories and files in a directory. By default, the ‘ls’ command lists all files and directories in the current directory. You use the following command to list items in the current directory:
You can also recursively list elements of a directory. To recursively list files in a specific directory, use the following command:
$ ls -R
You can also list files from another system’s directory. To do this, use the ‘ls’ command to specify the full path of a specific directory. For example, if you want to list your home directory files, use the ‘ls / home / sam’ which lists all files in the home directory.
Change directory – with the cd command
The ‘cd’ command is used to change from the current directory to another.
Example of a CD command
For example, if you want to go to ‘Downloads’, use ‘cd Downloads’, which you place in the Downloads directory.
You can also use the cd command to change to a specific directory by specifying the full path as ‘cd / home / sam / personal’.
You use ‘cd ..’ to go one step up to another directory.advertising
Remove file – with the rm command
The ‘rm’ command is used to remove or delete files. Before using this command, you need to be careful as it doesn’t ask the user for confirmation. The basic syntax of this command is given below:
$ rm filename
For example, if you want to remove a ‘test.py’ file, use ‘rm test.py’ to delete that file.
You can also remove or delete files from other directories. In this case, enter the full path of a file such as ‘rm / home / sam / testfile’.
Move files – using the mv command
The ‘mv’ command is used to move files to a new location. This command is also used to rename a file. For example, to name the file ‘home’ as ‘newfile’, use the following command:
$ mv home newfile
For example, if you want to move the files ‘workplace’ and ‘testfile1’ from the home directory to ‘Downloads’, use the following command:
$ mv workplace testfile1 Downloads
Similarly, you can move a file to other directories to provide the full path, e.g. B. ‘mv newfile / home / sam’.
Copy files – using the cp command
The cp command is used to make a copy of the file in a different directory instead of moving it.
$ cp filename Directoryname
For example, if you want to make the copy of ‘testfile2’ and ‘testfile3’ in ‘Downloads’ from the home directory, use the following command:
$ cp testfile2 testfile3 Downloads
Create a new directory – using the mkdir command
The ‘mkdir’ command is used to create a new directory.
For example, if you want to create a new directory of Samreenatasks in the current directory, enter the following command:
$ mkdir Samreenatasks
Create symlinks – with the command ln
The ‘ln’ command is used to create links. You can create a symbolic link with the following command:
$ ln -sf ~/bin/topprocs.sh topps.sh $ ls -l topps.sh
For example, you want to create a symbolic link with the name ‘topps.sh’ to the file ‘topprocs.sh’. ‘-Sf’ is used here, which forces you to create a new link.
Change Permission – Using the chmod command
The chmod command is used to change the permissions on a file. The basic syntax is given below:
$ chmod 777 -R directory_name
Midnight Commander – mc file manager
You can also install the file manager ‘mc’ on your system. To do this, first log into your system as the root user.
Then install the mc file manager on your system using the yum command:
This process will take some time. A security query is displayed in the terminal during installation. You will press ‘y’ to continue. After that, the rest of the installation on your system will be completed.
After you have completed the installation of the Midnight Commander, enter ‘mc’ on the terminal to open the user interface of the mc file manager.
Now use the arrow keys to navigate between the options. You can open the help window with ‘Alt + 1’ and use other keys as required.
In this article you learned how to manage files and directories with the terminal and how to install the midnight commander tool on CentOS 8. Hope this article will help you in the future. You can also explore other functions of the mc file manager.