The file system is responsible for managing information on the disk.
Information is stored in files, which are stored in directories (folders).
Directories can also store other directories, which forms a directory tree.
cd path
changes the current working directory.
ls path
prints a listing of a specific file or directory; ls
on its own lists the current working directory.
pwd
prints the user’s current working directory.
/
on its own is the root directory of the whole file system.
A relative path specifies a location starting from the current location.
An absolute path specifies a location from the root of the file system.
Directory names in a path are separated with /
on Unix, but \
on Windows.
..
means ‘the directory above the current one’; .
on its own means ‘the current directory’.
cp old new
copies a file.
mkdir path
creates a new directory.
mv old new
moves (renames) a file or directory.
rm path
removes (deletes) a file.
*
matches zero or more characters in a filename, so *.txt
matches all files ending in .txt
.
?
matches any single character in a filename, so ?.txt
matches a.txt
but not any.txt
.
The shell does not have a trash bin: once something is deleted, it’s really gone.
Most files’ names are something.extension
. The extension isn’t required, and doesn’t guarantee anything, but is normally used to indicate the type of data in the file.