Q1What does running du -sh data show?
System Info Commands — du / df / date, and more
Check directory size with du -sh, disk free space and usage with df -h, the date with date +%Y-%m-%d, the kernel with uname -a, the user with whoami and id, plus seq and expr — with diagrams and a hands-on terminal.
Checking Disk Usage — du and df
This article covers four kinds of check commands: ① disk usage (du / df), ② date and time (date), ③ system and user (uname / whoami / id), and ④ sequences and arithmetic (seq / expr).
du reports how much space a directory or file uses, while df reports the free space and usage of the whole disk.
Reach for du when you want "how much space is this directory taking up?" and df for "how much free space is left on the whole disk?".
When you're running low on space, a common flow is to check the whole disk with `df -h` first, then hunt down large directories with `du -sh`.
| Command | What it does |
|---|---|
du -sh dir | Show a directory's total size in human-readable units |
df -h | Show total, used, free, and use% for the whole disk |
du -sh dir shows a target directory's total size, and df -h shows the whole disk's free space and usage. When space runs low, look at the whole disk with df -h, then find large directories with du -sh.mkdir -p data # create something to measure
echo 'sample' > data/a.txt # put a little content inside
du -sh data # total size of data (e.g. 4.0K data)
df -h # the whole disk's free-space list
Checking the Date and Time — date
date shows the current date and time.
Run it with no arguments and it prints the default format, including the weekday, month, day, and time.
Pass a format after +, like date +%Y-%m-%d, and you get just the date in a fixed shape such as `2026-05-18`. `%Y` is the 4-digit year, `%m` the 2-digit month, and `%d` the 2-digit day.
It's handy for things like putting a date in a log file name.
| Format code | Meaning | Example |
|---|---|---|
%Y | Year (4 digits) | 2026 |
%m | Month (2 digits) | 05 |
%d | Day (2 digits) | 18 |
date prints the default full output, while date +%Y-%m-%d pulls out just the date following the %Y year, %m month, %d day format.date # e.g. Mon May 18 14:30:05 UTC 2026 (default full output)
date +%Y-%m-%d # e.g. 2026-05-18 (just year-month-day)
Checking the System and User — uname / whoami / id
uname -a prints system info about the running OS all at once — the kernel name, version, architecture, and more.
whoami shows the name of the user currently running the command.
id shows that user's UID (user number) and the GID (group number) of their group, so you can check what privileges you're running with.
It's also used inside scripts to decide "who am I running as?"
| Command | What it does |
|---|---|
uname -a | Show system info such as the kernel name and version |
whoami | Show the name of the user running the command |
id | Show the user's UID and group's GID |
uname -a covers the system (kernel) side, whoami the current user name, and id that user's UID and GID.uname -a # kernel name, version, architecture, and more
whoami # the current user name (e.g. root)
id # e.g. uid=0(root) gid=0(root)
Sequences and Arithmetic — seq and expr
seq generates a sequence of numbers. seq 1 5 prints 1 through 5, one per line, which is handy for setting a loop count.
Pass three numbers, like seq 2 2 10, and they're read as start, step, end — so you get 2 to 10 in steps of 2.
expr does simple arithmetic on the command line. expr 3 + 4 prints 7, and each number and operator must be separated by spaces.
It's used inside scripts to count or add numbers.
| Command | What it does |
|---|---|
seq 1 5 | Generate 1 through 5, one number per line |
seq 2 2 10 | 2 to 10 in steps of 2 |
expr 3 + 4 | Compute, with numbers and operator space-separated |
seq builds a sequence from a start and end (and an optional step), while expr computes from space-separated numbers and operators.seq 1 5 # 1 2 3 4 5, one per line
seq 2 2 10 # 2 to 10 in steps of 2
expr 3 + 4 # 7 (space-separated)
expr 10 - 6 # 4
Knowledge Check
Answer each question one by one.
Q2Which is the output of date +%Y-%m-%d?
Q3What does running expr 3 + 4 output?