Technische Hinweise II - Linux Administration

Some Technical Hints II - Linux Administration

Sorry, but only some parts are already in English ...

Technische Hilfe für die Installation gibt es grundsätzlich am besten auf den Webseiten der genannten Tools, denn nur dort werden die Hinweise auf dem aktuellen Stand gehalten.
Alle Hinweise sind deshalb nach besten Wissen und Gewissen gegeben - aber ohne Gewähr.

 


 

Content: Technical hints for Linux/Unix administration


Einleitung

Wir haben für einige Installationen, die wir auf Messen oder für den Eigenbedarf selbst ausprobiert haben, an dieser Stelle einige kurze Hinweise zusammengestellt. Aus Kapazitätsgründen können wir diese Seite bei Updates nicht aktuell halten und übernehmen deshalb keine Garantie für eine aktuelle Korrektheit.

Ausführliche Hilfe bieten die Webseiten der verschiedenen Linux-Distributionen

und/oder allgemeine Hilfe-Seite für Linux


Allgemeine Hinweise für Linux/UNIX

Zu allen Befehlen gibt es auf der Kommandozeile Hilfe mit dem Befehl man (für Manual), also z.B. man awk

at - Run command at ...

Kommandos zu einem bestimmten Zeitpunkt ausführen lassen:

at 1am -f datei führt nächsten Morgen um 1h die Befehle in datei aus
at now + 1 hour ... wird in einer Stunde aktiv
at 19:23 ... wird um 19:23 aktiv

Für wiederkehrende Aufgaben siehe cron

 


 

awk - Ein Stream-Editor

 

awk -F':' -f scriptdatei liesdatei< /td> sucht : in liesdatei und führt scriptdatei aus
last | awk '{print $1}' | sort | uniq | wc listet die letzten User im System auf
awk '{print ":" $0 }' fügt ein : am Beginn jede Zeile ein

 To top of page


cp - Kopieren

 

cp Quelldatei Zieldatei Kopieren von Dateien
cp datei1 /tmp kopiert datei1 nach /tmp/datei1
cp -r /archiv /tmp kopiert das Verzeichnis archiv rekursiv mit allen enthaltenen Dateien nach /tmp/archiv
cp -rp /archiv /tmp wie oben; zusätzlich werden die Datei-Besitz- und Zugriffsrechte erhalten

  To top of page

 


cron - Run commands every ...

Zum Einrichten der Aufgaben  crontab -e aufrufen. Als Eingabe wird jeweils eine zeile der Form erwartet:

 m h  dom mon dow   command

Dabei ist

  • m die Minute
  • h die Stunde
  • dom der Tag des Monats
  • mon der Monat
  • dow der Wochentag
  • command der auszuführende Befehl

Mehrere Angaben werden durch Komma getrennt, also z.B. 0,15,30,45 für eine viertelstündliche Ausführung. Als Trennzeichen zwischen den Argumenten werden Leerzeichen oder Tabs akzeptiert.

 

 Zum Seitenanfang zurück


 

date - Datum und Zeit

date liefert das augenblickliche Datum
date +%s das Datum in Sekunden seit dem 1.1.1970 (Unixzeitrechnung)
date +%s --date="8/17/2011" das Datum vom 17.8.2011 in Sekunden seit dem 1.1.1970
date +%c das Datum in der Form "Mi 08 Jul 2015 17:48:09 CEST"

  To top of page


dd - disk dump Hardware-nahes kopieren

dd if=datei1 of=date2 kopiert Inputfile datei1 nach Outputfile datei2
dd if=/dev/fd0 of=/tmp/disk Diskette im Laufwerk fd0 wird als Image Datei disk abgelegt
dd if=/dev/sr0 of=/tmp/startblock bs=1024k count=2 Von einer CD werden die beiden ersten 1024K großen Blöcke in die Datei startblock kopiert
dd if=/dev/zero of=/tmp/leer bs=1024k count=2 Die Datei leer wird mit 2 Blöcken zu 1024K mit Nullen gefüllt

You may copy with dd via the network:
Into an image file:     dd if=/dev/sda1 | pv | ssh user@host “cat > img.dat”
pv is a program to see the progress. You may omit it.

To compress: dd if=/dev/sda1 | pv| gzip -c | ssh user@host “cat > img.gz”

Restore the image from a file to a partition: sdb1: dd if=image of=/dev/sdb1
or with pv: dd if=image | pv | dd of=/dev/sdb1
From a compressed image: gunzip -c image.gz | buffer -s 64k -S 10m | dd of=/dev/sdb1

