goal: keep it simple
See also
https://live.osgeo.org/en/quickstart/proj4_quickstart.html
https://live.osgeo.org/en/quickstart/gdal_quickstart.html



Command line Quickstart
#####################
When you work with linux operations systems it is good to know how to work on the command line. 

Don't worry. It is not difficult to learn and you will discover that it is fun and very powerful.

In this quickstart you will learn some basic commands.

The following commands run from within a Terminal Emulator window.
Start a Terminal Emulator (LXTerminal currently) from the  Applications menu in the Accessories section. This gives you a Unix  shell command prompt.

Conntents
--------------
*
* ...

Where am I?
---------------
pwd shows the path of your actual location.

pwd
/home/user

Notice: You can ask all commands for help and get information on how they can be used and find out about additional options.

f.e.

pwd --help
pwd: pwd [-LP]
    Gibt den Namen des aktuellen Arbeitsverzeichnisses aus.
    
    Optionen:
      -L    Gibt den Inhalt der Variable $PWD aus, wenn sie das aktuelle
        Arbeitsverzeichnis enthält.
      -P    Gibt den physischen Verzeichnispfad aus, ohne
                symbolische Verweise.
    
    Standardmäßig wird immer die Option »-L« gesetzt.
    
    Rückgabewert:
    Ist 0 außer wenn eine ungültige Option angegeben oder das aktuelle
    Verzeichnis nicht lesbar ist.



How to navigate in the file system?
---------------
First you should get to know how the file system under Linux is organized. The file system is organized in a tree. It starts with the / (root) directory. All files and directories are under the root directory /.

Your user user has a home directory. located at /home/user. When you open a terminal window you will start in your home directory (see pwd).

You can easily navigate in the file system with the command 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

Notice: Use the Tab key  to autocomplete the path while you are writing. 

Create a directory
-------------------------
You have write access in your user-directory. You can create files and directories there. Next we will create a directory for some commandline tests.

cd ~
mkdir demo - creates the directory demo 
cd demo


Show me what is in a directory
-------------------------------
You would like to know more about the content in a directory. ls is the programm that gives you a lot of information.

ls lists all files and directories
ls -l shows a more detailed list of the files/directories with time, user access rights
ls -a also shows hidden files
ls -al give you can combine the different options
ls -1 shows only the file names

How to create a new file
--------------------------
touch story.txt creates a new empty file

Notice: You can pipe the information from a command to a file f.e.

history > my_command_history.txt

Copy
------- 
You can copy files from one location to another.

cp myfile.txt newfile.txt copies the file to a new file
cp myfile.txt /home/user/ copies 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 the rights of the superuser root
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 will love the program sl. Run the new program with sl see also apt show sl

Services
-----------------
Some programms run as services like PostgreSQL, tomcat or Apache Webserver. You can start or stop the services.

Restart your Apache Service
sudo service apache2 restart

sudo service apache2 --help

sudo service apache2 status

How to edit files
---------------------------
You can either edit files in the terminal or open them with an external program like geany.

In the terminal window you can use the vim editor (Vi IMproved). vim is very powerful and has many options.

See also 
https://help.ubuntu.com/community/VimHowto
https://vim.rtorr.com/lang/en_en


vim /home/user/test.txt - 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
----------------------------------
Access rights define wether a user or group or others have access to a file and what sort of access is given. You can have read, write or excecute access.

Directories or files have an owner and a group definition. By default the creator of a file/directory is the owner. But this definition can get changed. You will learn this in the next section.

You can show the user and group via ls -l

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

The initial character can be - for a file or d for directory
user is defined as the owner and the group

Access rights are listed at the beginning of the row:
r read
w write
x execute

first 3 letters for the owner
then 3 letters for the group
followed by 3 letters for others 

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

4 read
2 write
1 execute

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

Things to try
---------------------
Here are other commands you may try.
What Next?
-------------------
You learned some important commands and information to work on the command line. Hopefully you discovered how powerful the command line is.

*https://ubuntu.com/tutorials/command-line-for-beginners#1-overview
https://en.wikipedia.org/wiki/Category:Standard_Unix_programs