UNIX treats everything as a file... Directories and devices like the hard disk, DVD-ROM, and printer are files to UNIX.
Three types of files
UNIX files are organized in a hierarchical (an inverted tree) structure, starting with root (/
)
import IPython.display
IPython.display.Image(filename='images/tree.png', embed=True, width=500)
Image Source: S. Das. Your UNIX/Linux: The Ultimate Guide. Third. McGraw-Hill, Inc.,
>mkdir myDir
(UNIX is case sensitive by-the-way) creates a directory myDir in the current directory
>mkdir myDir1 myDir2
Creates multiple directories in one command
>mkdir myDir1/myDir2
creates myDir2
inside of myDir1
(must exist)
rmdir myDir
Only works for empty directories. (No other files/directories inside)
rm -R myDir
Use will caution! You CANNOT recover from rm
>cp file1 file2
Copies file1
to file2
>cp -R myDir1 myDir2
-R
option copies recursively, meaning all subdirectories will be copied as well
>mv file1 file2
When used this way it’s basically a rename utility
>mv file1 file2 myDir
Moves file1
and file2
into the directory myDir
>rm file1 file2
>rm file*
*
is a wildcard, meaning anything, the command will remove all patterns that match file with anything following.
Can be dangerous. With the right permissions rm -Rf /*
would remove most of the files on your hard drive without warning.
Protect yourself rm -i