Skip to main content

Linux Command Line Tutorial For Beginners - mv command

In this Blog, we will learn how we can use mv command in Linux.
 
mv command is used to move files and directories.


First of all open Terminal, Ctrl+Alt+t .
 
Syntax for mv command is:

mv [options] [source] [Destination]

One more feature or say use of mv command is to change directory name and rename files.

So, lets see how we can do this:


In above example we had changed file name text1.txt to text2.txt and the content of the file remains same as it is.

Now, if you want to move a file into a particular directory then we will use command as:

mv [File_name] [Directory_name] 


You can see that previously dir1 contains only text1.txt file after that we can see that in that directory another file get moved text2.txt.

As we already know dir1 contains text1.txt and text2.txt files and if we try to move a file whose name is same as text2.txt which is already present in that directory then it will overwrite the contain of that file as we seen in previous blog, To avoid such type of condition we will use one option i.e., -i

mv -i [Source] [Destination]

Here -i means interactive which will ask before overwriting the content. 


If you type y and enter than the content will get overwritten and if we type n and enter then content will not be overwritten.

For move options you can try man command as:

man mv



For any query and suggestions you may contact with me or you may put comment in comment box.

Thank You.
Contact Details:
Phone: +91-8208826234 
E-mail: shivampawar1038@gmail.com

Comments

Post a Comment

Popular posts from this blog

Linux Command Line Tutorial For Beginners - Introduction

Hi Friends, Welcome to Blog , Welcome to Linux . Now first question you may ask yourself why we should learn command line, even if we have GUI ? So, Simple answer is that GUI ( Graphical User Interface ) is helpful in many task but not useful in all task, and when you learn command, you will observe that you are able to do your day to day task or any task related to programming much faster that you can do with GUI . By using command you can able to see what happening in a background when you given a something task. Before dive into the world of Linux you should know two terms i.e., Shell and Terminal. Now what is Shell? Shell is a simply a program that takes inputs from the keyboard and gives that to the operating system to perform task.It is also called as CLI ( Command Line Interface ), Now the second term is Terminal, terminal is tool which is used to pass a shell command, this is a program that open up a window and lets interacts with shell. There are different operating...

Linux Command Line Tutorial For Beginners - ls command

ls is a Linux shell command that lists directory contents which may be files or directories. First of all lets open Terminal, Alt+Ctrl+T ls command uses following syntax:          ls [option] [file or directory name] if we give simple ls command it will show us all directories and files present in home directory, as when we open terminal by default we are in home directory. Now if we want to see what is in Downloads directory then we simply give command as:                          ls Downloads Note one thing i.e., command line is case sensitive so we should write name of directory or file as it is. In same way you can able to see contents of any directory. If we want to see content of root directory then we will write command as: As we know / is called as root directory.      ...