Linux

so Linux-Zeugs, das ich immer wieder vergesse, weil ich es doch nicht jeden Tag brauche, aber immer wieder…

  1. Linux Kleinzeugs
    1. ssh stuff
    2. users und so
    3. regex, sed etc.
    4. firewall
    5. garbage
    6. alternatives
    7. tcsh
    8. bash
    9. Partition resize in RHEL
  2. Docker Kleinzeugs
  3. keeping overview over the Linux System:
  4. legacy
    1. quick and dirty manual install of JDK 11 on Ubuntu 18.04

Linux Kleinzeugs

reset the screens (Trick Robert):

ctrl-alt-F7 ... ctrl-alt-F1 

history completition

ctrl-r 

tab-switcher behaviour

gsettings set org.gnome.shell.app-switcher current-workspace-only true

rpm on ubuntu:

alien -i bla.rpm

distribution:

cat /etc/*release*
lsb_release -a

Ubuntu full update:

update-manager -c -d

Kleinzeugs Netzwerk:

nmap -p 5000 172.30.1.1
[luna:~] rschumm% sudo nmap -PR 192.168.1.0/24 -sn

Kleinzeugs

watch -n 1 befehl 

ugo Zeugs:

r=4
w=2
x=1

quickshell:

bash -c 'for i in {1..110}; do mkdir "$i"; done' 

Login-Screen Ubuntu:

sudo vi /usr/share/gnome-shell/theme/ubuntu.css
Sektion lockDialogGroup 

zip, tar

zip -r zipFileNameOhneZip Ordner (packen)
unzip zipFileName.zip (entpacken)

tar -cvz Ordner -f tgzFileName.tgz (packen)
tar -xvzf tgzFileName.tgz (entpacken)

ssh stuff

quick scp

scp luna:file .     (copy file in home of luna to here)
scp file remy@kassandra: (copy file from here to home of kassandra)

use a special key for git clone

in .ssh/config

host companygit
    Hostname code.company.com
    IdentityFile ~/.ssh/long_19_id_rsa
    IdentitiesOnly yes

and then replace the hostame in the git url:

git clone git@companygit:team/myRepo.git

users und so

sudo useradd --create-home --groups sudo cloud-user
sudo passwd cloud-user

Bem: useradd nur für simple user, adduser sollte alles machen, inkl. home-dir. cf Cheat

sudo usermod -aG sudo cloud-user
userdel -r cloud-user

für .ssh Zeugs:

chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys

regex, sed etc.

echo 'hallo welt' | sed 's/welt/winterthur/'

firewall

RHEL etc.

firewall-cmd --list-all
firewall-cmd --zone=public --add-port=8080/tcp
firewall-cmd --zone=public --remove-port=8080/tcp
firewall-cmd --zone=public --list-ports

garbage

logs and caches:

sudo journalctl --vacuum-time=10d
sudo apt-get clean

alternatives

update-alternatives --list java
sudo update-alternatives --config java
update-alternatives --install ... 

update-alternatives --query mvn
to install:  --install <Link> <Name> <Pfad> <Priorität>
sudo update-alternatives --install /usr/bin/mvn mvn /home/rschumm/Software/apache-maven-3.6.0-bin/apache-maven-3.6.0/bin/mvn 100

to set JAVA_HOME: find out where Java is with: update-alternatives --config java, then, in .bashrc:

export JAVA_HOME="/usr/lib/jvm/jdk-11.0.2+9"

tcsh

set path = ($path $HOME/.gem/ruby/2.3.0/bin/ .)
set path = (/Applications/maven/apache-maven-3.6.3/bin $path:q)
setenv  M2_HOME /Applications/maven/apache-maven-3.x.x
alias mvn $M2_HOME/bin/mvn

alias 2x mit Parameter, einmal normal und einmal frei: 
alias studrepos java -jar /Users/rschumm/zhaw/1974/git/praktikumgit/target/praktikumgit.jar
alias heute 'curl -i  -H "Content-Type: application/yaml" -X POST http://localhost:8080/stunden/heute --data-binary @\!:1'
alias lösche 'curl -i -X DELETE http://localhost:8080/stunden/tag/\!:1'

alias reload source ~/.tcshrc

bash

export PATH="/home/rschumm/minis/minishift-1.18.0-linux-amd64/:$PATH"
echo $PATH
printenv

alias and such:

alias schummsync='rsync -vrtz _site/* xxx@xxx.xxx.hostpoint.ch:~/www/public_html/schumm/'

#function will be accessible just like an alias: 
open() {
    #open the explorer just like in macOS
    nautilus "$1" & 
}
#!/bin/bash

java Generator.java
#(needs JDK 11)

for file in $(find . -iname '*.yml'); do 
     echo "$file"
     #ls -l "$file"
     oc create -f "$file"
done

Partition resize in RHEL

Partition sda2 füllt nicht die ganze Disk, ich will sie auf das Maximumm vergrössern:

sudo su - 
fdisk /dev/sda

p

d

n

p

..dann auch alles default... 

w

reboot

xfs_growfs /dev/sda2

Docker Kleinzeugs

general

docker pull
docker login -u user -p token 

docker images
docker image ls
docker image rm 

garbage collect docker:

docker images 
sudo docker system prune -a

quick interact docker:

run a simple container (with a webapp inside)

rschumm@kassandra:~$ docker run -i --rm -p 8080:8080 schumm/mywebapp

run a new container (with interacting local data)

docker run -it --rm --entrypoint /bin/bash quay.io/quarkus/centos-quarkus-maven:graalvm-1.0.0-rc14

…with a local directory mounted as a volume, here e.g. /project (note: the local dir must be chmod o+w). This examples runs a source to build image and then starts the mvn build in this container.

docker run -it  --entrypoint /bin/bash --rm -v /home/rschumm/git/halloquarkus:/project quay.io/quarkus/centos-quarkus-maven:19.0.2
mvn clean verify -Pnative -DskipTests 

attach to an already running container

docker ps 
docker exec -it 91e /bin/bash

save a docker image as file:

rschumm@kassandra:~$ docker save -o schumm.tar schumm/myimage

keeping overview over the Linux System:

install Cockpit

Cockpit

legacy

quick and dirty manual install of JDK 11 on Ubuntu 18.04

n.b.: finally, in ubuntus jdk11 is also jdk11 inside like it’s «written on the box». So no need anymore for this.

update-java-alternatives -l | -s 
% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.2+9/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'

% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.2+9/bin/*; do update-alternatives --set $(basename $bin) $bin; done'

then choose the installation with update-alternatives --config java


zurück zum Seitenanfang