Linux & shell: Create, copy, move, delete
13 Linux & shell commands: Create, copy, move, delete. Click a command to see what each part does.
Linux & shell: Create, copy, move, deleteIndex
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
Create, copy, move, delete13
mkdir -p <path/to/dir>Create a folder (and parents) in one goWhat each part does
mkdirmake directory-pcreate missing parent folders too; no error if it already exists
touch <file>Create an empty file / update its timestampWhat each part does
touchcreate the file if missing; if it exists, set its modified time to now
cp <src> <dest>Copy a fileWhat each part does
cpcopy<src>file to copy<dest>new file name, or a folder to copy into
cp -r <src-dir> <dest-dir>Copy a folder with everything in itWhat each part does
-r--recursive: copy directories and their contents
cp -a <src> <dest>Copy keeping permissions, owner and times (backups)What each part does
-a--archive: recursive + keep symlinks, permissions, ownership and timestamps
cp -i <src> <dest>Copy but ask before overwritingWhat each part does
-i--interactive: prompt before overwriting an existing file
mv <old-name> <new-name>Rename a file or folderWhat each part does
mvmove: within the same folder this is a rename
mv <file1> <file2> <dir>/Move files into a folderWhat each part does
<file1> <file2>one or more sources<dir>/destination folder (the trailing / makes it clear it is a folder)
Tip Add -i to be asked before overwriting, -n to never overwrite.
rm <file>Delete a fileCautionWhat each part does
rmremove (no recycle bin: it is gone)
rm -i <files>Delete, but confirm each fileCautionWhat each part does
-iprompt before every removal
rm -rf <dir>Delete a folder and everything in itDestructiveWhat each part does
-r--recursive: remove directories and their contents-f--force: never prompt, ignore files that don't exist<dir>double-check this path: there is no undo
Tip Run ls <dir> first. Never run it with a variable that might be empty (rm -rf "$DIR/").
rmdir <dir>Delete an empty folderWhat each part does
rmdirremove a directory only if it is empty (safe)
ln -s <target> <link-name>Create a symbolic link (shortcut)What each part does
lnmake links-s--symbolic: a symlink pointing to <target> (without -s it makes a hard link)<target>the real file or folder<link-name>the shortcut to create
Nothing matches.
My DevOps Playbook by Angelo John Calleja