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

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: Moving from Shared to Dedicated Web Hosting

Latest Articles

SCSI Explained – With Pictures

SCSI Explained – With Pictures

As with most specifications in the computer world, the original SCSI (pronounced scuzzy) specification was completed (in 1986) after work had already begun on a better version (SCSI-2). It was developed as a result of attempts by Shugart and NCR … [Read More...]

AMD Athlon 64

AMD Athlon 64

Of the pair of desktop CPUs announced in the autumn of 2003, the Athlon 64 was aimed at the mass market while the top-of-the range, limited-availability Athlon 64 FX-51 model was specifically targeted at gamers and … [Read More...]

PCI Audio Sound Cards

PCI audio chips started to emerge during 1996 and are either integrated on the motherboard or on a card in a PCI expansion slot. By mid-1998 a trend towards PCI cards providing enhanced features for both gaming and music applications had … [Read More...]


4 Very Useful CAD Hacks You Might Not Be Using

The market for CAD design is growing around 7% a year. It is expected to be worth $7.3 billion by 2022. CAD experts have a lot of job security, … [Read More...]

What Are the Best eSports Games to Watch in 2020?

The esports industry is growing at a remarkable rate.  According to Statistica, the global market for esports is expected to reach $1.79 billion … [Read More...]

Choosing the Safest Crypto Wallet for the New Year

 There are a number of excellent benefits of cryptocurrencies.  They are extremely convenient and offer a tremendous amount of privacy. … [Read More...]

Guidelines on Troubleshooting Python Code

Whenever we write a computer program we need to verify that it works as expected. Usually we execute the code, if necessary we provide some inputs, … [Read More...]

Developing a Python to Extract Data from Your Smartphone

Many times we ask ourselves: "What part of the universe is this phone from?", even if we already know where it is, but we don't know which operator. … [Read More...]

Most Demanding Heroes to Play in Dota 2

Dota 2 is one of the most popular multi-player online combat games. It had an average player count of 485,000 throughout most of 2018. The peak number … [Read More...]

Guides

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

Recent Posts

DynaSheet

Imagine a newspaper that sits neatly in your pocket, is environmentally friendly and gets updated every day. That's the dream that Toshiba … [Read More...]

Windows Antivirus Adviser

Windows Antivirus Adviser is a fake antivirus program.  This kind of virus is very common on the internet and they have been around for years under … [Read More...]

Peer to Peer Network Architecture

In a Peer-to-peer networking architecture each computer (workstation) has equivalent capabilities and responsibilities. … [Read More...]

Return to top of page

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