Basic Linux Terminal Commands

If you are new to Linux and it’s terminal, you might be wondering how to move around? I’ll show you how with some basic terminal commands.



Below I’ll list a few examples with comments denoted by #

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Displays contents in folder
ls 
 
# Changes Directory 
cd FOLDERNAME
 
# Go up one directory
cd ..
 
# Go to your home directory
cd
 
# Make directory
mkdir FOLDERNAME
 
# Remove a file
rm -- FILENAME
 
# Copy a file
cp ORIGINALFILE NEWFILE
 
# Move a file
mv SOURCE DESTINATION
 
# Install Program in Ubuntu and other Linux Distros
sudo apt-get install PROGRAMNAME
 
# To run a program you usually specify the name, 
# if text editor, its usually name of program and 
# text file to create, if no file is specified, the text editor still opens.
firefox
emacs hello_world.cpp
 
# Compile a program using g++ 
g++ hello_world.cpp
 
# Execute program 
./PROGRAMNAME


An example of finding help for a certain command is the following:

1
man mkdir


The man command will give you the manual page for a given command.

Example using the terminal

Let’s say we want to view the contents of a folder, create a folder called Example, create a text file using emacs, compile it, run it, and go back to our home directory. To do this, we would simply do the following.

1
2
3
4
5
6
7
ls
mkdir C++
cd C++
emacs hello_world.cpp
g++ hello_world.cpp
./a.out 
cd


Yes there are numerous ways to achieve this, its just a matter of how you want to navigate the terminal.

What now?


If you feel another basic command needs to be here or need more help, simply drop in a line in the comments box! I’ll be sure to put it down.

Expect advanced terminal commands in the near future.

Tags: , ,

  • China Mike

    thanks! Just what I was looking for. I can’t memorize them it seems, so I wanted a short list of the most often used/common. I copied these here and put them in a text file I parked on my Ubuntu desktop.
     

  • Benjisametz

    dir should be here