More hints about dd
http://wiki.ubuntuusers.de/dd
http://konstantin.filtschew.de/blog/2007/07/22/partitionen-mit-dd-unter-linux-sichern-und-auch-mal-per-ssh-uber-das-netzwerk/

To top of page


 

find - Suchen nach Dateien

find <pfad> -name <begriff> -print sucht im Pfad pfad rekursiv durch alle Unterverzeichnisse nach Dateinamen die den Suchbegriff enthalten und gibt diese aus
find <pfad> -name <begriff> -exec rm '{}' \; sucht im Pfad pfad nach Dateinamen die den Suchbegriff enthalten sind und löscht diese
find . -name thumbnail* -exec rm '{}' \; z.B. sucht im aktuellen Verzeichnis nach Datein, die mit thumbnail beginnen und löscht diese

Es gibt viele weitere Optionen bei der Verwendung von find. Durch die Verwendung der Option -exec oder durch das Hintereinanderausführen von Kommandos über eine Pipe | können komplexe Vorgänge damit ausgeführt werden, z.B. ein vollständiges Backup.

find /daten -hidden -depth -print | cp -rp /tmp/backup Hier werden alle Dateien, auch versteckte, aus dem Verzeichnis /daten unter Beibehaltung ihres Besitzers und der Rechte (-rp) nach /tmp/backup kopiert.

find . -mtime +0 findet Dateien, die vor mehr als 24 Stunden verändert wurden
find . -mtime 0 findet Dateien, die innerhalb der letzten 24 Stunden verändert wurden
find / -inum 4567 -ls findet Hardlinks auf inode 4567
find / -perm 4000 –ls findet alle Dateien in denen das s-Bit gesetzt ist
find . -name '*' -print0 | xargs <befehl> findet beliebig viele Dateien (mehr als ls schafft) und übergibt diese an das Kommando xargs, um einen Befehl darauf auszuführen

  To top of page


 

grep - Suchen nach Texten in Dateien

In allen Unix/Linux-Betriebssystemn gibt es die Befehle find und grep, um entweder nach Dateinamen oder nach Texten in Dateien zu suchen.

grep <begriff> <datei> sucht nach Begriff in der Datei
grep –n <begriff> <datei> suche Begriff mit Angabe der Zeilennummer
grep -w <begriff> <datei> alle Zeilen ohne den gesuchten Begriff

So findet grep -w # datei.txt in der Datei datei.txt alle zeilen ohne das Kommentarzeichen (#). Besteht der Suchbegriff aus mehreren Wörtern, so ist er in " einzuschließen.

 To top of page


iptables - Firewallregeln bearbeiten

Glücklicherweise muss niemand mehr seine Firewall mit einzelnen iptables Befehlen aufbauen. In Ubuntu gibt es dazu grafische Tools wie gufw, andere Alternativen sind firestarter oder das Monumentalwerk fwbuilder.

Wer sich dennoch mal die installierten Regeln anschauen möchte oder damit spielen will ...

iptables -F löscht alle Regeln
iptables --append -A input -p tcp -s ANY/0 -d ANY/0 --dport 22 -j ACCEPT

fügt zur input-Kette die Erlaubnis für tcp-Pakete von jeder Adresse an jede Adresse mit dem Zielport 22 (ssh) hinzu.

-j das Sprungziel kann sein ACCEPT, LOG, DENY, ...

iptables -N chain fügt eine neue Kette hinzu; mindestens sollten die Ketten INPUT und OUTPUT existieren
iptables -L listet die bestehenden Regeln; mit -nL werden die Regeln mit IP-Nummer statt DNS Namen gelistet

  To top of page

 


Der vi-Editor

Hat man bei der Administration eines Linux-Rechners nur einen Terminalzugang, so sind die komfortablen Editorenmit grafischer Oberflächer, wie pluma, gedit, u.ä. nicht nutzbar. Neben dem einfachen nano, gibt es dann immer noch den uralten vi.

Seine Steuerung ist mindestens gewöhnungsbedürftig, aber er bietet viele Möglichkeiten. Here you may find a list of the most important commands:

Start a vi Session

vi file Edit file
vi -r file Edit last saved version of file after System or editor crash
vi +n file Edit file and place Cursor at line n
vi + file Edit file and place Cursor on last line
vi file1 file2 Edit file1 and file2; After saving changes in file1, enter :n for next
vi +/str file Edit file and place Cursor at line containing str

