Buntch of commands Flashcards
(14 cards)
Q: What does the mkdir command do, and what type of arguments does it take?
A: Creates directories using absolute or relative pathnames.
Q: What does the mv command do, and what arguments does it require?
A: Moves or renames files and directories; requires at least a source and a destination.
Example:
mv /etc/sample1 /root
Q: How do you move multiple files to a directory using the mv command?
A: List all source files, then the target directory as the last argument.
Example:
mv /etc/sample1 /etc/sample2 /root
Q: Can mv use wildcards to move multiple files?
A: Yes, wildcards can be used to match multiple source files.
Example:
mv /etc/sample* /root
Q: What does mv do if the target is a directory?
A: Moves the source file(s) into the target directory.
Q: What does mv do if the target is an existing filename and one source file is specified?
A: Overwrites the target file with the source file.
Q: What does mv do if the target is a nonexistent filename in a directory?
A: Creates a new file with that name and moves the source file to it.
Q: How is the mv command used to rename a file?
A: By moving the file to the same directory with a different filename.
Q: Can the mv command be used to rename directories?
A: Yes, mv renames a directory by moving it to a new directory name.
Q: What command should you use if you want to copy a file or directory without deleting the source?
A: The cp (copy) command.
Q: What arguments does the cp command require?
A: At least two: the source file/directory and the target file/directory.
Q: How do you copy multiple files to a directory using cp?
A: List all source files as arguments followed by the target directory as the last argument.
Q: What is the difference between mv and cp when working with directories?
A: mv renames or moves a directory; cp creates a new copy of the directory and its contents.
Q: How do you copy a directory and all its contents in Linux using cp?
A: Use the -r (recursive) option with cp to copy directories and their subdirectories.