Operation | Command | Usage Example |
---|---|---|
Find your present working directory. | pwd | pwd (Displays the full pathname of your current directory) |
List the files in the current directory. | ls |
ls (Lists just the names of the files in the current directory.) |
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.) |
Copy a file |
cp originalFile newFile |
cp my_program.py ~prof/cs120/assignments (Copies a file named my_program.py into the assignments subdirectory of user prof.) cp my_program.py new_try.py (Copies a file named my_program.py into a file named new_try.py, in the same directory. WARNING: If there was already a file named new_try.py it would be wiped out!) cp ~cpsc/example.py . (Copies a file named example.py in the cpsc home directory to the present directory. Note, the dot means present directory.) |
Rename a file (same as moving it to a file with a different name). | mv oldName newName | mv my_program.py hello.py (Renames the file my_program.py. The new name is hello.py. WARNING: If there was already a file named hello.py it would be erased by this command.) |
View a file in the terminal. |
more filename or less filename |
more my_program.py (Displays the contents of the file my_program.py in the terminal one page at a time. Press the space bar to go to the next page. Press b to go back to the previous page. Press q to quit. less my_program.py (Same as more.) |
Delete (remove) a file. | rm filename | rm my_program.py (Deletes the file my_program.py 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.) |
Zip (create archive file of) files. | zip archive.zip files | zip assignment1.zip * (creates a zip file called assignment1.zip that contains all of the files in the present working directory (the * means all files in current directory).) |
Unzip (copy files out of) a zip file. | unzip archive.zip | unzip assignment1.zip (copies all of the files in the zip file assignment1.zip to the present working directory.) |
Convert ppm to png. | convert filename.ppm filename.png | convert mandelbrot.ppm mandelbrot.png (Creates a new file called mandelbrot.png by converting the file mandelbrot.ppm to a png file. |