Core Linux Terminal Utilities and Usage Patterns
Tech
1
Directory Navigation and File System Enspection
ls: Enumerates contents within a target folder.pwd: Outputs the absolute path of the current shell environment.cd <path>: Transitions the shell to a specified directory.cd ..: Moves up one level in the hierarchy.cd -: Reverts to the previously active directory.tree: Generates an ASCII-based hierarchical visualization of folders and files.
File Manipulation and Search
cat <file>: Streams raw text data to standard output.rm <target>: Permanently deletes specified items.mv <src> <dest>: Transfers files or applies a new name if the destination shares the same parent.cp <src> <dest>: Creates a duplicate at the specified location.locate <query>: Executes rapid filename searches via a pre-indexed database.
Text Processing and Editors
vim <target>: Launches a modal text editor.- Enter insertion state:
i - Return to normal state:
Esc - Trigger command mode:
: - Commmit and exit:
:wq - Abort and exit:
:q!
- Enter insertion state:
head -n <count> <file>: Extracts the leading lines of a document.tail -n <count> <file>: Extracts trailing lines. Append-fto continuous log monitoring.more <file>: Paginates terminal output. Use+<n>to start at a specific line, or-<n>to restrict the viewport height.
Resource Monitoring and Metrics
top: Renders a real-time, interactive table of running processes and hardware utilization.du -sh <path>: Calculates storage consumption (-s) using scalable units like KB, MB, or GB (-h).wc: Tallies lines (-l), words (-w), or characters (-c).- Optimized regular file counter:
Logic:ls -la | grep -c "^-"ls -laproduces a verbose directory listing.grep -c "^-"directly matches and counts lines beginning with a dash, which denotes standard files.
I/O Redirection and Shell Customization
- Output routing:
cmd > file.txt: Overwrites the target with fresh output.cmd >> file.txt: Preserves existing data and appends to the end.
- Persistent shortcuts:
alias ll='ls -lh --color=auto' - Inline terminal execution from Vim:
Prepend
:!to any shell instruction (e.g.,:!whoami) to run it without closing the editor. - Temporal calculations:
target_date=$(date -d "72 hours ago" +"%Y-%m-%d") echo "Resolved value: $target_date" - Locale verification and override:
locale export LC_ALL="en_US.UTF-8"