A command line is an interface for passing arguments to programs. Begin with your current directory, understand which files a command can affect and keep a small practice folder separate from important work.
Know where the command runs
A relative path is interpreted from the current working directory; an absolute path identifies a location from the filesystem root. Use a directory-listing command and inspect the files before assuming you are in the intended project. Spaces and special characters can change how a shell splits text into arguments, so quote paths deliberately.
Connect programs through their output
A pipeline passes one program’s standard output into another program’s standard input. This is useful for filtering or counting text without opening an editor. Standard error is a separate channel, so an error message may not be part of the piped data. Confirm the input and output at each stage when a pipeline gives a surprising result.
Check side effects and exit status
A command can read files, create files, change permissions or contact a remote service. Learn its options before using it on valuable data. Exit status is a conventional signal of success or failure, but important work also needs a visible result check. Practise unfamiliar commands with fictional files and avoid copying privileged commands without understanding them.
Worked example
In a temporary practice folder, create a small text file and count matching lines through a pipeline. First inspect each stage separately. This teaches where the data flows without requiring deletion commands, administrator privileges or access to a live server.
pwd
# Inspect the current folder before using relative paths.
printf "apple\npear\napple\n" | sort | uniq -c
Check your understanding
Try each question before opening its explanation. These are free practice prompts; they do not use game chances.
Why quote a filename containing spaces?
Quoting keeps the intended filename together as one argument rather than allowing the shell to split it into several arguments.
Does a pipe include every error message automatically?
Not necessarily. A normal pipeline connects standard output. Standard error is a separate stream unless you deliberately redirect it.
What should you establish before running a file-changing command?
Confirm the working directory, target paths, intended effect and recovery option. Use a small isolated practice folder when learning behaviour you have not checked.
Sources and further reading
These original examples explain foundational concepts. Use the official references for complete, current details and version-specific behaviour.
About this guide: AI-assisted educational content with original examples and linked primary references. Found an issue? Tell us what to improve.