- 01Getting Started
- 02What Is a Terminal?
- 03Checking Where You Are with pwd
- 04Checking Contents with ls
- 05Seeing Hidden Files Too with ls -la
- 06Moving Around with cd
- 07Creating a Folder with mkdir
- 08Creating a File with touch
- 09Viewing a File's Contents with cat
- 10Displaying and Writing Text with echo
- 11Searching Text with grep
- 12Copying and Moving with cp / mv
- 13Deleting with rm (Use Caution!)
- 14Checking Who You Are with whoami
- 15Changing File Permissions with chmod
- 16Finding Files with find
- 17Viewing Part of a File with head/tail
- 18Counting Lines & Characters with wc
- 19Viewing Running Processes with ps
- 20Ending a Process with kill
- 21Checking Free Disk Space with df
- 22Checking a Folder's Usage with du
- 23Sorting a File's Lines with sort
- 24Merging Duplicate Lines with uniq
- 25Extracting a Column with cut
- 26Viewing Command History with history
- 27Reading a Command's Manual with man
- 28Creating a Symbolic Link with ln -s
- 29Bundling Files with tar
- 30Replacing Text in a File with sed
- 31Finding a Command's Location with which
- 32Setting Environment Variables with export
- 33Checking Environment Variables with printenv
- 34Giving a Command a Nickname with alias
- 35Extracting a Column with awk
- 36Checking System State with top
- 37Making a Request to a URL with curl
- 38Checking a Server's Reachability with ping
- 39Connecting to a Remote Server with ssh
- 40Changing a File's Owner with chown
- 41Comparing Two Files with diff
- 42Checking the Current Date and Time with date
- 43Checking Your Computer's Name with hostname
- 44Replacing Characters with tr
- 45Displaying with Line Numbers Using nl
- 46Extracting Just the Filename with basename
- 47Extracting Just the Folder Part with dirname
- 48Generating a Sequence with seq
- 49Checking Your User Info with id
- 50Checking Memory Usage with free
- 51Checking Server Uptime with uptime
- 52Doing Simple Math with expr
- 53Listing Environment Variables with env
- 54Checking a File's Details with stat
- 55Repeating a String with yes
- 56Creating Nested Directories at Once with mkdir -p
- 57Clearing Command History with history -c
- 58Checking a Command's Type with type
- 59Reversing Text with rev
- 60Formatting Output with printf
- 61Making Usage Human-Readable with du -h
Viewing Part of a File with head/tail
head and tail are for when "I just want a quick look at the start or end of a long file." head shows just the beginning of a file, and tail shows just the end.
Use them in the form head filename and tail filename. By default they show 10 lines from the start or end, and the -n option changes how many.
Running head notes.txt shows just the first 10 lines of notes.txt. Handy when displaying the whole file with cat would be too much.
A common early mistake is wanting to see the latest info in a large log file, but reaching for head and only seeing old information. Use tail when you want the most recent entries.
In real work, watching the end of a log file in real time with tail -f is an extremely common technique in server operations.
🧑💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).