Save Text and Exit vi

:wq or : x Save file and exit vi
:w file Save file but do not exit
:w! file Save file overriding normal checking
:q Leave vi, saving changes before last write (you may be prompted to save first)
:q! Leave vi without saving any changes since last write

Status Commands

: .= Print current line number
: = Print number of lines in file

Inserting Text

i input mode; insert before Cursor
a input after cursor
o Append after end of current line; new line
O Insert before beginning of current line
:r file Insert file at current position

To leave the insert mode, press ESC.

Undoing and Repeating Commands

u Undo last command
U Restore current line to original state
np Retrieve last nth delete (last 9 deletes are in a buffer)
1pu.u. Scroll through the delete buffer until you retrieve desired delete (repeat u.)
n Repeat last / or ? search command
N Repeat, in reverse direction, last / or ? search command
; Repeat last f F t or T search command
, Repeat, in reverse direction, last f F t or T search command
. Repeat last text change command

Moving the Cursor

k or | CTRL K~P~ Up
^ or Return Down
k Up
j Down
h or Backspace Left
l or Space Right
w or W Start of next word; W ignores punctuation
b or B Start of previous word; B ignores punctuation
e or E End of next word; E ignores punctuation
0 or | First column in current line
n| Column n in current line
^ First non-blank character in current line
$ Last character in current line
+ or Return First character in next line
- First non-blank character in previous line
1G First line in file
G Last line in file
G$ Last character in file
nG Line n in file
( Back to beginning of sentence
) Forward to beginning of next sentence
{ Back to beginning of paragraph
} Forward to beginning of next paragraph

Deleting text

nx Delete n characters beginning with current; omit-ting n deletes current character
nX Delete previous n characters; omitting n deletes previous character
xp Switch character at Cursor with following character
ndw Delete next n words beginning with current; omitting n deletes current word
ndb Delete previous n words; omitting n deletes previous word
ndd Delete n lines beginning with current; omitting n deletes current line
:n,md Delete lines n through m
db Delete word

Pattern matching

:set magic Allow pattern matching with special characters (default)
: set nomagic Allow only " and $ as special characters
^ Match beginning of line
$ Match end of line
. Match any single character
\< Match beginning of word
\> Match end of word
[str] Match any single character in str
[~str] Match any character not in str
[a-n] Match any character between a and n
* Match zero or more occurrences of previous character in expression
\ Escape meaning of next character (e.g., \$ lets you search for $)
\\ Escape the \ character

Indenting Text

:set ai Turn on auto-indentation
:set sw=n Set shift width to n characters

Searching

% Search to beginning of balancing ( ) [ ] or { }
fchar Search forward in current line to char
Fchar Search backward in current line to char
tchar Search forward in current line to character before char
Tchar Search backward in current line to character after char
/str +Return Find str
?str +Return Search in reverse for sfr
:set ic Ignore case when searching
:set noic Pay attention to case when searching (default)

Global Search and Replace

:n,ms/str1/str2/opt Search from n to m for str1. Replace str1 with str2, using opt. opt can be g for global change, c to confirm change (press y to acknowledge, Return to suppress), and p to print changed lines.
:n,ms/searchtext/newtext/g Replace searchtext by newtext between line n and m globally
:%s/searchtext/newtext/gc Replace searchtext by newtext everywhere with confirmation
& Repeat last search command
:g/str/cmd Run cmd on all lines that contain str
:g/str1/s/str2/str3/ Find line containing str1, replace str2 with str3
:v/str/cmd Execute cmd on all lines that do not match str

Copying and Placing Text

(a-z)nyy or (a-z)ndd Copy or delete n lines into named buffer; omit n for current line
nyy or nY Yank n lines (place in buffer); omitting n yanks current line
ycursor_cmd Yank from Cursor to cursor_cmd (e.g., yG yanks current line to last line in file)
p Put yanked text after Cursor (print buffer); also prints last deleted text
P Put yanked text before Cursor; also prints last deleted text
(a-z)p or (a-z)P Put lines from named buffer a through z after or before current line

Changing Text
Preceding these commands with a number n repeats the command n times.

rchar Replace current character with char
Rtext Replace current character(s) with text
stext Substitute text for current character
S or cc text Substitute text for entire line
cwtext Change current word to text
Ctext Change rest of current line to text

Joining Lines

J Join next line to end of current line
nJ Join next n lines

Cursor Placement and Adjusting the Screen

