Skip to main content

Search for independently written descriptions of common commands, read-only examples, and easily overlooked limitations.

pwd

View the current working directory.

pwd

Outputs the absolute path without changing the file.

ls

View directory contents and hidden files.

ls -lah

The time and size in the list are affected by parameters and system implementation.

cd

Switch the directory where the current terminal is located.

cd /path/to/project

This is a shell built-in command, and quotes are required when the path contains spaces.

head

View only the first few lines of the file.

head -n 20 app.log

It is suitable to look at the sample first, without reading the entire file at once.

tail

Look at the log at the end of the file.

tail -n 100 app.log

Added -f to continue following; press Ctrl+C to exit.

less

Read larger text files in pages.

less app.log

Use / to search and press q to exit without modifying the file.

grep

Filter lines in a file by fixed text.

grep -nF 'ERROR' app.log

-F matches literal text, -n displays line numbers; do not post confidential logs in a public location.

find

Find the file name in the specified directory.

find ./src -type f -name '*.ts'

Wildcard characters are enclosed in quotes to prevent premature expansion by the shell. This example does not delete files.

du

View the disk space occupied by the specified directory.

du -sh ./data

Counting large directories may be time-consuming, and some files may not have read permissions.

df

Check the remaining space of the file system.

df -h

df checks the file system and du looks at the directory. The statistical calibers of the two are different.

ps

View the process list.

ps -ef

Process parameters may contain sensitive information, please check before sharing.

ss

View the TCP port that is listening on.

ss -ltn

This is a network status tool for Linux and does not automatically scan remote hosts.

ip

View the local interface address and routing.

ip address show
ip route show

Only the current configuration is read; iproute2 may not be installed on the system.

wc

Count the number of lines, words, or bytes of text.

wc -l notes.txt

-l counts the number of newlines. You need to pay attention when there is no newline in the last line.

sort / uniq

Group duplicate rows and count occurrences.

sort names.txt | uniq -c

Sorting depends on the locale; sorting first can merge non-adjacent duplicate rows.

sha256sum

Computes the SHA-256 digest of a file.

sha256sum archive.zip

A summary can check whether the content is consistent, but a summary alone cannot prove that the source of the document is trustworthy.

Instructions for use

  1. Enter the command name, purpose or keywords in the filter box.
  2. Read the description and limitations of the match command to confirm whether the example is suitable for your environment.
  3. Copy the examples you need; we won't execute the commands in the terminal for you.

Input and output examples

Example input
df -h
Example output
文件系统空间

These are demo inputs and sample results, and do not mean that your data has been processed.

Calculation basis and reference materials

This is a quick quick tour of selected commands, not a full man page. This site only displays and copies examples and does not run terminal commands; parameters may vary depending on the distribution.

Content check: · About this site and content description

Related tools