Linux - Snippets: Unterschied zwischen den Versionen
Aus Wikizone
(t) |
|||
| Zeile 36: | Zeile 36: | ||
== Prozesse == | == Prozesse == | ||
| + | === Top === | ||
| + | http://man.openbsd.org/top.1 | ||
| + | Prozesse auflisten | ||
top | top | ||
| + | top [-1bCHIinqSu] [-d count] [-g string] [-o [-]field] [-p pid] [-s time] [-U [-]user] [number] | ||
| + | |||
top -c -p $(pgrep -d',' -f string_to_match_in_cmd_line) | top -c -p $(pgrep -d',' -f string_to_match_in_cmd_line) | ||
| + | Filter by commandname: top -p expects a comma separated list of pids so we use -d',' in pgrep. The -f flag in pgrep makes it match the command line instead of program name. | ||
top -u [user] | top -u [user] | ||
| + | ==== Shortcuts für Top Interactive Mode ==== | ||
| + | <pre> | ||
| + | |||
| + | h | ? | ||
| + | Display a summary of the commands (help screen). | ||
| + | ^L | ||
| + | Redraw the screen. | ||
| + | <space> | ||
| + | Update the screen. | ||
| + | q | ||
| + | Quit top. | ||
| − | + | + | |
| + | Reset any filters put in place by the ‘g’, ‘p’, and ‘u’ interactive commands, or their command line equivalents, or any process highlighting put in place by the ‘P’ interactive command. | ||
| + | 1 | ||
| + | Toggle the display of per CPU or combined CPU statistics. | ||
| + | C | ||
| + | Toggle the display of process command line arguments. | ||
| + | d count | ||
| + | Show only count displays, then exit. | ||
| + | e | ||
| + | Display a list of system errors (if any) generated by the last kill or renice command. | ||
| + | g string | ||
| + | Display only processes that contain string in their command name. If displaying of arguments is enabled, the arguments are searched too. ‘g+’ shows all processes. | ||
| + | H | ||
| + | Toggle the display of process threads. | ||
| + | I | i | ||
| + | Toggle the display of idle processes. | ||
| + | k [-sig] pid | ||
| + | Send signal -sig (TERM by default) to process pid. This acts similarly to the command kill(1). | ||
| + | n|# count | ||
| + | Show count processes. | ||
| + | o [-]field | ||
| + | Sort the process display area using the specified field as the primary key. The ‘-’ prefix reverses the order. Values are the same as for the -o flag, as detailed above. | ||
| + | P pid | ||
| + | Highlight a specific process, selected by pid. ‘P+’ removes process highlighting. | ||
| + | p pid | ||
| + | Show only the process pid. ‘p+’ shows all processes. | ||
| + | r count pid | ||
| + | Change the priority (the nice) of a list of processes to count for process pid. This acts similarly to the command renice(8). | ||
| + | S | ||
| + | Toggle the display of system processes. | ||
| + | s time | ||
| + | Set the delay between screen updates to time seconds. | ||
| + | u [-]user | ||
| + | Show only those processes owned by username or UID user. ‘u+’ shows processes belonging to all users. The ‘-’ prefix hides processes belonging to a single user. | ||
| + | </pre> | ||
== Skripte == | == Skripte == | ||
Version vom 1. März 2019, 07:24 Uhr
User und Rechte
Als Superuser arbeiten
sudo su
oder
sudo [kommando]
Dateien
Linux - tar
Downloads mit cURL
http://www.thegeekstuff.com/2012/04/curl-examples/
Dateien komprimieren mit gz
Eine Datei komprimieren
gzip file
Ergbnis: file.gz
Datei dekomprimieren:
gunzip file
Dateien in einem komprimierten Archiv zusammenfassen:
tar cfvz archiv.tar.gz inhalt1 inhalt2
Ergebnis: archiv.tar.gz
Archiv dekomprimieren und auspacken:
tar xfvz archiv.tar.gz
Suchen und finden
ps ax | grep ssh ps aux | grep mysql
ls -altr
Prozesse
Top
http://man.openbsd.org/top.1
Prozesse auflisten
top top [-1bCHIinqSu] [-d count] [-g string] [-o [-]field] [-p pid] [-s time] [-U [-]user] [number]
top -c -p $(pgrep -d',' -f string_to_match_in_cmd_line)
Filter by commandname: top -p expects a comma separated list of pids so we use -d',' in pgrep. The -f flag in pgrep makes it match the command line instead of program name.
top -u [user]
Shortcuts für Top Interactive Mode
h | ?
Display a summary of the commands (help screen).
^L
Redraw the screen.
<space>
Update the screen.
q
Quit top.
+
Reset any filters put in place by the ‘g’, ‘p’, and ‘u’ interactive commands, or their command line equivalents, or any process highlighting put in place by the ‘P’ interactive command.
1
Toggle the display of per CPU or combined CPU statistics.
C
Toggle the display of process command line arguments.
d count
Show only count displays, then exit.
e
Display a list of system errors (if any) generated by the last kill or renice command.
g string
Display only processes that contain string in their command name. If displaying of arguments is enabled, the arguments are searched too. ‘g+’ shows all processes.
H
Toggle the display of process threads.
I | i
Toggle the display of idle processes.
k [-sig] pid
Send signal -sig (TERM by default) to process pid. This acts similarly to the command kill(1).
n|# count
Show count processes.
o [-]field
Sort the process display area using the specified field as the primary key. The ‘-’ prefix reverses the order. Values are the same as for the -o flag, as detailed above.
P pid
Highlight a specific process, selected by pid. ‘P+’ removes process highlighting.
p pid
Show only the process pid. ‘p+’ shows all processes.
r count pid
Change the priority (the nice) of a list of processes to count for process pid. This acts similarly to the command renice(8).
S
Toggle the display of system processes.
s time
Set the delay between screen updates to time seconds.
u [-]user
Show only those processes owned by username or UID user. ‘u+’ shows processes belonging to all users. The ‘-’ prefix hides processes belonging to a single user.
Skripte
Datenbank sichern
#!/bin/bash
DATUM=`date +%d.%m.%Y_%a%H-%M`
MYSQLPATH=/usr/bin/
DBUSER=diensthandyadm
DBNAME=diensthandy
DBPASS=MeinPasswort
BACKUPDIR="/serv/www/diensthandy.dekra.com/bak/db"
# dump database
#/usr/bin/mysqldump --all-databases -u diensthandyadm -pMeinPasswort > $BACKUPDIR/"diensthandy_$DATUM.sql"
${MYSQLPATH}mysqldump $DBNAME -u $DBUSER -p${DBPASS} > ${BACKUPDIR}/${DBNAME}_${DATUM}.sql
/bin/gzip ${BACKUPDIR}/"${DBNAME}_${DATUM}.sql"
# delete older
find $BACKUPDIR -type f -mtime +4 -exec rm {} \;
Backup Skript
#!/bin/bash ############################################################################### # Skript legt ein Backup der aktuellen Dateien im webverzeichnis an # und holt sich eine neue Version vom Produktivserver ############################################################################## datum=`date` BACKUPDIR="/serv/www/diensthandy.dekra.com/bak" WEBDIR="/serv/www/diensthandy.dekra.com/data" ADMINMAIL="schlegel@geo-bit.de" BETREFF="DEKRA Diensthandy - Produktivserver Kopie" # Webdateien verschieben/sichern (alte Kopie löschen) #rm -rf $BACKUPDIR/data/* #mv $WEBDIR/* $BACKUPDIR/data/ #echo "--- Webverzeichnis gesichert ---" # Kopie von Produktivserver holen # scp -r schlegel@212.9.188.227:/serv/www/diensthandy.dekra.de/data/* $WEBDIR/. # echo "--- Kopie von Produktivserver geholt ---" # Config-zurückspielen cp $BACKUPDIR/data/includes/configure.php $WEBDIR/includes/ cp $BACKUPDIR/data/admin/includes/configure.php $WEBDIR/admin/includes/ echo "--- Konfigurationsdateien kopiert ---" # Cache Verzeichnisse löschen rm -rf $WEBDIR/cache/* rm -rf $WEBDIR/templates_c/* # Rechte anpassen chmod 775 -R $WEBDIR/* chmod 777 -R $WEBDIR/cache chmod 777 -R $WEBDIR/templates_c chmod 444 $WEBDIR/includes/configure.php chmod 444 $WEBDIR/admin/includes/configure.php echo "--- Rechte angepasst ---"