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

Essential Steps to Restore Lost Macbook Files

MacBooks are gaining tremendous popularity. They might soon overtake the total computers produced by the largest PC manufacturer. Apple reportedly sold 5.3 million MacBooks in the fourth quarter of 2018 alone. As more people invest in MacBooks, we are starting to become more aware of the … [Read More...]

Travan Tape Storage

While the build quality of QIC/Travan cartridges is superb - making them ideal for long-term storage - for a long time they are more expensive than DAT media. This was especially so for the 8GB/Travan-4 cartridges, which have built-in tape … [Read More...]

How to publicise your website

Sometimes, a website can explode from nowhere with absolutely no publicity, but it will catch a mood and suddenly be pulling millions of visitors. The story of Mahir and the I Kiss You phenomenon is possibly the best-known example of this. However, there are billions of pages out there, millions of … [Read More...]

Tips on How to Land a Remote Job in Cyber Security

The demand for skilled cyber security professionals is growing as well as a number of threats and risks. Any company needs an expert or team to … [Read More...]

Video Tutorials for Anyone Wanting to Learn About Big Data

Did you know that we create about 2.5 quintillion bytes of data every single day? There is no denying the fact that big data is changing our world in … [Read More...]

Video Tutorials to Help Canva Users Shorten their Learning Curve

Canva is a very popular design software that is used by over 55 million designers. It is a robust application, but it can be tricky for beginners to … [Read More...]

Great Videos to Learn About Cricut Design Space

Cricut Design Space is one of the best digital design applications for people trying to create projects for Cricut projects. You can create a lot of … [Read More...]

Great Videos on Dangerous Computer Viruses

Computer viruses are obnoxious programs that can wreak havoc on even the most sophisticated machines. The good news is that people will be better … [Read More...]

Best Creative Commons Videos on Learning Adobe Illustrator

Adobe Illustrator is one of the most popular design tools available. The tool has been around since 1987 and is used by over 90% of the world's … [Read More...]

Guides

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

Recent Posts

Digital Video Editing

Broadly speaking, there are two types of video editing. One involves editing directly from one tape to another and is called linear editing. The other … [Read More...]

Get Ready for the $50 Tablet from Amazon

Who ever thought we would see the days of a sub $50 tablet, and an Amazon device at that. Well, it is coming. It will now be possible to obtain a … [Read More...]

RIMMs Memory

With the introduction of Direct RDRAM (DRDRAM) in 1999 came the RIMM module (the name is not an … [Read More...]

[footer_backtotop]

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