Cadastre-se agora para um orçamento mais personalizado!

How to copy and rename files from the Linux terminal window

19 de julho de 2023 Hi-network.com
PixelsEffect/Getty Images

When you first start using Linux, you'll most likely be glued to the GUI. That's not only totally understandable but acceptable. There is no shame in not using the command line. In fact, you could go your entire Linux life without ever touching the terminal window.

But for some tasks, the terminal is simply more efficient. The only difference to using the GUI is that you have to remember the commands to use. 

Also: How to replace Windows with Linux Mint on your PC

I want to help you with this process. In fact, my goal all along is to make Linux easy to understand for the masses. As part of that effort, I like to include the command line interface (CLI) because there's so much you can do with it. 

With that in mind, let's start with two very simple but handy commands for copying and renaming files.

Ready to type?

How to copy a file

What you'll need:The only thing you'll need for this process is a running instance of Linux. It won't matter what distribution you use, as the two commands I'm going to show you are included with every version of Linux you'll encounter.

1. Open a terminal window

The first thing to do is open a terminal window. To do this, open your desktop menu and either search for "terminal" or navigate through the default menu until you find the terminal listed. The name of this app will will depend on the desktop you're using. 

Also: The best Linux distros for beginners

Fortunately, most desktops use fuzzy searching, so if you type terminal in the menu search field, it should appear (whether it's Konsol, Terminal, Tilex, or any number of options). The good news is most Linux terminals work the same way.

2. Copy a file

Let's say you have a file named zdnet_test.txt in your home directory and you want to copy it to your Documents directory. The command for that process would be:

cp ~/zdnet_test ~/Documents/

One thing to note is that ~/ is a shortcut for /home/USER (where USER is your username), so you don't have to type as much. 

Also: How to choose the right Linux desktop distribution

If you were already in your home directory (which your terminal app should default to when you first open it), you could short the command to:

cp zdnet_test Documents

How to rename a file

Let's now rename a file.

1. Renaming while copying

You can rename a file, while copying it. Let's say you want to copy zdnet_test to Documents, but also rename it to zdnet.test. For that, the command would be:

cp zdnet_test Documents/zdnet.test

Remember, the above command would only work if you were already in your home directory, otherwise you'd need to add ~/ on both ends, like so:

cp ~/zdnet_test ~/Documents/zdnet.test

2. Renaming while moving

You can also rename a file when moving it. This process is almost the same as above, but you're not copying a file to another directory, you're moving it. 

Also: How to enable Linux on your Chromebook

This task is accomplished with themvcommand. We'll stick with our example. Say, you have zdnet_test in your home directory, and you want to move it to Documents and rename it to zdnet.test at the same time. The command for this process is:

mv zdnet_test Documents/zdnet.test

Remember, if you're not already in your home directory, that command would be:

mv ~/zdnet_tst ~/Documents/zdnet.test

And that's all there is to renaming a file in Linux. This is a very basic task that you can use to get accustomed to the Linux CLI...but only if you feel the need to start broadening your understanding of the open-source operating system. Otherwise, stick to the GUI.

See also

How to install Ubuntu Linux (It's easy!)How to run a Windows app on Linux with WineHow to get started with Git on LinuxHow to kill a process in Linux
  • How to install Ubuntu Linux (It's easy!)
  • How to run a Windows app on Linux with Wine
  • How to get started with Git on Linux
  • How to kill a process in Linux

tag-icon Tags quentes : Tecnologia Nosso processo Serviços & Software Código aberto

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.