Skip to content

Links for journalctl

Links for journalctl published on No Comments on Links for journalctl

Allgemeine Infos zu journalctl:
https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs

journalctl -u tomcat7.service

Speichereinstellung für das Journal ändern

Quelle ubuntuusers.de
Wie (und ob) das Journal gespeichert wird, wird über den Wert des Schlüssels Storage geregelt. Unter Ubuntu ist der Standardwert auto. Dabei wird die Journal-Datei im Verzeichnis/run/log/UUID_DES_VERZEICHNISSES/ angelegt und geht nach dem Herunterfahren des Systems verloren.

Damit die Journaldateien - und damit alle Logs - für längere Zeit gespeichert werden, gibt es zwei Möglichkeiten:

  • Man legt das Verzeichnis /var/log/journal/ an. Nach dem Neustart des Systems wird die Journal dort gespeichert und bleibt somit auch nach einem Neustart des Systems bestehen.
  • Man ändert in der Konfigurationsdatei den Wert die Zeile
    Storage=auto
    auf
    Storage=persistent

Nach einem Neustart des Systems wird der Ordner /var/log/journal/ automatisch angelegt und das Journal wird dort dauerhaft gespeichert.

Randomized collection of useful linux commands

Randomized collection of useful linux commands published on No Comments on Randomized collection of useful linux commands

Cut some rows
cut -d " " -f2-4 messages

with tee we drop shit in a file and in stdout
grep kernel /var/log/messages | tee /root/my.log

with xargs we give in this expample the command host the output line by line:
cut -d " " -f1 localhost_access_log.2014-11-19.txt | sort | uniq | xargs -n1 host

ps -C tail
ps and show all processes of the program tail

pstree -pna
-p = show PID
-n = sort by PID
-a = shows options and arguments

top -bi -d 1 > file.txt
-b = batch mode to put it in a file
-i = show only the active ones
-d 1 = every 1 sec
Like that the file.txt has every second the active processes in top

kill -l shows you all available signals you can send to the process
1) SIGHUP: Hang-up-signal, for daemons to reload their config
9) SIGKILL: to kill the process
15) SIGTERM: to terminate the process
other
2) SIGINT: like Ctrl+C, but much more fun
18) SIGCONT: continue processes which are put in the background with bg and fg (or with 19)
19) SIGSTOP: bg, but also much more fun
20) SIGSTP: like ctrl+z.

with w we see the logged in users

Notes for 103.3 and nice to know

Notes for 103.3 and nice to know published on No Comments on Notes for 103.3 and nice to know

Change time stamp of a file:
touch -t YYYYMMDDhhmm.ss myfile
 
show full time stamp
ls -la --time-style=full-iso myfile

wildcards

? = replace one char
* = replace 0 or x chars
[a-z] = replace one char in the specified range
[abcde] = replace one char of the specified characters
[!a-z] = replace one char NOT in the specified range

tar

Not well known options
t = list
tar tzf salami.tar.gz

zipping the shit out of the files

gzip -c myfile.txt > myfile.txt.gz creates a myfile.txt.gz and does not delete the original myfile.txt
gzip -l myfile.gz lists the content of myfile.gz

decompress with:

  • gzip -d
  • gunzip
  • zcat

bzip2 has usually better compress rate. It uses the same parameters.
decompress with:

  • bzip2 -d
  • bunzip
  • bzcat

cpio

extract files out of archives
cpio -i | --extract = copy in mode; copy from archive in file system
cpio -o | --create = copy out mode; copy files into the archive
cpio -p | --pass-throughno archive, all files of stdin into a dir

backup all ods in home to backup
find /home/ -name *.ods | cpio -pd /backup

-d = creates directories

dd

backup mbr
dd if=/dev/sda of=mbr.backup ibs=512 count=1

file myfile.sh shows the type of the file

Notes for 103.2

Notes for 103.2 published on No Comments on Notes for 103.2

expand x.txt > y.txt replace TAB by spaces
nl x.txt cat with line number
uniq x.txt remove duplicates
split -l 11000 -d catalina.out salami_ split catalina.out evere 11000 lines to a file salami_nn (-d is for numeric file number)
cut -f2 tabulator.txt cut columns 2
paste x.txt y.txt merge two files by column
join -j like paste with "sql like" join on a common key
cat x.txt | tr Q P replace Q by P in x.txt
cat x.txt | tr a-z A-Z lower case to upper case
[:lower:] possible as an argument of tr