-
sudo -s- Starts a shell with the target user’s privileges (root by default) but keeps your current environment variables.
- Uses your current shell (
$SHELL) instead of the target user’s login shell. - Good when you only need elevated permissions without changing the overall environment context.
-
sudo -i- Simulates a full root login: runs the target user’s login shell (passwd), reads that user’s profile files (profile,
~/.profile, etc.), and sets up their environment. - Essentially gives you a fresh login session as root, including home directory changes.
- Simulates a full root login: runs the target user’s login shell (passwd), reads that user’s profile files (profile,
-
Ideal when you need the complete root environment (e.g., for system-level configuration that depends on root’s PATH or dotfiles).
from pathlib import Path
# Get the current working directory as a Path object
current_dir = Path.cwd()
# Use the '/' operator (overloaded in Path class)
# to construct the path to 'mkdocs.yml'
mkdocs_yml = current_dir / 'mkdocs.yml'