Operation | Command | Usage Example |
Find out where you are ... your present working directory | pwd | pwd (displays the full pathname of your current directory) |
List the files in the current directory | ls OR ls -l OR ls -a |
ls lists just the names of the files in the current directory; ls -l gives a long listing that includes the file name, permissions, the owner, the size, and the date; ls -a lists all files in the directory, including some system files whose names start with a period; ls -la gives a long listing of all files; ls -l s* gives a long listing lf all files whose name starts with s. (There are lots of other variations!) |
Create (make) a new subdirectory of your current working directory | mkdir directory_name | mkdir lab1 (creates a directory named lab1 within your current directory) |
Change to another directory | cd pathname | cd lab1 (Changes to the lab1 subdirectory of your current directory) (Changes to user jdoe's lab1 directory) |
Copy a file | cp originalFile newFile | cp myProgram.cc ~professor/cpsc120/assignments (copies a file named myProgram.cc into the assignments subdirectory of user "professor") (copies a file named myProgram.cc into a file named newTry.cc (in the same directory); WARNING: if there was already a file named newTry.cc it would be wiped out!) (copies a file named example.cc in the cpsc home directory to the present directory) |
Rename a file (same as moving it to a file with a different name) | mv oldName newName | mv myProg.cc hello.cc renames the file myProg.cc; the new name is hello.cc WARNING: If there was already a file named hello.cc it would be erased by this command. |
Print a file | nenscript -2rG -p- filename | lpr - h OR lpr filename OR lpr -Plabt filename |
nenscript -2rG -p- myProgram.cc | lpr -h (prints the file myProgram.cc in a nice format (that saves paper!) to the lab printer) (prints the file myProgram.cc to the lab printer) (prints the file myProgram.cc to the lab on first floor Trexler) |
View a file on the screen | more filename OR less filename |
(displays the contents of the file myProgram.cc on the monitor one page at a time. Press the space bar to go to the next page; type b to go back to the previous page; type q to quit. less is similar.) |
Delete (remove) a file | rm filename | rm myProgram.cc (deletes the file myProgram.cc in the current directory) |
Delete (remove) a directory | rmdir directoryName | rmdir lab1 (removes the directory lab1 from the current directory. The directory must be empty to remove it.) |