Table of Contents
This tip is about the how To transfer and rename Files in Linux. So read this free guide, How To transfer and rename Files in Linux step by step. If you have query related to same article you may contact us.
How To transfer and rename Files in Linux – Guide
Files and directories on Linux are very similar from a file system point of view. This means that operations performed on one can also be performed on the other, with very few exceptions. So you will find that the commands to perform actions on files are the same as directories. Before delving into moving files, it’s worth taking a closer look at what actually happens when file system objects are moved. When a file is created, it is assigned an inode, which is a fixed point in a file system used for data storage.
Moving files on Linux may seem relatively easy, but there are more options than most people realize. When you move a file, you don’t actually move the data from one inode to another, you just give the file object a new file name or path. A file actually retains its permissions when it is moved because moving a file does not change or recreate it. The file and directory inodes never imply inheritance and are dictated by the file system itself. Inode allocation is sequential based on when the file was created and is completely independent of how you organize your computer.
Renaming Files in Linux
To rename a file in Linux you use the mv command. The command accepts two or more arguments. To rename files, only two arguments are needed, which are the source file and the destination file. The mv command will take the specified source file and rename it to the destination file.
To rename a file named student1 to student10, for example, you would run the following command.
As long as the file destination is the same directory, all file attributes will remain, including permissions.
Moving a file in Linux
To move a file to another location, we use the same method as renaming a file, except the file path must be different.
For example, to move a file from /home/student1/lab-work.log to /var/labs/student1/lab-work.log, you would run the following command.
Moving and Renaming Files in Linux
A file can be renamed during a move process using the mv command. You simply give the target path a different name. When mv moves the file, it gets a new name.
For example, to move a file named student1.txt to /var/students and rename it to class1-student1.txt, run the following command.
Moving Multiple Files in Linux
The mv command accepts multiple source files, which means we can move two or more files at the same time. When running the mv command, each file listed will be considered a source, with the last path being the exception. The last path will be treated as the destination.
For example, to move student1.txt and student2.txt to /var/students, run the following command.
Final note
I hope you like the guide How To transfer and rename Files in Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.