I want to copy a directory from one place to another via the command line



I want to copy a directory from one place to another folder.

sudo cp is the command, but after that what should I type? The destination or source first?


The -a flag is probably what you are looking for:

cp -a /path/from /path/to

The -a flag turns on recursive behaviour (which can also be done with the -R flag), and will also attempt to preserve metadata such as file ownership, permissions, timestamps, links, etc.

You should only need to use sudo if you are copying to a location not owned by the current user, if the current user doesn't have read permissions for the files being copied, or if you want to preserve ownership on files not owned by the current user.


If you want to copy directory please use below command:

sudo cp -R Source_Folder Destination_Folder

This command can also be used to copy files, by just removing the "-R" which is used...

0 0

ow do I copy files under Linux operating systems? How do I make 2nd copy of a file on a Linux bash shell? How can I copies files and directories on a Linux?

To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name.

cp Command Syntax

The syntax is as follows to copy files and directories using the cp command:



In the first and second syntax you copy SOURCE file to DEST file or DIRECTORY.In the third syntax you copy multiple SOURCE(s) (files) to DIRECTORY.

Note: You need to type the cp command at the dollar sign...

0 0

I use rename all the time. It is pretty simple, but hopefully you know basic regex:

rename "s/SEARCH/REPLACE/g" *

This will replace the string SEARCH with REPLACE in every file (that is, *). The /g means global, so if you had a SEARCH SEARCH.jpg, it would be renamed REPLACE REPLACE.jpg. If you didn't have /g, it would have only done substitution once, and thus now named REPLACE SEARCH.jpg. If you want case-insensitive, add /i (that would be, /gi or /ig at the end).

With regular expressions, you can do lots more.

Note that this rename is the prename (aka Perl rename) command, which supports complete Perl regular expressions. There is another rename which uses patterns, and is not as powerful. prename is installed by default on Ubuntu (along with Perl).

Here are a few examples:



rename 's/^/MyPrefix_/' * document.pdf renamed to MyPrefix_document.pdf


Also you can remove unwanted strings. Let's...

0 0

Below are the steps required to copy computer documents, pictures, or other files from one source to another. Click on one of the links below to scroll down automatically to the operating system you need help with or scroll down to review them all.

Note: When copying files, you are going to get more than one copy of the file on your computer. If you want only one copy of the files, you should move the files.

How to copy a file in Microsoft Windows

Below are the simple steps on how to copy a file or multiple files in Microsoft Windows from one location to another.

Go to the files or folders you want to copy. If you need help locating the files use the Windows find feature. Highlight the file or files you want to copy by clicking them once with the mouse. If you need to highlight more than one file, you can hold down the Ctrl or Shift keys on your keyboard or drag a box around the files you want to copy. Once highlighted, right-click one of the highlighted...
0 0

After you’re comfortable with moving around the hierarchy of your hard drive in UNIX, it’s a cinch to copy, move, and rename files and folders. To copy files from the command line, use the cp command. Because using the cp command will copy a file from one place to another, it requires two operands: first the source and then the destination.

For instance, to copy a file from your Home folder to your Documents folder, use the cp command like this:

cp ~/MyDocument ~/Desktop/MyDocument

Keep in mind that when you copy files, you must have proper permissions to do so!

If you can’t copy to the destination that you desire, you need to precede the cp command with sudo. Using the sudo command allows you to perform functions as another user. The idea here is that the other user whom you’re “emulating” has the necessary privileges to execute the desired copy operation.

When you execute the command, the command line asks you for a password. If you don’t know what the...

0 0
Some instructions.
1. This question has been tagged into Linux but you can ask for Mac/Windows in comments.
2. The answer has been divided into two part.
3. Since question detail deviates from the general idea of question, so the readers who are interested in the Question heading can read first Part I & the one sent me A2A can skip to Part II.

Part I: Actual Question—How can I transfer files from one private network to another via Terminal?

There're several ways to achieve it but first you have to set up connections between the two different networks and configure it. There're many GUIs & CLIs protocols by which you can do it but since this question relates only to copy via terminal command line, I will list out some network protocols & commands by which you can achieve it.
(Assuming both the private networks are connected via Internet or any other TCP physical/wireless connection)
Suppose your IP is: 172.16.32.X
And You want to copy files to a...

0 0

As an operating system, Linux is extremely popular with hard core technical enthusiasts. Those who work on it, swear by it. It is robust, safe, and scalable. However, there are folks who’ve gotten used to a Windows UI who tend to shy away from it. In this tutorial, you’ll get to see how simple and powerful Linux can be – if you just learn a few basic commands and practice them. We will walk you through one such command today – copying directories

Linux – an introduction

Linux is free operating system. By free, what we mean is that the source code of Linux comes free. This means that the code of the operating system is available to all and you can modify and add to it according to your need. Thus, since its inception Linux has gone through many changes and there is a strong and growing community of Linux programmers who keep on adding to its functionalities. If you do not have prior experience with Linux, we highly recommend you first try out this Linux crash course...

