{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreih6v4ojmy5kn3ohbrdsviwieeco53whyguwdeantn6xj63uqf5ms4",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpareozquuz2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreifrckbkse4z3oxo4w6vkusjykgos4o2pr3rfaqqvafl7ryotdowx4"
},
"mimeType": "image/webp",
"size": 53378
},
"path": "/yunasong/linux-basics-essential-file-system-commands-27dh",
"publishedAt": "2026-06-27T05:02:13.000Z",
"site": "https://dev.to",
"tags": [
"linux"
],
"textContent": "## 1. `cd` — Change Directory\n\nChanges the current working directory.\n\n### Syntax\n\n\n cd <path>\n\n\n### Common Usage\n\n\n cd / # Go to the root directory\n cd ~ # Go to the current user's home directory\n cd .. # Move up one directory\n cd - # Return to the previous directory\n cd ./Documents # Relative path\n cd /var/log # Absolute path\n\n\n### Path Types\n\n * **Absolute path** : Starts with `/` and specifies the full path from the root directory.\n * **Relative path** : Starts from the current directory (e.g. `./`, `../`, or a directory name).\n\n\n\n### Tips\n\n * Press **Tab** for auto-completion.\n * Use quotes for directory names containing spaces.\n\n\n\n\n cd \"My Folder\"\n\n\n## 2. `ls` — List Files and Directories\n\nDisplays the contents of a directory.\n\n### Syntax\n\n\n ls [options] [path]\n\n\n### Common Options\n\n\n ls # List files\n ls -l # Long format\n ls -a # Include hidden files\n ls -la # Long format + hidden files\n ls -lh # Human-readable file sizes\n ls -t # Sort by modification time\n ls -S # Sort by file size\n ls -r # Reverse sort order\n ls -R # Recursive listing\n ls -d */ # Show directories only\n\n\n### Useful Combinations\n\n\n ls -altr # Hidden files, long format, time sort, reverse order\n ls -alF # Append indicators (/, *, etc.)\n ls -lthr # Human-readable, time sort, newest at the bottom\n\n\n## 3. `pwd` — Print Working Directory\n\nDisplays the absolute path of the current directory.\n\n### Syntax\n\n\n pwd\n\n\n### Options\n\n\n pwd -L # Logical path (default)\n pwd -P # Physical path (resolve symbolic links)\n\n\nExample:\n\n\n\n /home/user/workspace\n\n\n## 4. `mkdir` — Make Directory\n\nCreates one or more directories.\n\n### Syntax\n\n\n mkdir [options] <directory>\n\n\n### Common Usage\n\n\n mkdir project\n mkdir dir1 dir2 dir3\n mkdir -p parent/child/grandchild\n mkdir -v new_folder\n mkdir -m 755 secure_folder\n\n\n### Useful Options\n\n * `-p` : Create parent directories if needed.\n * `-v` : Show created directories.\n * `-m` : Set permissions when creating the directory.\n\n\n\n## 5. `rm` — Remove Files and Directories\n\nDeletes files or directories permanently.\n\n> **Warning:** Deleted files cannot be recovered from the Trash.\n\n### Syntax\n\n\n rm [options] <file>\n\n\n### Common Usage\n\n\n rm file.txt\n rm -i file.txt\n rm -r directory\n rm -f file.txt\n rm -rf directory\n\n\n### Multiple Files & Wildcards\n\n\n rm file1.txt file2.txt\n rm *.log\n\n\n### Important Options\n\n * `-i` : Ask for confirmation.\n * `-r` : Remove directories recursively.\n * `-f` : Force deletion without prompts.\n\n\n\n> **Never run**\n>\n>\n> sudo rm -rf /\n>\n>\n> This command can destroy the entire operating system.\n\n## 6. `cp` — Copy Files and Directories\n\nCopies files or directories while keeping the original intact.\n\n### Syntax\n\n\n cp [options] <source> <destination>\n\n\n### Common Usage\n\n\n cp file1.txt file2.txt\n cp -r dir1 dir2\n cp file1.txt file2.txt ~/backup/\n cp -a /etc/config.conf ~/backup/\n\n\n### Useful Options\n\n * `-r` / `-R` : Copy directories recursively.\n * `-a` : Archive mode (preserve attributes, permissions, timestamps, and symbolic links).\n * `-p` : Preserve file metadata.\n * `-i` : Confirm before overwriting.\n * `-f` : Force overwrite.\n\n\n\n## 7. `mv` — Move or Rename Files\n\nMoves files/directories or renames them.\n\n### Syntax\n\n\n mv [options] <source> <destination>\n\n\n### Common Usage\n\n\n mv file1.txt ~/Documents/\n mv file1.txt file2.txt\n mv folder1 ~/backup/\n mv file1.txt file2.txt ~/backup/\n\n\n### Useful Options\n\n * `-i` : Confirm before overwriting.\n * `-f` : Force overwrite.\n * `-n` : Never overwrite existing files.\n * `-v` : Show each move operation.\n\n",
"title": "Linux Basics: Essential File System Commands"
}