Linux commands


The very basics
The program to enter the commands is Terminal. Just find it in menus and double-click to open.  
When in Terminal:
The flashing cursor indicates that the computer expects you to type commands in a special language called 'bash'. That means you are typing in a Command-line
‘enter’ key of the keyboard indicates end of one Command-line and starts its execution. Until the ’enter’ key is pushed you can type, clear, change anything in the command-line. Nothing will happen.
‘space’ key divides words in a command-line syntax (No commas needed! Just space)
“” (quotation marks) mean the text typed between them is not a command (could be an argument though, but as a whole, not in parts).
/ (slash) is used to indicate hierarchy of directories in their 'pathnames'. The highest directory (the 'root') is indicated as '/', all other directories pathnames are like: /home/user/sth/sth/etc, the pathname of the file 'filename' in the directory atc will be : /home/user/sth/sth/etc/filename
Navigation in the whole history of keyboard-printed commands (since the linux installed on this computer) is possible by ‘up’ and ‘down’ arrow-keys. Each time the returned command is put in command-line, so pressing the ‘enter’ key will activate it. No copy-paste needed.
Moving cursor within the command line is only possible by ‘left’ and ‘right’ keys. The mouse can not move the cursor.
‘Delete’ and ‘backspace’ keys work from where the cursor is (‘Delete’ deletes one sign to the right of the cursor, 'backspace’ deletes one sign to the left ).
Any typing results in text insertion right to the cursor.
Copy-paste is possible by using the mouse: highlight the text to be copied (move mouse pointer above the text while the left button being pressed down. The background will change to indicate that the text is highlighted), free the left button and push the middle button of the mouse. The text will be pasted right to the cursor.
Useful Commands:
exit = exit the Terminal. Does not stop the process. Just closes the Terminal window and shows the desktop. (The Terminal could also be closed by pushing the usual 'close' button of its window).
man  ‘command’ = manual description of a command, h = help (when in manual), shorter (summarized) description, shows sub-commands of the command
‘command’ --help = shows help page of the command (summary of the relevant manual page)
q = quit (the manual, the file content viewing). Takes back to command-line regime
pwd = print working directory, shows address of the current directory
cd = change current directory. without an argument, it changes to user’s default: /home/username 
cd .. changes to the parent directory of the current directory.
mkdir sth = make new directory called sth
rmdir sth = remove (delete) directory sth (it should not be current directory). Removes only empty directories. To remove all directories use rm -r (see below)
ls = list content of the current directory. by default hidden files/folders ignored 
ls -l = long format of listing 
ls -a = all content, including hidden files/folders
rm sth = remove (delete) file  sth (recoverable in principle. unrecoverable = shred). 
rm * deletes all files of the current directory. 
rm -r * deletes all content of the current directory (including subfolders and their files and subfolders etc)
touch sth = make new file called sth (in reality this command changes ‘last modified’ time of a file into the current time. But if file does not exist, it is created)
mv file1 file2 = move file1 (not from a directory, but from a name! in essence = rename file1 into file2 + overwrite if file2  already existed)
mv file1 dir1   will simply move file1 into directory dir1
mv dir1 dir2    might have different results: if dir2 did not exist, than dir1 will just be renamed in dir2. If dir2 existed than dir1 (with all its content) will become a sub-directory to dir2. 
cp file1 file 2= make a copy of file1 and name it file2 + overwrite if file2 already existed;
cp file1 file2 dir1   make a copy of file1 and file2 in the existing directory dir1. If dir1 does not exist the command will not be executed
cp dir1 dir2    might have different results: if dir2 did not exist a copy of dir1 will be created and named dir2. If dir2 already existed than copy of dir1 (with all its content) will become a sub-directory to dir2.

more, less = show content of the file (more is primitive. better to use less)
 Argument wild-cards:
* =  any number of signs in the filename (only * means all files in current directory)
? = one sign in the filename
printing part of a filename + pressing ‘tab’ key results in completion of the filename. If several files match, the ‘beep’ sound heard. pressing ‘tab’ again will display them all
. = current directory
.. = mother directory to the current directory



whoami = Who am I, returns name of the current user
su = shift (change) user
PS1 = prompt string, number 1 (default user). The command defines content of the prompt (what the computer itself writes at the begining of each command-line. By default it usually looks like username@computername :~$).  
                           the command to change PS1 is like this:
                           PS1=”\u\d\t\$”(will result in a prompt containing username, date and time).