Skip to content

Using Files

Viewing Files

If you want to view the contents of a file, there are two commands that you can use to do so.

The first is better suited to small files:

Text Only
% cat cool-stuff.py

The second method calls up an interactive pager that display over the entirety of your terminal window. It will also allow you to scroll through and search for text. Use the j and k keys to scroll, and when you are ready to quit press q:

Text Only
% less cool-stuff.py

Deleting Files

To delete a file, we use the rm command.

Danger

The rm command is not like deleling files using a GUI! This command does not move files to a "recycling bin". Instead, it permanently deletes them. There is (almost) no way to recover them.

Here's an example:

Text Only
% rm cool-stuff.py

Copying Files

The command to copy files is cp. To copy a file, run the copy command followed by the name of the file that you want to copy, and then the location that you want the copy to be in. This command is handy when you'd like to try something new with your code, but you're worried about breaking it:

Text Only
% cp cool-stuff.py.bak

Moving/Renaming Files

In Linux, moving something and renaming it are the same thing. To do this use the mv command. This command takes two arguments: the path of the file to move/rename, and the new path/new name.

Text Only
% mv cool-stuff.py really-cool-stuff.py