Learn by reading through in order

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`.

CommandWhat it does
du -sh dirShow a directory's total size in human-readable units
df -hShow total, used, free, and use% for the whole disk
When to use du vs df
A targetdirectoryTotal sizee.g. 4.0MLow on space?Check df → duThe whole diskFree, used,and use% listdu -sh dirdf -h
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

① Run mkdir -p data to create a directory to measure.

② Run echo 'sample' > data/a.txt to put a file inside it.

③ Add the two options for "summary only" and "human-readable units" to du and show the size of data.

④ Add the human-readable option to df and show the whole disk's free space. (Run it correctly and the explanation will appear.)

Linux console
0 / 4 completed
Loading Linux Terminal...

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 codeMeaningExample
%YYear (4 digits)2026
%mMonth (2 digits)05
%dDay (2 digits)18
date and format specifiers
System'scurrent timeWeekday day time(default full output)Pick a formatwith +2026-05-18%Y=year %m=month%d=daydatedate +%Y-%m-%d
Plain 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)

① Run date with no arguments to show the current date and time in the default format.

② Add + to date and pass the year-month-day format to pull out just the date, in a shape like 2026-05-18. (Run it correctly and the explanation will appear.)

Linux console
0 / 2 completed
Loading Linux Terminal...

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?"

CommandWhat it does
uname -aShow system info such as the kernel name and version
whoamiShow the name of the user running the command
idShow the user's UID and group's GID
What uname / whoami / id tell you
System infoOS / kerneltype and versionCurrent userUser namee.g. rootUser numberUID and GIDe.g. uid=0(root)uname -awhoamiid
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)

① Add the option that prints all info to uname and show the system information.

② Use whoami to check the current user name.

③ Use id to check the UID and GID.

Linux console
0 / 3 completed
Loading Linux Terminal...

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.

CommandWhat it does
seq 1 5Generate 1 through 5, one number per line
seq 2 2 102 to 10 in steps of 2
expr 3 + 4Compute, with numbers and operator space-separated
Sequences with seq and arithmetic with expr
Make a sequence(seq)1 2 3 4 5start, end(step)2 4 6 8 10Do arithmetic(expr)7num op numspace-separated4seq 1 5seq 2 2 10expr 3 + 4expr 10 - 6
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

① Use seq to print 1 through 5, one number per line.

② Pass three numbers to seq to print 2 to 10 in steps of 2.

③ Compute 3 + 4 with expr and check the result.

④ Compute 10 - 6 with expr and check the result.

Linux console
0 / 4 completed
Loading Linux Terminal...
QUIZ

Knowledge Check

Answer each question one by one.

Q1What does running du -sh data show?

Q2Which is the output of date +%Y-%m-%d?

Q3What does running expr 3 + 4 output?