DevOps
Linux
File Ops & Navigation

File Ops & Navigation

Mastering file operations and directory navigation is the first step toward effective Linux system administration.

Advanced ls (List)

Beyond a simple ls, flags allow you to see hidden files, permissions, and sort orders.

  • ls -l: Long format, showing permissions, owner, size, and date.
  • ls -a: Show all files, including hidden ones (starting with .).
  • ls -ltr: List files sorted by modification time in reverse order (newest at the bottom).
# Example long listing
drwxr-xr-x 2 user user 4096 Oct 12 10:00 docs
-rw-r--r-- 1 user user  128 Oct 12 10:05 README.md

Direct Navigation

  • cd -: Switch back to the previous directory you were in.
  • cd ~: Go straight to your home directory.
  • mkdir -p: Create a directory and its parents if they don't exist (e.g., mkdir -p project/src/utils).

Aliases & History

Command History

The history command displays a numbered list of all previously executed commands.

  • Use !n to re-run the n-th command from history.
  • Use history | grep "docker" to find a specific past command.

Aliases

Aliases allow you to create custom shortcuts for long or frequent commands.

# Set an alias
alias ll='ls -la'
 
# Now just type 'll' to run 'ls -la'

[!TIP] Persistence To make aliases permanent, add them to your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc).