File commands
pwd, cd, ls, tree, mkdir, rmdir, touch, cp, mv, rm and find with their common options: what each one does, what it refuses and what it destroys.
- 30 cards
- 5 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
- Understand
A few cards from the deck
ls -la: what is it?Show the answer
Lists a directory's content in detail (type, permissions, owner, size, date), hidden files included.
-lgives the long format,-aadds the files whose name starts with a dot, such as.bashrc, which a plainlsdoes not show.The directory
archivedoes not exist. What doesmv rapport.txt archivedo?- It renames
rapport.txttoarchive - It creates the
archivedirectory and moves the file into it - It fails, because the destination
archivedoes not exist - It copies the file under the name
archiveand keeps the original
Show the answer
It renames
rapport.txttoarchiveWhen the destination is not an existing directory,
mvtakes it as a new name. It is a classic way to lose files: the file is now a file calledarchive.- It renames
pwdprints the … directory;cdwith no argument goes back to the … directory, andcd -to the … one.Show the answer
pwdprints the current directory;cdwith no argument goes back to the home directory, andcd -to the previous one.cd -switches back and forth between two directories: handy to hop without retyping paths.mkdir -p a/b/c: what is it?Show the answer
Creates
a,a/banda/b/cin one go, and reports no error if one of them already exists.Without
-p,mkdir a/b/cfails (“No such file or directory”) ifa/bdoes not exist, andmkdir afails ifaalready exists.cp src sauvegardeanswers “cp: -r not specified; omitting directory 'src'” and copies nothing. Which fix?- Add root's rights:
sudo cp src sauvegarde - Add recursion:
cp -r src sauvegarde - Force the copy:
cp -f src sauvegarde - Preserve permissions:
cp -p src sauvegarde
Show the answer
Add recursion:
cp -r src sauvegardeThe message says it:
srcis a directory andcponly goes into a directory with-r.sudo,-fand-pdo not change this refusal.- Add root's rights: