CS197U: A Hands-on Introduction to Unix

Demo commands

I listed all the commands we did in the class. If you have any questions, first try to refer to man. But as always, please don't hesitate to ask questions.

yppasswd : change passwords at edlab machines all at once

rm -i file.txt : needs user confirm before deleting the file.txt

rm -v file.txt : provides the detail information about deleting file.txt

man ls : display the help information for command ls; press h to see how to navigate

mkdir -p parent_dir/child_dir : use -p to create parent_dir if it does not already existing

touch -t 201509171211.11 existingfile.txt : changes the ctime, atime, mtime to YYYYMMDDHHMM.SS format.

cp f1.txt f2.txt; cp -r dir1 dir2; cp f1.txt dir1; cp f1.txt f2.txt dir1 are all valid. However cp f1.txt f2.txt f3.txt is not valid; the last argument has to be a directory for copying multiple files.

stat existingfile.txt : the last 4 lines show the timestamps of the file.

head -n k f1.txt : displays the first k lines of the f1.txt; remember, head always display from the start of file (refer the picture in class. )

tail -n k f1.txt : displays the last k lines of the f1.txt; similar to head, tail always display until the end of file.

sort -n f1.txt : sort the lines in f1.txt in an ascending numerical order

sort -n f1.txt | head -n 100 : first sort and pipe | the output to the head command