Basic Linux Commands

Body

Basic Linux Commands

There are a great many things that can be done with a terminal in Linux. The following is a very minimal selection intended to help beginners navigate their way around the Mill using a terminal. At the bottom there are some links for further resources. The only limit to what you can do in a terminal is your imagination (and the lack of a graphical interface)!

The Hierarchical Folder Structure

Use of the command line in Linux assumes that you understand and can hold in your mind the basic organization of files and folders in Linux so that you can navigate them without a visualization.

Below is the output of the tree command, which visualizes home folder of an example user. Folders are in blue and files are in white.

Terminal-style directory tree diagram showing a user folder named User1 containing four simulation folders. Simulation1 includes files Input.txt and Output.txt, plus a subfolder Reference_data containing data.dat. Simulation2 contains Input.txt and Output.txt. Simulation3 contains Input.txt. Simulation4 is listed with no contents shown. Blue text is used for directory names and white text for files on a black background. A summary line at the bottom reads: “6 directories, 6 files.”

The path that tells the computer where a file is located can be determined by following the tree and adding all of the steps in order, separated by For example, the path to the file "data.dat" can be given as:

User1/Simulation1/Reference_data/data.dat

Relative and Absolute Paths

Linux supports two ways of giving paths to things: relative and absolute.

Relative Path - The relative path starts with the current location of your terminal, which is initially the folder your terminal started in. In the previous example, our User1 is just one user among many. The terminal is in the "users" folder, which has a folder for every user including User1.

Absolute Path - Starts at "root", which is the highest level folder on a linux computer, with the path " " (For windows users - This is roughly equivalent to C: ).

As mentioned before, User1 is just one of many users. Their home directory is in a larger folder with many others. The absolute path, traced back to root, is:

/home/User1/Simulation1/Reference_data/data.dat

Note: Linux does not like spaces in file paths

While modern implementations of linux can handle spaces in file paths, the formatting is unintuitive and legacy code may simply not work. It is encouraged to use file and folder names without spaces. Two common conventions: ExampleName, called camel case, and Example_Name, called snake case.

Moving Around With a Terminal

To move around with a terminal, there are three essential commands.

Where You Are - pwd
pwd - this command stands for "print working directory" and will print to your terminal the current location of your terminal

example command: pwd
output: /home/User1/Simulation1

What is Where You Are - ls
ls this command stands for "list" and prints the contents of the current working directory to the terminal. The output will tell you what files and folders are in your current directory.

example command: ls
output: Input.txt Output.txt Reference_data

Move Through the Terminal - cd
cd this command stands for "change directory" and and is used to move the terminal and the current working directory to another folder. It accepts both relative and absolute paths.

example command: cd Reference_data OR cd /home/User1/Simulation1/Reference_data
output: Terminal moves location, no output on successful execution.

Manipulating Files and Folders

These commands can be accomplished within a SCP client like WinSCP or Filezilla, but sometimes it is convenient to perform quick edits in a terminal.

Creating a File or Folder - touch or mkdir

touch will create an empty file and takes the name of the file as an argument. The empty file can be edited with a teminal text editor like nano or vim, though how to do so is beyond the scope of this article.

example command: touch text.txt
output: No output on successful execution. File named text.txt created in current working directory.

mkdir stands for "make directory" and will create an empty folder with a given name. It takes the name of the folder as an argument.

example command: mkdir results_folder
output: No output on successful execution. Folder named "results_folder" created in current working directory.

Copying and Moving

These commands can be accomplished within a SCP client like WinSCP or Filezilla, but sometimes it is convenient to perform quick edits in a terminal.

cp stands for "copy" and will copy a file or folder. For folders, you will generally want the -r (recursive) flag so that all the contents of the folder are copied as well. The command takes two arguments, the path to the file and the path to copy the file to.

example command: cp -r Simulation1/results_folder Simulation2/results_folder
output: No output on successful execution. The results folder will be copied from Simulation1 to Simulation2.

mv stands for "move" and will move a file or folder. Like the "cp" command, you will generally want the -r (recursive) flag for folders. The command takes two arguments, the path to the file and the path to copy the file to. This command is equivalent to the "cp" command except the original file is deleted from the original location after it is moved.

example command: mv Simulation1/Input.txt Simulation4/Input.txt
output: No output on successful execution. The Input.txt file will be moved from Simulation1 to Simulation4.

Further Reading

There are many excellent resources to expand your linux skills beyond the basics.

Google: Performing a simple web search like "linux command move file" will often return helpful information.

Tutorial Websites: There are a number of tutorial websites. These will often come up on the google searches above, but they also have more structured learning organized into courses. Some good ones are: W3 Schools or Geeks for Geeks.

Details

Details

Article ID: 2696
Created
Fri 7/31/26 11:43 AM
Modified
Tue 8/4/26 3:40 PM