bash2 - Grinshpon/Shell-and-Git GitHub Wiki
Directories and Files
Before getting further into the shell environment, one important aspect to know about is how Unix systems handle files and directories. On Unix file paths look like this:
/path/to/file
Where path and to are directories and file is the file being referenced by the path.
The file system starts at the root directory, under which everything else is contained. Root in the shell is simply a slash /.
$ ls /
It's important to note that in a shell, starting a filepath with a / means you start at root. Starting a filepath with the first subdirectory starts locally. There is another shortcut, the tilde ~, which points towards the home directory /home/$USER, in which USER is whatever user you are logged in as.
$ ls ~
There is also the dot ., which represents the directory that you are currently in, and two dots .. represents the parent directory, or the one above you.
$ ls .
$ ls ...
In order to move to and from directories, you must know the cd command. cd Means change directory. You can access a local subdirectory.
$ cd Documents
Or you can access a directory using one of the shortcuts.
$ cd /usr/bin
$ cd ~/Downloads
$ cd ..
$ cd ./Documents
Directories, as you might have guessed, contain files. An empty file can be created with the touch command
$ touch example.txt
Unix functions under the philosophy that everything is a file, which means that all components can be treated as a file, or essentially a stream of bytes. Your hard drive is likely mounted on /dev/sda, and so even though it's a physical device, in the filesystem it's treated as a file. The file /dev/null discards anything you write into it, like a dump, and /dev/random generates random noise, and you can read from it to generate random sequences.
$ head -c 30 /dev/random