Where to start First steps track · 15 stages
Linux Labs

Files and directories

16 articles, grouped by kind; the order follows the tracks.

Concepts 1

  • Symbolic and hard links

    The difference between a symlink and a hard link, when to use which, broken links.

    ln -sln -sfnreadlink -f

    4 min

Commands 15

  • Basic file commands

    Navigation and files — ls, cd, cp, mv, rm, cat, less, head, tail, terminal copy-paste.

    ls -lahcd dirpwd

    8 min
  • ls — list directory contents

    The ls command lists files and directories with permissions, owner, size and modification time, hidden ones too.

    lsls -lls -la

    6 min
  • mkdir — creating directories

    Creating directories: -p (with parents), -m (permissions right away), brace expansion, rmdir.

    mkdir -pmkdir -mrmdir empty

    3 min
  • stat — file metadata

    Full file information — size, permissions, owner, timestamps (atime/mtime/ctime), inode.

    stat filestat -cls -lc

    4 min
  • file — determining file type

    Figuring out what's inside a file (text, ELF, archive, image) by content, not by extension.

    file ffile -ifile -b

    3 min
  • cp — copy files and directories

    The cp command copies files and directories, with overwrite prompts, preserved permissions and times, recursively.

    cpcp -rcp -a

    5 min
  • mv — move or rename

    The mv command renames a file or directory and moves it elsewhere; it silently replaces an existing target.

    mvmv projectmv -i

    5 min
  • rm — remove files and directories

    The rm command deletes files and directories at once, with no trash; -i and -I ask first, -r removes a tree.

    rmrm -irm -I

    6 min
  • ln — symbolic and hard links

    Symlinks (ln -s) and hard links: how they differ, when to use which, common mistakes with relative paths.

    ln -sln -sfreadlink -f

    4 min
  • Paths — basename, dirname, realpath

    Splitting a path into a name and a directory, getting an absolute path; a script's own directory.

    basenamedirnamerealpath

    3 min
  • find — searching for files

    Finding files by name, size, time, permissions; acting on what's found.

    find

    4 min
  • tar — archiving and extracting files

    Packs files into a compressed archive; an archive with no top directory dumps its files into the current directory.

    tar czftar xzftar tvzf

    4 min
  • rsync — file synchronization and copying

    Copies only the differences between trees; --delete mirrors the source into the destination, removing anything extra.

    rsync -avzPrsync -avznrsync -avz

    4 min
  • restic — deduplicated backups

    Incremental encrypted backups with snapshots; without the password the repository cannot be decrypted at all.

    restic initrestic backuprestic snapshots

    4 min
  • git: change history, undo and a remote repository

    A version control system: who changed what in the files, how to get back a working version and exchange changes.

    git statusgit diffgit add

    15 min

Nothing found. Try a shorter query.

Loading…