-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial 06
In many of the earlier tutorials, we used optional flags with commands. For example, with cp -r, the -r flag enabled recursive mode so it could copy folders, not just files.
As you gain more Linux experience, you'll want to do more complex tasks — and for that, learning how to use options, symbols, and outputs is essential.
Almost every command has its own manual page, which you can access using the man command.
Example:
$ man lsThis shows a description of the command and a list of options (flags) you can use with it. Most options are accessed with a - followed by one or more letters.
Most command options are specified using a dash (-) followed by a letter or group of letters.
Examples using ls:
-
-l: show detailed information -
-t: sort by modification time (newest first) -
-r: reverse the order
You can combine them:
$ ls -ltrLinux makes heavy use of symbolic characters. Here are the most important ones:
-
.refers to the current directory -
..refers to the parent directory (one level up)
$ ls .
$ cd ..Matches any single character in a filename.
Example:
If you have FolderA, FolderB, FolderC, this command matches them all:
$ ls Folder?/Matches zero or more characters.
Example:
$ ls Fol*/Will match FolderA, FolderB, FolderC, etc.
The ~ symbol is shorthand for your home directory.
$ cd ~Use this when you want to quickly return to your main user folder.
By default, Linux commands display output to the terminal screen. But often, you may want to save or process that output.
Saves command output to a file (overwrites if it exists):
$ ls > list.txtAppends output to the end of a file without overwriting:
$ ls >> list.txtThe pipe symbol (|) sends the output of one command into another.
Example: Count how many files/folders are in the current directory:
$ ls | wc -lThis uses ls to list files and wc -l to count the lines (i.e. number of items).
You've now learned how to use flags, wildcards, symbolic shortcuts, and how to redirect or pipe command output — powerful tools that will make your Linux experience much more flexible and efficient! 🚀
➡️ Continue to Tutorial 7