Lesson 7 - Chapter 3: Working with Files Flashcards
What is a wildcard?
A way to search for specific types of files
A wildcard consists of 1 of 2 special characters which are:
- Asterisk *
- Question Mark ?
How do you use a wildcard? What does it replace?
You use a wildcard in place of all or part of a filename (so that it can target more than one file at a time)
What types of commands does a wildcard work with?
virtually every command that deals with multiple files or directories will take wildcards (like dir on Windows)
A good way to think about the wildcard is to replace the part of the filename that you don’t….?
replace the part of the filename that you don’t care about with an asterisk (*.txt)
What’s an example of using a wildcard using the dir command to see all files with the .txt extension?
dir *.txt
What’s an example of using a wildcard when using dir command to see every file that starts with the letter k?
dir k.
(dir k star-dot-star)
(remember, replacing the parts we don’t care about with the asterisk so don’t care about the rest of the filename, don’t care about the extension)
What’s an example of using a wildcard in Linux to find all files that start with o?
ls o* -l
What 2 commands can you use to delete files in Windows?
- del
- erase
What command do you use to delete files in Linux/macOS?
rm
(same as deleting directories with contents)
Files and directories deleted via the command line go to the recycling bin. T or F?
False, once they’re gone they’re GONE.
(Might be able to recover with a recovery utility called Piriform’s Recuva but don’t count on it)
How do you delete multiple files?
use wildcards
Linux example: rm *.txt
In Windows, how do you delete files named config with any extension?
del config.*
How do you delete all the files in a directory in Windows?
del .
(the star dot star wildcard)
What command do you use in Windows to delete a single file?
del
What command do you use in Linux/macOS to delete a file?
rm
NEVER fall for this Linux syntax prank:
sudo rm -rf /
it deletes every file and directory on the hard drive, -f switch forces the system to obey the command and / is the root of the drive
In Linux and macOS, what commands move and copy files? (2)
- cp
- mv
What commands do you use in Windows to copy and move files?
- copy
- move
What workaround options do you have regarding working with files/directories with multiple words and spaces in between? (2)
- Use File Explorer or another GUI file manager
- Refer to the file by its short 8-3 name
What is a file’s short 8-3 name?
It’s the first 6 letters of the file’s name followed by a tilde ~ and then a number
How does a file’s short 8-3 name work?
If it’s the only file in that location with those first 6 letters, the number at the end is a 1. If multiple files have the same letters, it goes by sequential numbers (2, 3, 4, etc)
Each long file name also has a ___-___ alias
short-name
How do you see the aliases for all the files in a location? Command and switch
dir /X
(names that are already 8-3 compatible don’t have alternate short names)
How do you rename a folder in Windows? What command?
ren
ren oldname newname
How do you rename a folder in Linux/macOS, what command?
mv oldname newname
How do you rename directories?
Same process as renaming the files, just doesn’t have file extensions
What’s something to watch out for when you’re trying to move a file in Linux/macOS with the mv command?
If you try to move the file to a location that doesn’t exist, Linux might silently rename the file to that location name instead
Typed: mv Newfile.odt Screenplays
Instead of: mv Newfile.odt ~/Screenplays
What is the process called when you copy or move a directory (complete with its sub-directories and files) as a whole pile with one command?
pruning and grafting
What Windows command do you use to copy multiple sub-directories with one command?
xcopy
(needs a switch like /s or /e among many others)
What is the robocopy command short for?
Robust File Copy
What is robocopy on Windows used for? (3)
c, r, d
- copies files/directories between computers on a network
- replicates the structure on the destination system
- deletes anything on that destination system that wasn’t part of the copy
What does the basic syntax for robocopy look like?
robocopy [source] [destination] [options]
What command do you use to copy all files and sub-directories from a local machine to a shared directory on a remote server?
robocopy
What does the /mir switch do for the robocopy command?
it tells robocopy to copy everything from the source and make the destination mirror it (which will also delete anything in the destination that doesn’t match the source directories/files)
Besides copying files and directories from one computer to another across a network, what else can robocopy do? (2)
it enables, resumes
- It enables an administrator to copy encrypted files (even if admin is denied access to the files)
- resume copying after an interruption at the spot it stopped
Unlike Windows, in Linux/macOS you can move and copy directories and contents with the same cp and mv commands you’d use for a single file. T or F?
True
To copy directories and its contents on Linux/macOS, what special switch do you use and with what command? (2)
cp -R
(recursive which means all its contents)
To move directories and its contents on Linux/macOS, what command do you use and what switch?
mv
it doesn’t need a switch!
Delete all the files in the Personal directory at a Linux CLI?
rm ~/Personal/.
star-dot-star
Delete all the files in the Personal directory at a Windows CLI
del C:\Personal*.*
Delete the Personal directory in Windows without first removing all its files
rd Personal /s
(or rmdir)
Delete the Personal directory in Linux without first removing all its files
rm Personal -r
(he says /r but that doesn’t work for me only -r)
Delete the Personal directory in Windows (only after having first removed all its files)
rd Personal