Where am I?
---------------
pwd Shows the path of your location


Navigation
---------------
How is the directory structure setup?
you have a root directory at the top -> /


you can navigate with cd
cd / navigated to the root directory 
cd /home/user goes to your home directory
same as
cd ~

cd .. goes on directory to the top
cd user goes from your current location to the directory user. This is not the same as /user

User the tab-Tasten to autocomplete the path while you are writing. 

Create a directory
-------------------------
create a directory for some commandline tests.
cd ~
mkdir demo created the directory demo 
cd demo



Show me what is in a directory
-------------------------------
ls lists all files and directories
ls -l show a more detailed list of the files/directories with time, user access rights
ls -al also shows hidden files
ls -1 shows only the file names

How to create a new file
--------------------------
touch myfile.txt creates a new file


Create a directory
-------------------------
create a directory for some commandline tests.
cd ~
mkdir demo created the directory demo 
cd demo

Copy
------- 
cp myfile.txt newfile.txt copies the file to a new file
cp myfile.txt /home/user/ copyies a file to a directory
cp -R /home/user/demo /tmp copies a whole directory to a new location (-R recursive)

Who is sudo?
----------------
With sudo you can do things that you are normally not allowed to.
sudo runs commands with root-rights
With sudo you can f.e. install more software, administrate services, change access rights and more fun. You will see the use of sudo in some of the following commands.

Search and install programms
---------------------
Show information about programms
apt show postgis

Search for programs 
apt search postgis

Install programs
sudo apt-get install sl

you can run the new program with 
sl
apt show sl

Services
-----------------
Restart your Apache Service
sudo service apache2 restart

sudo service apache2 --help

sudo service apache2 status

Get to know the vim Editor - you can edit files on the command line
---------------
vim -  Vi IMproved
see also https://help.ubuntu.com/community/VimHowto
sudo vim pg_hba.conf - opens a file
press i to switch to the edit mode
ESC leave the edit mode
:w save your changes
:wq save your changes and close the file
:q close the file
:q! close the file without saving

Find something
------------------
find
locate

Owner and access rights
----------------------------------

Owner - Group and others
A directory or files has an owner and a group definition. 

you can show them via ls -l

ls -l ~
drwxr-xr-x  7 user user     4096 Nov 18 18:20  Desktop

d Desktio is a directory
user is defined as the owner and the group

Accessright
r read
w write
x execute

first 3 letters for the owner
the 3 letters for the group
3 letters for other 

You can change the owner with chown
---------------------------------------------------
sudo chown -R user:www-data /var/www/html/TBD
first pass the user than the group - like user:www-data
-R recursive

You can change the access rights with chmod
----------------------------------------
sudo chmod -R 777 /var/www/html/TBD 
777 everyone can do everything

1. number: owner (u) 
2. number: group (g)
3. number: other (o)

-R recursive

660 user and group are allowed to read and write, other have no rights
744 user can do everything, group and others can only read

or use it like this
chmod -R u+rwx /var/www/html/TBD 
u = user 
g = group 
o = other 
a = all 
+/- right: r = read / w = write / x = execute