H Move Cursor to top line of screen
nH Move Cursor to line n from top of screen
M Move Cursor to middle of screen
L Move Cursor to bottom line of screen
nL Move Cursor to Line n from bottom of screen
 
z Return Make current line top line on screen
nz Return Make line n top line on screen
z. Make current line middle line
nz. Make line n middle line on screen
z- Make current line bottom line
nz- Make line n bottom line on screen

Shell Escape Commands

: ! cmd Execute Shell command cmd; you can add these special characters to indicate:
  % name of the current file
  # name of last file edited
: ! ! Execute last Shell command
: T ! cmd Read and insert Output from cmd
: f file Rename current file to file
: w ! cmd Send currently edited file to cmd as standard input and execute cmd
:cd dir Change the current working directory to dir ($HOME is default)
: sh Start a sub-shell (CTRL-d returns to editor)
: so file Read and execute commands in file (file is a Shell script)

 


Important files and processes in Linux OS

With the command  init n the system is put in differant states (only as super user).

init 0 ausschalten
init S single User mode
init 1 multi User ohne Netz
init 2 multi User mit Netz
init 3 multi User mit  Netz und GUI
init 4,5 unbenutzt
init 6 reboot
   
   
   

 Important files:

/etc/rc.local diese Startskripte werden als letztes ausgeführt
 /etc/inid.d/ dort befinden sich alle aktiven Startskripte
   
/etc/passwd Datei mit allen Usern des Systems
/etc/group Zuordnung der User zu Benutzergruppen
/etc/shadow Passwörter der User
/etc/sudoers Liste der User, die Rootrechte erhalten dürfen
/etc/fstab Liste der Geräte, die gemounted werden
/etc/hosts Liste bekannter Hosts, deren Namen nicht über DNS aufgelöst werden muss
/etc/services Zuordnung von Diensten und Portnummern (z.B. smtp 25 ...)

  To top of page


Tools for working with files from or for Open Street Map

Here we have listed some experiences we have found while making maps for Open Street Maps.

Our data to Open Street Map we have uploaded with josm, the Java Open Street Map Editor.

For splitting and merging of OSM-maps for Garmin GPS devices we used Garmin Mapper Tool  gmt :

  • Merging maps in img format.
  • Splitting files in img format into mapset, maps, subfiles of maps.
  • Installation of mapset for use with programs Mapsource, BaseCamp, HomePort.
  • Editing of map properties - map type, priority, transparency, name, creations date.
  • Map modifications - changing of labels case, removing national characters, replacing TYP files.

Maps for Garmin's Mapsource or for QT-Landkarte we made with MakeMap from OSM-maps, i.e. java -jar mkgmap-r3419/mkgmap.jar beispielkarte.osm

  • The Program produces tiles and *.tbl for QT-Landkarte
  • Without special typfiles the mapes are rather empty, no landscape, only ways.
  • There are several options, see java -jar mkgmap.jar --help=options

splitter.jar , the tile splitter for mkgmap

  • ... calculates objects for a Garmin-tile.

A good manual you will find herei http://stefan-felten.blogspot.de/2009/03/ganz-europa-als-openstreetmap-karte-auf.html

Who thinks that this is to complicate will find complete maps of all countries here

If you want buld your own navi with OSM Karten you need a RaspberryPi and:

  To top of page

 


... will be continued ...
Wir sind für Hinweise auf (Schreib-)Fehler sehr dankbar.

  To top of page


Category[40]: Anti-Überwachung Short-Link to this page: a-fsa.de/e/2un
Link to this page: https://www.aktion-freiheitstattangst.org/de/articles/5052-technische-hinweise-ii-linux-administration.htm
Link with Tor: http://a6pdp5vmmw4zm5tifrc3qo2pyz7mvnk4zzimpesnckvzinubzmioddad.onion/de/articles/5052-technische-hinweise-ii-linux-administration.htm
Tags: #TechnischeHinweise #Installation #Tools #Datenschutz #Verschluesselung #Linux #Administration #Befehle #Kommandos #Optionen
Created: 2014-03-27 16:12:04


Kommentar abgeben

For further confidential communication, we recommend that you include a reference to a secure messenger, such as Session, Bitmessage, or similar, below the comment text.
To prevent the use of this form by spam robots, please enter the portrayed character set in the left picture below into the right field.

We in the Web2.0


Diaspora Mastodon Twitter Youtube Tumblr Flickr FsA Wikipedia Facebook Bitmessage FsA Song


Impressum  Privacy  Sitemap