UNIX treats everything as a file... Directories and devices like the hard disk, DVD-ROM, and printer are files to UNIX.
UNIX files are organized in a hierarchical (an inverted tree) structure, starting with root (/
)
Figure Source S. Das. Your UNIX/Linux: The Ultimate Guide. Third. McGraw-Hill, Inc.,
.
(a single dot) represents the current directory..
(two dots) represents the parent directory%%bash
pwd
/Users/john/Documents/HPC_Course/Spring2018/lectures
%%bash
cd images;
pwd
/Users/john/Documents/HPC_Course/Spring2018/lectures/images
%%bash
cd ..;
pwd
/Users/john/Documents/HPC_Course/Spring2018
mkdir myDir
(some UNIX OS's are case sensitive by-the-way)mkdir myDir1 myDir2
mkdir myDir1/myDir2
myDir2
inside of myDir1
(must exist)rmdir myDir
rm -R myDir
rm
cp
- copy¶cp file1 file2
file1
to file2
cp -R myDir1 myDir2
-R
option copies recursively, meaning all subdirectories will be copied as wellmv
- move¶mv file1 file2
mv file1 file2 myDir
file1
and file2
into the directory myDir
rm
- remove¶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
%%javascript
function hideElements(elements, start) {
for(var i = 0, length = elements.length; i < length;i++) {
if(i >= start) {
elements[i].style.display = "none";
}
}
}
var prompt_elements = document.getElementsByClassName("prompt");
hideElements(prompt_elements, 0)