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

Advances in Big Data Drive Demand for SQL and Data Programmers

The online programming industry is lucrative and growing rapidly. In the United States, programmers ear over $100,000 a year. Qualified experts are so scarce around the world that it has become the star topic at executive and recruiter meetings. The data scientist is one of today's most … [Read More...]

Digital Video Television Sound

The standard sound format for European digital television comes in the form of MPEG-2 Stereo. This system can carry two channels of CD quality digital audio. The quality of audio this delivers is little different to that possible using the NICAM Stereo Audio system for digital stereo sound with used … [Read More...]

How to Use Print Screen in Windows

There are times where you would like to show something on your screen to someone. I use this all the time in my tutorials and you may be wondering how I do it. One of the easiest ways to accomplish this is using the Print Screen feature in Windows 7. This short article will show you how you can save … [Read More...]

AI-Driven Software Improves Trading Strategies for Investors

Artificial intelligence technology is changing the state of modern finance. A growing number of investors are utilizing AI to improve the … [Read More...]

What You Need to Know When Choosing the Best VPN for an iPhones

Today millions of people have smartphones; most use them to access the Internet. Research shows that more than 50% of Internet users access it with … [Read More...]

Must-Have Software and Apps Every Remote Worker Should Have on Their PC in 2023?

In the last few years, the future of work has changed permanently. In a survey conducted near the end of 2020, 72% of people were fully remote, with … [Read More...]

Cloud Technology Changes the Calculus of Risk Management in a Global Economy

Cloud technology has changed the state of the global economy in previously unimaginable ways. Ninety-four percent of enterprises utilize some form of … [Read More...]

Risk Management Considerations in an Artificial Intelligence Environment

Risk management is about identifying, assessing, evaluating, and prioritizing risk. Although risk management has been practiced in some ways since … [Read More...]

New Software and GPS Tools Help Parents Monitor their Children

More parents are using technology to keep their children safe. One survey from Pew Research in 2016 showed that 30% of parents use technology to block … [Read More...]

Guides

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

Recent Posts

Take the Step for iPad Mini with Retina Display

Can you imagine holding a super portable, mini size and one hand iPad mini with 7.9 Retina Display? The retina display of this device has more than … [Read More...]

LP to CD Equipment

The following equipment will be needed to produce a signal capable of being digitised in your PC: a turntable and pickup arm fitted with a good … [Read More...]

CIS Scanners

CIS is a relatively new sensor technology which began to appear at the budget end of the flatbed scanner market in the … [Read More...]

[footer_backtotop]

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