2.3 File management

Here are some examples on basic file management.

(Note that the commands are in one single line, i.e. don't break them into multiple lines!)

  • Change directory, e.g. change to a subdirectory called "mydir":$cd mydir.

    • Change to the parent (upper) folder:$cd ..

    • Change to the previous folder:$cd -

    • Change to your home directory:$cd ~

      or solely$cd

  • Create directory, e.g. create a directory named "mydir":

    $ mkdir mydir

  • List files, e.g. in the directory "mydir":

    $ ls mydir

  • Create an empty file, e.g. create a file named "myfile":

    $ touch myfile

  • Copy files, e.g. copy a file named "myfile" as "myfile_copy":

    $ cp myfile myfile_copy

  • Move files, e.g. move a file named "myfile_copy" into directory "mydir":

    $ mv myfile_copy mydir/myfile_copy

  • Rename files, e.g. rename a file named "myfile" into "myfile1":

    $ mv myfile myfile1

  • Remove files (use with caution!!), e.g. remove a file named "myfile1":

    $ rm myfile1

Last updated

Was this helpful?