How to move one file to a folder using terminal?
up vote
37
down vote
favorite
I want to move one file to a folder using terminal. How do I do this?
command-line
add a comment |
up vote
37
down vote
favorite
I want to move one file to a folder using terminal. How do I do this?
command-line
linuxcommand.org/learning_the_shell.php Check out themvcommand.
– dan08
May 14 '14 at 16:11
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
2
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56
add a comment |
up vote
37
down vote
favorite
up vote
37
down vote
favorite
I want to move one file to a folder using terminal. How do I do this?
command-line
I want to move one file to a folder using terminal. How do I do this?
command-line
command-line
edited Jul 6 '17 at 13:43
muru
134k19283484
134k19283484
asked May 14 '14 at 16:09
Louise Avon
3062512
3062512
linuxcommand.org/learning_the_shell.php Check out themvcommand.
– dan08
May 14 '14 at 16:11
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
2
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56
add a comment |
linuxcommand.org/learning_the_shell.php Check out themvcommand.
– dan08
May 14 '14 at 16:11
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
2
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56
linuxcommand.org/learning_the_shell.php Check out the
mv command.– dan08
May 14 '14 at 16:11
linuxcommand.org/learning_the_shell.php Check out the
mv command.– dan08
May 14 '14 at 16:11
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
2
2
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56
add a comment |
2 Answers
2
active
oldest
votes
up vote
47
down vote
accepted
mv [file] [directory]
For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/
As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.
If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:
sudo mv info.txt config/
BIG IMPORTANT NOTE:
Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
add a comment |
up vote
3
down vote
You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:
mv info.txt config/information.txt
This would move the file and change its name.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
47
down vote
accepted
mv [file] [directory]
For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/
As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.
If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:
sudo mv info.txt config/
BIG IMPORTANT NOTE:
Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
add a comment |
up vote
47
down vote
accepted
mv [file] [directory]
For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/
As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.
If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:
sudo mv info.txt config/
BIG IMPORTANT NOTE:
Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
add a comment |
up vote
47
down vote
accepted
up vote
47
down vote
accepted
mv [file] [directory]
For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/
As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.
If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:
sudo mv info.txt config/
BIG IMPORTANT NOTE:
Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.
mv [file] [directory]
For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/
As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.
If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:
sudo mv info.txt config/
BIG IMPORTANT NOTE:
Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.
edited Dec 13 '17 at 8:11
derHugo
2,25921428
2,25921428
answered May 14 '14 at 16:12
David Oneill
5,634104366
5,634104366
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
add a comment |
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
1
1
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
– Panther
May 14 '14 at 16:13
add a comment |
up vote
3
down vote
You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:
mv info.txt config/information.txt
This would move the file and change its name.
add a comment |
up vote
3
down vote
You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:
mv info.txt config/information.txt
This would move the file and change its name.
add a comment |
up vote
3
down vote
up vote
3
down vote
You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:
mv info.txt config/information.txt
This would move the file and change its name.
You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:
mv info.txt config/information.txt
This would move the file and change its name.
answered May 14 '14 at 16:20
mbrookes1304
311
311
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f465877%2fhow-to-move-one-file-to-a-folder-using-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
linuxcommand.org/learning_the_shell.php Check out the
mvcommand.– dan08
May 14 '14 at 16:11
use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13
2
Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43
@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56