0 0

I have this problem as part of a school assignment:

NOTE: In case it's hard to read in the image above, here's the directory tree:

$ tree . `-- sample_dir1 `-- sample_dir |-- admin |-- cambridge | |-- cafeteria | |-- library | `-- security | |-- annex | |-- building | `-- parking |-- faculty |-- history.exe |-- markham | |-- annex | |-- building1 | `-- parking |-- oxford | |-- outline.doc | |-- programming | | `-- report.pdf | `-- security `-- stenton |-- gen_ed `-- lib_arts |-- english.txt `-- match.doc 15 directories, 11 files

I tried doing the command:

$ cp ../cambridge/security/parking ./parking2

...but it isn't working. The question in the image above states that the current directory is stenton, and that we need to make a copy of the file named parking (from the security directory), and to name the new file parking2,...

0 0

I am assuming that these are not pgm files, right ?
The easiest method, inmo, would be to just run the windows – XCOPY cammand via the run dos command action with the following switches, as needed. Refer to windows help for full xcopy syntax.

Copies source files changed on or after the specified date only. If you do not include a mm-dd-yyyy value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.

Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.
Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line...

0 0


A branch is a named pointer to a commit. Selecting a branch in Git terminology is called to checkout a branch. If you are working in a certain branch, the creation of a new commit advances this pointer to the newly created commit.

Each commit knows their parents (predecessors). Successors are retrieved by traversing the commit graph starting from branches or other refs, symbolic references (for example: HEAD) or explicit commit objects. This way a branch defines its own line of descendants in the overall version graph formed by all commits in the repository.

You can create a new branch from an existing one and change the code independently from other branches. One of the branches is the default (typically named _master ). The default branch is the one for which a local branch is automatically created when cloning the repository.


When you commit your changes into a repository this creates a new commit object in the Git repository....

0 0

These are the questions related to the currently supported versions. For older questions, see below.

General questions: ¶

What is Subversion? Why does it exist? ¶

Subversion is an open-source, centralized version control system. See Our Vision on our front page to know why Subversion exists. Want to take a quick look? See Quick Start.

Is Subversion proprietary software? ¶

No, Subversion is open source / free software. Several companies (CollabNet, WANdisco, VisualSVN, elego, ...) pay or have payed the salaries of some full-time developers, but the software carries an Apache License which is fully compliant with the Debian Free Software Guidelines. In other words, you are free to download, modify, and redistribute Subversion as you please; no permission from any company or any person is required.

How stable is Subversion? ¶

Subversion is very stable. It is mature software, with strong compatibility guarantees. The...

0 0


Updated by Tina Sieber on January 21, 2017.

Microsoft has slowly but surely pushed the command line 10 Windows Command Line Tips You Should Check Out aside in the Windows interface. This is not without reason. It’s an antiquated and mostly unnecessary tool from an era of text-based input.

But many commands remain useful, and Windows 8 and 10 even added new features. Here we present the 15 commands every Windows user needs to know.

In case you’re not sure how to access the command prompt, forgot basic commands, or would like to know how to see a list of switches for each command, you can refer to our beginners guide to the Windows command line A Beginner's Guide To The Windows Command Line for instructions.

Prefer this tutorial in video form? We’ve got you covered:

Our 15 Favorites


Most files in...

0 0

Allowing Network Access with Blank Passwords (XP and Vista)

Added 2/10/07

Although you can log in locally without a password, by default, WindowsXP Pro does not allow network users to access the computer without a password. Typically you will receive an Unknown error 31 if this is the case.

To change this setting:

Run gpedit.msc Go to Computer Configuration / Windows Settings / Security Settings / Local Policies / Security Options Double click on Accounts: Limit local account use of blank passwords to console login only Disable this option

Disabling the F3 Search Key

Added 1/20/03

If you want to disable the ability to use the F3 key from either the Windows Explorer or Internet Explorer

Start Regedit Go to HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions Create a Dword value called NoFindFiles Give it a value of 1 Reboot

Preventing Changes to File Associations


0 0

While automation exists to make it easier to make things repeatable, all of your systems are likely not exactly alike.

On some systems you may want to set some behavior or configuration that is slightly different from others.

Also, some of the observed behavior or state of remote systems might need to influence how you configure those systems. (Such as you might need to find out the IP address of a system and even use it as a configuration value on another system).

You might have some templates for configuration files that are mostly the same, but slightly different based on those variables.

Variables in Ansible are how we deal with differences between systems.

To understand variables you’ll also want to dig into Conditionals and Loops. Useful things like the group_by module and the when conditional can also be used with variables, and to help manage differences between systems.

It’s highly recommended that you consult the ansible-examples...

0 0