Written 1 Sep 2026. This is a how-to, not a product card.
See the last name
After realpath, basename prints the last name so a practice file shows the file name without the folder path. You don't need extra software for this.
See the full path printed a full path. Tonight you pull the last name off a path: basename. Basename prints the last name from a path. Start with one tiny practice file, then basename ~/basename-a.txt.
Tilde ~ is home shorthand. Folder path is the folders before the file name. Basename strips folder path and keeps last name. You are still only practicing in home on the computer. It does not need extra system software, htop, Grafana, or a NAS for this one job.
Skip until SSH already works
SSH from the couch should already get you a prompt. SSH means type commands from your laptop, on the house network. If a full path is what you want, that is see the full path. If the folder of a path is what you want, that is see the folder path. If the folder you sit in is what you want, that is see which folder you are in.
What this is
basename prints the last name from a path. You make one tiny practice file, then type basename ~/basename-a.txt. Basename prints basename-a.txt with no folder path. Stick with that safe peek. You don't need extra system software for this.
It is not realpath. Realpath prints a full path. It is not dirname. Dirname prints the folder of a path. It is not pwd. Pwd prints the folder you sit in.
Practice basename in home
SSH in. Make sure home is where you sit:
pwd
You want a path that ends in your login name. If not:
cd ~
Make one tiny practice file:
printf 'hello\n' > ~/basename-a.txt
Print the last name:
basename ~/basename-a.txt
You want basename-a.txt, without folder path, then the prompt back. That is enough for tonight. Practice only in home.
Debian and Ubuntu usually already have basename (coreutils). Don't make apt the job.
If basename is missing, install coreutils:
sudo apt install coreutils
Then stop. That apt line is not the lesson.
When you are done looking, throw the practice name away with careful delete only. That is delete a file carefully. Skip rm -rf.
rm -i ~/basename-a.txt
Useful extras, still home only
Optional extra: last name with suffix stripped:
basename ~/basename-a.txt .txt
That peek prints basename-a, without the .txt ending. Don't make suffix strip required.
Optional extra: last name of root:
basename /
That peek prints /. Root has no extra name to strip. Don't make / required. Don't dump the whole / tree.
Skip huge dumps as this job. Basename of whole home, /etc, password files, or huge logs is still a huge dump. Tonight: one tiny practice file.
Skip basename piped into rm. Basename prints last name. Rm deletes files. Don't mix those jobs. Skip dirname, realpath, ln, stat, find, htop, Grafana, and a NAS. Keep SSH on the house network: keep the computer on the house network. Don't forward port 22.
What this is not
This is not realpath. Realpath prints a full path. That is see the full path. It is not dirname. Dirname prints the folder of a path. That is see the folder path. It is not pwd. That is see which folder you are in.
What next
Need the folder of a path? See the folder path. Need a full path? See the full path. Keep SSH on the house network: keep the computer on the house network. Don't forward port 22.
Skip
- Skip if SSH still fails. Finish SSH from the couch first.
- Skip huge dumps as this job. Tonight: one tiny practice file.
- Skip
basenamepiped intorm. Basename prints last name. Don't mix delete into this drill. - Skip
dirnameandrealpathas this job. Those notes already exist. - Skip apt as this job. The coreutils aside is not the lesson.
- Skip
rm -rf. Careful delete only: delete a file carefully. - Skip files under
/etcand whole/. Practice only in home. - Skip opening SSH to the internet. That is keep the computer on the house network. Don't forward port 22.
Sources
Debian: basename(1). Ubuntu: basename(1). Official pages only. For a full path, see see the full path. For the folder of a path, see see the folder path. For the folder you sit in, see see which folder you are in. For the login, see SSH from the couch.