
Starvard University · The Linux Command Line
You will move around, manage files, and automate boring tasks from the command line, the skill behind most technical jobs. You will start with read only exploration, learn each command carefully, and always meet a clear warning before anything destructive.

Hello, my name is Finn, and I'm going to help you understand this course.
Here it is, explained like you are 10:
The command line is a place where you type short instructions and the computer follows them exactly. Instead of clicking through menus, you type commands like ls to list files and cd to move between folders. This course teaches those commands one at a time, safely, so you can manage files, search text, and automate dull jobs with confidence.
Every command in this course was checked against its manual page. You can do the same yourself at any time by typing man followed by a command name, for example man ls. The shell, usually Bash, is the program that reads your commands. Small tools that each do one job well are the heart of Linux, and joining them with pipes is where the real power appears.
Safety comes first here. You will explore with read only commands before you change anything, and any command that can delete or overwrite gets a clear Warning in the same breath. The rm command has no trash can, so this course teaches you to pause, check with ls, and only then act. By the end you will write a small script and schedule it with cron.
The whole course in brief
What you will be able to do after this course
The eleven lessons
Lesson 1
The command line looks plain, but it is one of the most durable skills in computing. Graphical tools change every few years, while core Linux commands have stayed steady for decades. When you type a command, you give a precise instruction that the computer repeats exactly, on one file or on thousands. That precision is why system administrators, programmers, scientists, and support teams still live in the terminal every day.
A terminal is the window, and the shell is the program inside it that reads your commands. On most Linux systems the shell is Bash. You type a command, press Enter, and the shell runs it and shows the result. Three habits will serve you from day one. First, read what the screen says, because errors are information. Second, use the up arrow to recall earlier commands instead of retyping them. Third, type man followed by a command name, as in man ls, to read its manual page, the official ground truth for what it does.
Start read only. Commands that only look, like ls, pwd, cat, and grep, cannot harm your files, so explore freely with them. This course follows that order on purpose: look first, change later, and meet every destructive tool only after you know how to check your work. By the end, the black window will feel less like a test and more like a workshop you control.
Lesson 3
To make a new directory, use mkdir, as in mkdir projects. The flag -p, as in mkdir -p projects/2026/notes, creates parent folders as needed and avoids errors if a folder already exists. The command touch creates an empty file, as in touch notes.txt, or updates a file time stamp. To copy a file, use cp with a source and a destination, as in cp notes.txt notes-backup.txt. Warning: cp will overwrite a destination file with the same name without asking, so check the destination name first. To copy a whole directory, add the recursive flag, as in cp -r projects projects-backup.
The command mv moves or renames a file, and moving and renaming are the same action in Linux. Typing mv notes.txt archive.txt renames the file, while mv notes.txt projects/ moves it into that folder. As with cp, mv can overwrite an existing file at the destination, so look before you move. The command rmdir removes a directory only if it is empty, which makes it a gentle first deletion tool.
Now the command that demands the most respect. Warning: rm removes files permanently and Linux has no trash can for it, so a file removed with rm is gone and cannot be undone from the terminal. Typing rm old-file.txt deletes that one file. The flag -r removes a directory and everything inside it, and -f forces removal without prompts, so the combination rm -rf is especially dangerous. Warning: never run rm -r on a path you have not first listed with ls, and prefer rm -i, which prompts before each removal, while you are learning. Delete slowly, one known file at a time.
Lesson 4
Four tools cover most reading. The command cat prints a whole file to the screen, which is perfect for short files and painful for long ones. The command less shows a file one screen at a time, lets you move with the arrow keys and search with a slash, and quits with q, so use less for anything long. The command head shows the first lines of a file, ten by default, and head -n 20 shows the first twenty. Its partner tail shows the last lines, and tail -n 20 shows the last twenty.
For finding things, grep is the star. Typing grep error report.txt prints every line in the file that contains the word error. The flag -i ignores upper and lower case, so grep -i error also catches Error, and -n adds line numbers to the results. Used with a folder, grep -r pattern folder searches inside files across the folder, which can take time on large trees, so start small.
The command find locates files by name or property. Typing find . -name notes.txt searches from the current directory, written as a dot, downward for that exact name, and find . -name '*.txt' finds matching names. Combine your tools: use find to locate, less to read, and grep to pinpoint the line you need. Reading and searching are read only and safe, so practice them until they feel automatic.
Lesson 5
A pipe sends the output of one command into the next command, using the vertical bar character. This simple idea is the heart of Linux power. Small programs that each do one job are called filters when they read input, transform it, and print a result. The command sort orders lines, wc counts lines, words, and characters, with wc -l counting only lines, and uniq removes repeated neighboring lines, which is why it is often paired with sort.
Build pipelines one step at a time. Typing ls | sort shows a sorted listing. Typing grep error app.log | wc -l counts how many lines mention error, without ever printing them all. Typing sort names.txt | uniq shows each name once. After each pipe, run the pipeline and read the result before adding the next stage. If something looks wrong, shorten the pipeline until the fault appears, then rebuild.
You can also save output to a file with redirection. A single greater than sign, as in ls > listing.txt, writes output into a file. Warning: that form overwrites the file completely if it already exists, so use a new name or check first. Two greater than signs, as in echo done >> listing.txt, appends instead of overwriting, and echo simply prints its text. Pipes and redirection together turn a handful of small commands into a custom tool built for exactly your task.
Lesson 6
Wildcards are patterns the shell expands into filenames before a command runs. The star matches zero or more characters, so ls *.txt lists every file ending in .txt, and ls report* lists every name starting with report. The question mark matches exactly one character, so ls data?.txt matches data1.txt but not data10.txt. Square brackets match one character from a set, so ls [abc].txt matches a.txt, b.txt, or c.txt. Because the shell expands these patterns, a command like cp *.txt backup/ can copy many files in one line.
Preview before you act. Run ls with your pattern first and read the list the shell gives you. Only when the list is exactly the files you intend should the same pattern go into cp, mv, or any deletion command. Warning: a wildcard inside an rm command can match far more than you meant, and rm has no undo, so an ls preview is not optional caution, it is part of the command.
Loops repeat a command for each item in a list. A simple Bash loop looks like this in words and then in practice: the words for file in *.txt, then do, then your command using $file for the current name, then done. Typed as a loop, it can print each name with echo, or process each file in turn. Software Carpentry teaches loops this way, with a variable holding each filename in turn. Quote the variable, as in echo with the variable in double quotes, so names with spaces still work. Loops turn one careful command into patient work across a whole folder.
Lesson 7
Every file has an owner, a group, and a set of permissions that say who may read, write, or execute it. The long listing from ls -l shows these as a string of letters: r for read, w for write, and x for execute, repeated for the owner, the group, and others, in that order. A leading d means the item is a directory. For a directory, execute permission means you may enter it and access its contents, which surprises many beginners.
The command chmod changes permissions. In symbolic form, chmod u+x script.sh adds execute permission for the owner, the u, while chmod go-w file.txt removes write permission from the group and others. In numeric form, each permission has a value, read is 4, write is 2, and execute is 1, and you add them per class. So chmod 755 sets the owner to 7, meaning read, write, and execute, and the group and others to 5, meaning read and execute. The command whoami tells you your username, and sudo runs one command with administrator power.
Handle power with care. Warning: recursive changes with chmod -R or chown -R apply to a folder and everything inside it, and a wrong recursive permission change can lock you out of files or expose private data across a whole tree. The command chown changes a file owner and usually needs sudo, as in sudo chown newowner file.txt. Use sudo only for a specific, understood task, never as a habit, and check permissions with ls -l before and after any change.
Lesson 8
A package manager installs software from trusted collections called repositories, handles the extra pieces the program needs, called dependencies, and keeps track of updates and removal. This is safer and tidier than downloading random programs from the web. On Debian and Ubuntu systems the tool is APT, used through the apt command. On Fedora and related systems the tool is dnf. The pattern is the same in both: refresh the catalogue, then install by name.
On Debian and Ubuntu, first run sudo apt update, which refreshes the list of available packages without installing anything. Then run sudo apt install followed by the package name, as in sudo apt install curl, and read the summary and confirmation prompt before agreeing. The commands apt search and apt show, which need no sudo, help you find and inspect a package before installing. To remove a package, use sudo apt remove followed by its name. On Fedora, the parallel commands are sudo dnf install and sudo dnf remove, with dnf search for finding packages.
A few habits keep installs clean. Install only software you need, from the standard repositories your system already trusts. Read the list of extra packages a command proposes, because that list is the real cost of the install. Keep your system updated with sudo apt upgrade on Debian family systems after an update refresh. And remember that sudo gives full power, so type package commands carefully and never copy an install command from an untrusted page without reading it first.
Lesson 9
A shell script is simply a text file containing commands, saved so you can run them again without retyping. Software Carpentry puts it well in spirit: a bunch of commands saved in a file is called a shell script, but it is really a small program. Create one with a plain text editor such as nano, as in nano hello.sh, and type a few commands, one per line, starting with a comment line beginning with a hash sign that explains what the script does. Comments are for people, and your future self will thank you for them.
Most scripts begin with a special first line called a shebang, written as #!/bin/bash, which tells the system to run the file with Bash. Inside the script, $1 means the first argument you pass on the command line, and the quoted at sign variable means all arguments, so a script can work on files you choose when you run it. Save the file, then run it with bash hello.sh, which works even before you set permissions.
To run a script directly as a program, make it executable with chmod u+x hello.sh, then run it as ./hello.sh, where ./ means the current directory. That dot slash matters, because Linux does not search the current folder for programs by default, for safety. Start tiny: a script that echoes a greeting and lists a folder. Test it, read any errors, fix one thing at a time, and grow it only when the small version works.
Lesson 10
SSH, short for Secure Shell, lets you log in to another computer over a network and use its command line as if you were sitting at it, with the connection encrypted. OpenSSH provides the ssh client on Linux. The pattern is ssh followed by your username, an at sign, and the host name, as in ssh [email protected]. The first time you connect, ssh shows the server fingerprint and asks if you want to continue. That prompt protects you, so continue only when the fingerprint or the server identity is what you expected, and the host key is then saved in your known hosts file.
While connected, everything you type runs on the remote machine, so pwd and hostname help you confirm where you are. Type exit to close the session and return to your own shell. To copy files, use scp, the secure copy tool that works over SSH and follows the cp pattern. Typing scp file.txt [email protected]:/home/user/ copies a local file to the remote home folder, and reversing the order copies a remote file down. The flag -r copies a whole directory recursively, and scp uses a capital -P for a port, because small -p already means preserve file times and modes.
Keys make SSH both safer and easier. The command ssh-keygen creates a key pair: a private key you keep secret on your own machine and a public key you place on the server. Never share the private key or paste it anywhere. Treat a remote server with extra care, because commands act on someone else machine and data. Check pwd, confirm the host, and log out when you finish, every time.
Lesson 11
Automation is where the command line pays you back. Pick a small, boring, repeatable task: for example, making a dated backup copy of a folder of notes, or listing your largest files into a report each morning. Write the commands by hand first and run them until the result is right. Then save those exact commands as a script, with comments, and test the script on a small copy of your data before trusting it with the real thing.
To run a script on a schedule, use cron, the time based job scheduler. The command crontab -e edits your personal schedule and crontab -l lists it. Each line has five time fields, in the order minute, hour, day of month, month, and day of week, followed by the command to run. An asterisk means every value for that field. So a line beginning 0 7 star star star runs at seven each morning, and you would follow it with the full path to your script. Use full paths in cron lines, because cron runs with a plain environment and no memory of your folders.
Automate carefully. Warning: an automated script that deletes or overwrites will do so faithfully on schedule, including when something else has gone wrong, so keep deletion out of first automations and prefer scripts that copy, list, or report. Test with crontab -l to confirm the line you saved, watch the first scheduled run, and check its output file. A small task, automated safely and watched once, is the honest finish of this course: you now command the machine, on time, even when you are not watching.
Sources
This course is grounded in the Linux manual pages, the GNU manuals, and the Software Carpentry Unix Shell lesson, which is licensed CC BY and credited here. Commands and flags were checked against those sources during the build.
Graduation
You learned why the command line matters, how to navigate the file tree, and how to create, copy, move, and delete files safely. You read and searched files, joined commands with pipes, selected files with wildcards and loops, handled permissions and packages, wrote your first script, visited a remote server with SSH, and automated a real task with cron.
Keep learning
This course is part of Starvard University, striving for greatness.
A note on accuracy: Much of what you read at Starvard was created with help from AI agents, working alongside people. We check what we can, but we cannot guarantee that everything here is true, current, or complete. If something really matters, your health, your money, a grade, a job, please verify it with a trusted source before you rely on it.