General :: How Does Cp Command Determine Source And Destination Locations In Command?
Apr 14, 2011
When you run the following cp command in the BASH terminal, how does Linux know which files are the source and which are the destination when copying multiple files from one location to another?How does Linux know that the services, motd, fstab, and hosts files are the source and the /home/fred/my_dir is the destination?This question came up in a Linux class and I was not sure of the answer. I was thinking it is based on the source path entered ending with a file path and the destination being a directory, but was not sure.
I am trying to run the same command(s) on the many destination servers from my source server.source server user "report" ssh keys are added to all destination hosts.
To make a full backup I run a live Knoppix DVD and clone the computer's HDD to an external HDD using the dd command. Is there a possible problem with the source being copied onto bad sectors on the destination disk? If so is there a way to prevent this from happening? A typical dd command I use looks like: dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror. Is this the recommended command for cloning to a disk of equal size?
Suppose I have a tree structure like this: /home/mahmood/sim/a/b/file1.cpp /home/mahmood/sim/a/b/file2.h /home/mahmood/sim/a/c/file3.txt /home/mahmood/sim/d/file4.txt
How can I copy all of them to /home/mahmood/sim. So that when I run "ls" in /home/mahmood/sim, I see all files: file1.cpp file2.h file3.txt file4.txt
Can 'cp' search for all file and copy them in another folder?
Firstly I would like to say that Linux is very cool, especially the CLI. I have been trying to learn how to do some things in Fedora after being told Fedora was a good distro to get my feet wet. I have run into some issues and cant seem to find any answers. What Linux utility can be configured to automatically save the current logs?
How does your Fedora get an IP number? What IP numbers has your Fedora been assigned since it was installed (based on the logs you have)? What command did you run to determine the IP numbers? What command would you run to determine the number of times a user successfully used "su"? What command would you run to determine the number of times a user unsuccessfully used "su"? Having some issues with the file system as your Fedora boots up.
Let's say I have a bash script called log.sh. In this script, I want to read in input from a pipe, but I also want to know the command used to pipe input into me. Example:
tail -f /var/log/httpd/error | log.sh
In the shell script, I want to know the command tail -f /var/log/httpd/error.
In Linux, I'd like to know how to find the file(s) if any which as using a particular sector on the hard drive (ext2/3). There is a similar question here regarding Windows, however I need a Linux command line solution (this is a headless system).
My laptop has a dead battery. Even when it's fully charged, if the power cable is pulled out it only lasts for about 4 minutes before it dies. I'm running Ubuntu Lucid Lynx 32-Bit. What I want to do is create some sort of script or program that will immediately set my computer to go into hibernation once it detects that the power cable has gone dead. I'm willing to look into all ways of doing this. I can program in C, but I'm not familiar with the API used to manage Power Management in Linux.
I have written a set of aliases in a file.When i tried to dot it( "Prompt> . filename" ). It said " Permission denied. "But, when I sourced it ("Prompt> source filename"). It worked perfectly.Linux manual has one entry for both the commands. Then what am I missing ?
I know there's a which command, that echoes the full name of a binary (e.g. which sh). However, I'm fairly sure there's a command that echoes the package that provides a particular binary. Is there such a command? If so, what is it? I'd like to be able to run this:
I had written a source code of C++ and complied it with the same name using the following command line.For example: c++ source-code.cpp -o source-code.cpp.Now my source code has been replaced by the executable program.Is there any way to retrieve my source-code.
Can any body tell me where can i found the source code for echo command. so that i can download it such that it can help me for further studies on echo command
I'm trying to get the source code of a web page from linux command line and save it to a file. I googled for it but didn't get any info. I'm not sure if wget can do this.
The man page seems to indicate no. There is /etc/rc.d/init.d/halt on Fedora. It has a hard coded pause in it, but there's got to be a better way than to change that script.
why do we have to define both Source/Destination AND Direction when building firewall.Isn't direction= source->destination? what would happen if source and destination were swapped?
I have a headless server set up with no GUI on board.I know there is some way to display the installed hardware , I just can't remember how.What I'm looking for in particular is determine the type and speed of the PCI-e slots.
Is there a command to know " From where a specific RPM package was downloaded & installed ( The full HTTP/FTP path ) " ? For example, if I had previously installed Firefox from here [URL] is there a specific rpm query, or any other place, from where I can get the full ftp path back.
Before, the "sudo cp -r" command automatically set the permissions to make the directory / files can be accessed by others.
But, after I reinstall Ubuntu 9.10 and apply all the latest updates, "sudo cp -r" command set the files to be accessible by root only.
After I copy the codecs directory to /usr/lib by using the above command, not only I cannot view the files inside, SMPlayer and other player software cannot access the directory.
To fix this, I have to run the chmod command to change the permissions.
Does anyone face this problem? Was it caused by the installation of latest updates?
I know my way around MS Windows much better, but I just don't feel right trying to program something for Android on a Microsoft operating system. I am interested in Android programming so I followed the instructions on [URL] to install the environment on my computer...
I just installed the JDK, SDK, Eclipse successfully (or I assume):
* When I get to Step 4 where I'm supposed to run 'android' it will not run. I get the error message "android: command not found" (I am definitely in the right directory).
** When I double-click it in nautilus, it opens up in gedit. I can set the permissions in nautilus (through the properties - Allow executing file as a program) and get it to work,
I am using openSUSE 10.3.When I install software from tarball then to record time required I send output of date to beg.txt(when installation begins) and end.txt (when installation finishes).How can I append output of date to a file so I don't need two files?
I want to be able to use Ctrl+R to have reverse-i search. Also if I press Shift+Up Arrow after typing the first few characters of a recently executed command then the shell should complete the command by finding the most recent commmand having the same first few characters.