Actions

Basic Linux Commands

From Montana Tech High Performance Computing

Revision as of 09:38, 2 March 2018 by Bdeng (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

You can use the man command to quickly check the manual of a command/program. For example, to check the manual of the cp command, you can simply do: $ man cp

Below are some examples of basic commands in Linux command line.

  • To check your current directory use the command:

$ pwd

  • Copy an folder to your home directory:

$ cp -r /opt/intro ~

Copy a file to your home directory:

$ cp /opt/intro/helloworld.f ~

The tilde symbol is your home directory

  • List the contents of your home directory:

$ ls

  • Go to the newly copied directory intro and list contents:

$ cd intro

$ ls

  • Create a new folder, testfolder, here

$ mkdir testfolder

$ ls

  • Move/Rename a file(or folder)

$ mv helloworld.f helloworld2.f

$ls

$ mv helloworld2.f ./testfolder/

$ ls

$ ls ./testfolder

Here the dot above represents the current directory.

  • Go back to your home directory

$ cd

  • Delete file/folder

$ ls

$ rm helloworld.f

$ ls

$ rm -r intro

$ ls