pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

Creating, Moving, Renaming and Copying Files and Directories in Linux

Most basic Linux file and directory management – creating, renaming, moving and copying – can be achieved with the use of just three Linux commands. Their use is fairly straightforward, though it’s probably a good idea to be reasonably familiar with the Linux directory structure before getting too adventurous with file work (or download Knoppix to test drive Linux).

To rename a file, we use the mv command, giving two arguments. The first is the current name of the file, and the second is the name to change the file to.

$ mv oldname.txt newname.txt

Here the file oldname.txt is renamed to newname.txt. The same absolute and relative rules apply when addressing files here, so the file oldname.txt has to be in the current working directory.

Moving a file is achieved using the same command.

$ mv something.txt newplace/something.txt

This will move the file something.txt from the current directory to the directory newplace. The directory has to exist, and we’ll look at creating directories in a moment.

It might be worth pointing out that using the mv command can achieve both moving a file and renaming it at the same time, like this.

$mv oldname.txt newplace/newname.txt

So we come to copying files. This is done using the cp command.

$ cp this.txt there.txt

In this example the file this.txt is copied to file there.txt. This is extremely useful for creating backups of files before editing them. The convention in this case is to use a .BAK extension.

$ cp important.txt important.txt.BAK

Notice that the previous file extension of .txt has been kept, which isn’t necessary but just means that you won’t forget it.

Finally a point on the tilde character, ~. This is a special character that represents the current user’s home directory, and can provide a useful shorthand. For instance, take this command:

$ cp thisfile.txt ~

This will copy the file thisfile.txt into the home directory. This applies to mv too.

$ mv thisfile.txt ~

This moves the file to the home directory. It’s useful to remember, then, that the tilde ~ character means home.

Creating Directories

Organising your file system is hugely important so there will be times when you need to make directories for your files. This is done using the mkdir command. The argument is the name and location of the new directory, and the location can, as usual, be absolute or relative.

$ mkdir [directory]

As long as you have permission, this command will create a subdirectory, relative to the current directory, called whatever name you give it.

  • Advantage to Shared Web Hosting
  • Shared Hosting Issues – Shared Bandwidth and Server Resources
  • The Ins and Outs of Dedicated Web Hosting
  • When To Move To A Dedicated Server
  • Choosing a Dedicated Server for your Website
  • Managing and Operating a Dedicated Server Over the Internet Using Online Control Panels
  • Accessing the Linux Operating System on Dedicated Servers with PuTTY or SSH
  • How to Create a Secure Password
  • Using Sudo for Super User Access to Root Privileges in Linux
  • The Linux Directory Structure
  • Linux Commands for Navigating and Viewing Directories
  • Creating, Moving, Renaming and Copying Files and Directories in Linux
  • Find, View and Delete Files and Directories Using Linux Commands
  • Using vi to Edit Text Files on A Linux Dedicated Server

Filed Under: Moving from Shared to Dedicated Web Hosting

Latest Articles

OSI Model

The Open Systems Interconnection (OSI) reference model describes how information from a software application in one computer moves through a network medium to a software application in another computer. The OSI reference model is a conceptual … [Read More...]

ASUS P8Z77-V PRO

$229 - ASUS P8Z77-V PRO is an Intel 7 series mother board. Socket H2 (LGA1155) At this time the product has 2 great reviews on Tigerdirect and 1 negative review. Read Reviews here Prices change all the time.  View Current Price on TigerDirect Here Support Page including Drivers and … [Read More...]

Best DNS Providers of 2021 – Part 3

Here is the last installment of the best DNS providers of 2021. We hope it helps! DNS.Watch Okay, all that stuff about adding layers of customization and blocking some pages is fine. But you also have other alternatives like DNS.Watch, who prefer to offer you a full speed experience without … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Graphic Designers on Reddit Share their Views of AI

There are clearly a lot of positive things about AI. However, it is not a good thing for everyone. One of the things that many people are worried … [Read More...]

Redditors Talk About the Impact of AI on Freelance Writers

AI technology has had a huge impact on our lives. A 2023 survey by Pew Research found that 56% of people use AI at least once a day or once a week. … [Read More...]

11 Most Popular Books on Perl Programming

Perl is not the most popular programming language. It has only one million users, compared to 12 million that use Python. However, it has a lot of … [Read More...]

10 Exceptional Books on ChatGPT that Will Blow Your Mind

ChatGPT is a powerful new AI tool that is taking the world by storm. You are going to find a lot of amazing books that will teach you how to make the … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Watch Out for Fake Windows Phone Apps

Like other popular smart phones, the Windows Phone has a store where you go to get apps for it. There have been reports of fake apps turning up on the … [Read More...]

Keep Track of Product Serial Numbers

It's always a good idea to document serial numbers of the high priced gadgets in your home or business. If your place burns down, gets damaged in a … [Read More...]

Essential Practices for Oracle SQL Development in 2021

Are you considering becoming an Oracle SQL developer? This is a great field with many promising opportunities. You can see how much job security you … [Read More...]

[footer_backtotop]

Copyright © 2025 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors