Linux Newbies: Managing Files with Terminal in CentOS 8

Any user new to the Linux environment should know about the basic commands for navigating directories and managing files. In Linux, each command is used for a specific purpose that works well for the specified task. The mc tool, known as Midnight Commander, is a file manager used for the Linux terminal. It acts as a good interface for executing all file management related commands.

In this article, you will learn how to manage files with commands like ls, cd, rm, etc., and how to install Midnight Commander file manager on CentOS 8.

The following commands are used to manage files on CentOS 8.

List files – using the ls command

The ‘ls’ command is used to list directories and directory files. By default, the ‘ls’ command lists all files and directories in the current directory. You will use the following command to list the items in the current directory:

 $ ls

You can also recursively list directory items. To recursively list the files in a specific directory, you use the following command:

$ ls -R

Recursive file list

You can also list files from another system directory. To do this, you will provide the full path to a specific directory using the ls command. For example, if you want to list the files in your home directory, you would use ls / home / sam, which will list all the files in your home directory.

Change directory – using the cd command

The ‘cd’ command is used to change from the current directory to another.

Linux cd command

CD command example

For example, if you want to navigate to the Downloads section, you would use Downloads from CD to navigate to the Downloads directory.

Using the cd command, you can also change to a specific directory by specifying the full path as “cd / home / sam / personal”.

Change directory with cd command

You will use ‘cd ..’ to go one step up to another directory.

Delete file – using rm command

The ‘rm’ command is used to delete or delete files. Before using this command, you must be careful because it will not prompt the user for confirmation. The basic syntax for this command is shown below:

$ rm filename

Delete file using command line

For example, if you want to remove the file test.py, you will use rm test.py to remove that file.

You can also delete or delete files from other directories. In this case, you will specify the full path to a file like “rm / home / sam / testfile”.

Moving files – using the mv command

The ‘mv’ command is used to move files to a new location. This command is also used to rename the file. For example, you want to name your home file “new file”, then you would use the following command:

$ mv home newfile

Move files with mv command

For example, if you want to move the files “workstation” and “testfile1” from the home directory to “Downloads”, use the following command:

$ mv workplace testfile1 Downloads

Move multiple files with one command

Likewise, you can also move the file to other directories to specify the full path, for example mv newfile / home / sam.

Copy files – using the cp command

The cp command is used to create a copy of a file in a different directory instead of moving it.

$ cp filename Directoryname

Copy files using CP command

For example, if you want to generate a copy of testfile2 and testfile3 in the Downloads section from your home directory, you would 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 Samreenatasks directory in the current directory, enter the following command:

Create directory with mkdir

$ mkdir Samreenatasks

Creating symbolic links – with the ln command

The ln command is used to create links. You can create a symbolic link using the following command:

$ ln -sf ~/bin/topprocs.sh topps.sh

$ ls -l topps.sh

Linking Files - Symbolic Links

For example, suppose you want to create a symbolic link named “topps.sh” to the file “topprocs.sh”. This uses ‘-sf’ which will force you to create a new link.

Change permission – with chmod command

The chmod command is used to change the permissions on a file. The basic syntax is below:

$ chmod 777 -R directory_name

Chmod command on CentOS

Midnight Commander – mc file manager

You can also install the “mc” file manager on your system. To do this, you will first be logged in as the root user.

Then install the mc file manager on your system using the yum command:

Install Midnight Commander (MC)

This process will take some time. During installation, a confirmation prompt will be displayed in the terminal. You will press “y” to continue. This will complete the remaining installation on your system.

Confirm installation

After the installation of Midnight Commander is complete, you will type “mc” in a terminal to open the mc file manager interface.

Midnight Commander on CentOS

You will now navigate between the options using the arrow keys. You can open the help window using Alt + 1 and you can use other keys as per your requirement.

How to use mc on CentOS

Conclusion

In this article, you learned how to manage files and directories using the terminal and how to install the Midnight Commander tool on CentOS 8. I hope this article helps you in the future. You can also explore additional features of the mc file manager.

Linux Newbies: Managing Files with Terminal in CentOS 8

Sidebar