From 5a80ca3e2bfae7b13dd0cd14d41af9c09925a22d Mon Sep 17 00:00:00 2001 From: Luiza Date: Tue, 14 Nov 2023 13:10:15 +0000 Subject: [PATCH] Add 'Linux.adoc' --- Linux.adoc | 852 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 852 insertions(+) create mode 100644 Linux.adoc diff --git a/Linux.adoc b/Linux.adoc new file mode 100644 index 0000000..237b3b3 --- /dev/null +++ b/Linux.adoc @@ -0,0 +1,852 @@ += Linux at Roche +Luiza Kuźma +:icons: font +:toc: + + +== New Installation + +* Copy +** your notes +** your pictures and folders +** bash history +** bookmarks!!! +** gvimrc +** snap list +** apt list + +== Dell XPS 13 + + +=== Others + +jetbrains@ -> 3x (keyring) +keyring -> 3x (keyring) +wallet4kde -> 3x -> kde 4x + + +==== GitLab + +https://docs.gitlab.com/ee/ssh/ + +* nie używaj hasła do certyfikatu bo będzie się Ciebie pytał po 3x przy każdym pushu.... + +---- +cd +cd ./ssh + +ssh-keygen -t ed25519 -C "" +ssh-keygen -t ed25519 -C "Dell_on_Gitlab" +---- + + + +=== GNOME (ubuntu) 22 + +==== Programming installations + +* Flyway 6.5.5 +** https://code.roche.com/pdil/snowflake/snowflake/-/package_files/167350/download[Roche repo for Flyway] +** sudo cp -r flyway /usr/local/bin/flyway_6_5_5 +** sudo ln -s /usr/local/bin/flyway_6_5_5/flyway /usr/local/bin/flyway + +==== System Installations + +* apt update +* apt upgrade +* IntelliJ +** Toolbox: +*** sudo tar -xzf jetbrains-toolbox-1.21.9712.tar.gz -C /opt +* openJDK 11 +** sudo apt install default-jre +** sudo apt install default-jdk +** szukanie lokalizacji JDK +*** /usr/lib/jvm/java-11-openjdk-amd64 +*** sudo update-alternatives --config java +*** Problem: IntelliJ nie bierze tego jdk - bierze z katalogu: default.... +* Extensions - rozszerzenia gnome +** gnome-shell +*** sudo apt gnome-shell +** gnome-shell-extension +*** sudo apt install gnome-shell-extensions +** gnome-shell-extension-manager +*** sudo apt install gnome-shell-extenstion-manager +* pulpity +** sudo apt install gnome-tweaks +** pulpit dzielony na 4 -> extension do "gnome-tweaks" +*** sudo apt install gnome-shell-extensions +* Now you will need to restart the Gnome shell. +** Hit Alt+F2 keyboard shortcut and then type r and hit Enter to do so. +* Changing brightness in screen: XPS 9300 Ubuntu & Adaptive Brightness changing all the time +** I have a XPS 13 9300 shipped with Ubuntu 18.04 by Dell. The adaptive brightness can be disabled from: +*** Settings => Power => Automatic brightness + +* Michał Kalinowski Terminal: guake +https://overflow.roche.com/t/i-cannot-connect-to-wifi-on-my-dell-xps-9310-what-should-i-do/6739 + +=== GNOME (ubuntu) 20 - Problems on Dell + +* WiFi + blutooth +** https://overflow.roche.com/t/i-cannot-connect-to-wifi-on-my-dell-xps-9310-what-should-i-do/6739/7 +*** git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git +*** sudo cp -r linux-firmware/ath11k /lib/firmware/ + +===== External Display is not visible + +* gnome does not see external display +* trying to fix it +** sudo apt-get install kubuntu-desktop +** it didn't help +*** on my home computer I have KDE as a windows and external screen works with HP computer (also Ubuntu 20th) + +* idea to check +** in the office with the external screen + +===== No visible Blutooth + +* at least in gnome +** and little ports to use + + + +Default RLC at GNOME (ubuntu) working with + +==== Multiple workspaces with many monitors + +sudo apt install gnome-tweaks + +* przełączanie +** Super + Pg Up / Pg Down +** OR +** Ctrl + Alt + Arrow Up / Arrow Down +* przenoszenie okna między workspace'ami +** Super + Schift + Page Up/Down +* podzał ekranu na 4 - opcje: winTile, gTile, ShellTile, +** WinTile +*** Super + strzałka (to przy podziale na 4 -> jak pod Windows) +*** icon:minus[] nie działa dla Ubuntu 22 +** ShellTile +*** icon:minus[] nie działa dla Ubuntu 22 +** Ubuntu 22 +*** Tiling Assistant (GitHub) +**** https://askubuntu.com/questions/1460962/view-split-on-top-bottom-in-ubuntu-22-04[Instruction] +*** Quater Windows +*** Tactile +**** https://fostips.com/two-more-apps-side-by-side-ubuntu-22-04/[] + +==== Quater Windows + +https://github.com/troyready/quarterwindows[Shortcuts] + +Overview +This extension adds shortcuts for window management. + +Shortcuts +Move window to upper right ("northeast") corner: Ctrl + Win + i +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-corner-ne "['i']" +Move window to upper left ("northwest") corner: Ctrl + Win + u +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-corner-nw "['u']" +Move window to lower right ("southeast") corner: Ctrl + Win + k +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-corner-se "['k']" +Move window to lower left ("southwest") corner: Ctrl + Win + j +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-corner-sw "['j']" +Move window to upper half: Ctrl + Win + UpArrow +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-half-n "['Up']" +Move window to bottom half: Ctrl + Win + DownArrow +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-half-s "['Down']" +Move window to right half: Ctrl + Win + RightArrow +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-half-e "['Right']" +Move window to left half: Ctrl + Win + LeftArrow +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/put-to-half-w "['Left']" +Move window focus to the left ("west"): Shift + Win + h +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/move-focus-w "['h']" +Move window focus down ("south"): Shift + Win + j +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/move-focus-s "['j']" +Move window focus up ("north"): Shift + Win + k +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/move-focus-n "['k']" +Move window focus to the right ("east"): Shift + Win + l +Can be customized via: dconf write /org/gnome/shell/extensions/com-troyready-quarterwindows/move-focus-w "['l']" +Determining Shortcut Keys +An easy way to determine custom shortcut key values is to: + +Watch for dconf changes by opening a terminal and running dconf watch / +Set a temporary custom GNOME shortcut (Settings -> Keyboard -> View and Customize Shortcuts -> Custom Shortcuts) +The dconf command will display the chosen shortcut keys. Delete the shortcut and use the displayed shortcut in the above customization commands. + +==== gnome-shell + +* gnome-shell --version +* install extension manually from zip +** e.g. wintile +*** przykład na innym extension: +**** https://linuxconfig.org/install-gnome-shell-extensions-from-zip-file-using-command-line-on-ubuntu-20-04-linux +*** unzip -C wintilenowsci.com.v7.shell-extension.zip metadata.json | grep uuid | cut -d \" -f4 wintile@nowsci.com +*** mkdir -p ~/.local/share/gnome-shell/extensions/wintile@nowsci.com +*** unzip -q wintilenowsci.com.v7.shell-extension.zip -d ~/.local/share/gnome-shell/extensions/wintile@nowsci.com +*** gnome-extensions enable wintile@nowsci.com +*** In order for the changes to take effect, you’ll need to restart the GNOME shell. The quickest way of doing so is: +**** to press Alt+F2 on your keyboard, type r, and then press enter. + +===== Paint pod Gnome + +* pod gnome za maleńkie ikonki (i nie dało się tego poprawić) +** Pinta +** xpaint +** KolourPaint +* pod gnome działały (ikony do rozczytania) ale trudne i skomplikowane programy: +** Krita +** MyPaint +* rozwiązanie +** kUbuntu Plasma <=> KDE - KolourPaint ma normalne ikony + +=== KDE - Ubuntu 20 + +* nie działał ekran startowy - doinstalowywałam +* języki - tutaj uwaga: +** System Settings -> Regional Settings +*** Language - MUSI zostać angielski inaczej CAŁY SYSTEM linux będzie po polsku +*** Formats +**** Region: Polska - ustawienia w KDE i komunikaty systemowe są po polsku +**** Region: MUSI zostać angielski inaczej CAŁY SYSTEM linux będzie po polsku +**** Detailded Settings: Jednakże ustawienia szczegółowe można przestawić na "Polska", nie wpływają na język systemu +***** Numbers, Time, Currency, Measurement Units, Collation and Sorting +* wylogowywanie przez Ctrl+Alt+Del +** Global Shortcuts +* dodanie sztywnych wirtualnych desktopów +** System Settings -> Virtual Desktops (moża podpisać i uzgodnić ułożenie - czy rząd czy tablica) +* gVim - doinstalowałam +** etc/vim/gvimrc +*** colorscheme desert +*** colorscheme slate +*** colorscheme torte +** these settings seems to be not necessary under Linux +*** set langmenu=en_US +*** set nocompatible +*** set nu +*** set guifont=Monospace:h13 +* Zegar na pasku +** Event Calendar widget - skonfigurowany pode mnie +** wygląda dobrze tylko jeśli taskbar jest u dołu +* Restore previous session - jest domyślny w KDE +* System Settings -> Screen Edges +** aka hot corners +** podłączanie różnych przydatnych zachowań pod "gorące punkty" +** można też dodać dzielenie ekranu na 4 ale to działa nie dla "ekranu" ale dla całego workspace +* podział ekranu na 4 w rogach +** Global Shortcuts -> kWin użycie i podpięcie pod akcje skrótów (te się sprawdzają i są intuicyjne - z Windows???) +*** Quick Tile Window to the Bottom Left : Meta+Ctrl+Left +*** Quick Tile Window to the Bottom Right : Meta+Ctrl+Down +*** Quick Tile Window to the Top Left : Meta+Ctrl+Up +*** Quick Tile Window to the Top Right : Meta+Ctrl+Right +* inny sposób prezentacji menu +** oryginalnie jest: Application Launcher +** doinstaluj Widget: Applicatin Dashboard przypięty do taskbara +*** Application Dashboard <=> A fullscreen application launcher + +* Mouse Whell - Scroll desktop (on desktop) +** you can redefine or remove this action in +*** Right click on desktop -> Configure Desktop -> Mouse Actions -> Vertical-Scroll -> minus button on the right +* Przemieszczanie okien między desktopami +** System Settings -> Workspace Behavior -> Screen Edges -> Switch desktop on edge: Only When Moving Windows + +=== Java Developer + + +==== Błędy w IntelliJ z opisem + +* po zainstalowaniu java + mvn przez sudo apt +** openJDK 11 +*** sudo apt install default-jre +*** sudo apt install default-jdk +*** szukanie lokalizacji JDK +**** /usr/lib/jvm/java-11-openjdk-amd64 +**** sudo update-alternatives --config java +***** możesz wybrać interakcyjnie wersję javy +**** Problem: IntelliJ nie bierze tego jdk - bierze z katalogu: default.... + +Czerwone w konsoli + +---- +/usr/lib/jvm/default-java/bin/java -Dmaven.multiModuleProjectDirectory=/home/users/kuzmal/IdeaProjects/roche-oauth2-spring -Dmaven.home=/usr/share/maven -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.ext.class.path=/home/users/kuzmal/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5457.46/plugins/maven/lib/maven-event-listener.jar -javaagent:/home/users/kuzmal/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5457.46/lib/idea_rt.jar=46707:/home/users/kuzmal/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/212.5457.46/bin -Dfile.encoding=UTF-8 -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar org.codehaus.classworlds.Launcher -Didea.version=2021.2.3 clean +WARNING: An illegal reflective access operation has occurred +WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) +WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 +WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations +WARNING: All illegal access operations will be denied in a future release +---- + +https://github.com/google/guice/issues/1216 + +@alan-hwp are you using Ubuntu's custom distribution of Maven? The official Maven distribution uses the "no-AOP" build of Guice which doesn't contain any CGLIB code. If you download an official distribution from https://maven.apache.org/ then you shouldn't see the warning. + +==== Reinstalacja mavena + +* Skonfiguruj java +** https://help.ubuntu.com/community/EnvironmentVariables +*** /etc/profile.d -> java-maven.sh +**** export JAVA_HOME=/usr/lib/jvm/default-java +**** export PATH=$PATH:$JAVA_HOME/bin +* Skonfiguruj maven +** https://maven.apache.org/install.html +** https://www.rosehosting.com/blog/how-to-install-apache-maven-on-ubuntu-20-04/ +** ja umieściłam maven tam gdzie java: /usr/lib/jvm +*** i dodałam do /etc/profile.d -> java-maven.sh +**** export M2_HOME=/usr/lib/jvm/apache-maven-3.8.4 +**** export MAVEN_HOME=/usr/lib/jvm/apache-maven-3.8.4 +**** export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin + +Ostatecznie plik java-maven.sh wygląda + +---- +export JAVA_HOME=/usr/lib/jvm/default-java +export M2_HOME=/usr/lib/jvm/apache-maven-3.8.4 +export MAVEN_HOME=/usr/lib/jvm/apache-maven-3.8.4 +export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin +---- + +* sudo chmod +x java-maven.sh +* wykonaj ten plik przez: +** source java-maven.sh + + + +== Roche Linux RLC configuration + + +=== Pulse Secure Snowflake problem + +https://overflow.roche.com/t/unable-to-connect-to-snowflake-due-to-blocked-ip/7501/8[Roverflow: Unable to connect to Snowflake due to blocked IP] + + +Manual adding any domain you want to tunneling using script delivered by @kravvcu . In my case it was domain suitable for SnowFlake. +Download the script from this link 1 or directly from @kravvcu post. (it is located in our Roche GitLab) + +==== Preparations - one time preparations + +* location +** ./Projects/PDIL/routes_lk +** ./Projects/PDIL/routes_oryg +* Edit script and add your domain. In my case it was changing DOMAINS variable + + from: DOMAINS=( domain.one.roche.com domain.two.roche.com ) + to: DOMAINS=( roche_pd.eu-central-1.snowflakecomputing.com ) + +* Add executable to the file routes (chmod u+x) + +==== VPN connection with SF + +* Connect to your VPN gateway, whichever you want +* Run the script ./Projects/PDIL/routes_lk +* It will produce two commands, which you execute on your own. +** In my case it was such commands (the ip address depends on gate, to which you are connected to): + +---- +sudo ip route add 3.65.82.225 via 10.143.136.153 dev tun0 metric 1; +sudo ip route add 3.120.160.121 via 10.143.136.153 dev tun0 metric 1; +---- + +* enjoy connection to SnowFlake… + +=== Pulse Secure hanging problems + + +==== Skorzystałam z takich poleceń od Zbyszka: + +sudo systemctl restart pulsesecure.service +sudo systemctl restart NetworkManager + + + +==== Zbigniew Grzybek, 7 min + +ja uzywam takich komend jak mi sie pulse wykrzaczy + +---- +sudo cp /etc/resolv.conf_back /etc/resolv.conf +sudo systemctl restart pulsesecure.service +sudo systemctl restart NetworkManager +---- + +i pozniej do laczenia: + +---- +/opt/pulsesecure/bin/pulselauncher -U rbapulse.range.roche.net/rlcaas-cert -r EMEA -c /home/users/grzybekz/.pulsesecure/pulse/certificates/grzybekz.pem -u grzybekz +w /etc/resolv.conf_back mam taki wpis (ale tutaj mozesz miec inny): + +# Generated by NetworkManager +search localdomain +nameserver 192.168.86.2 +---- + +=== FollowMe Printer + +https://overflow.roche.com/t/how-to-install-followme-printer/446/14[Roverflow How to install FOLLOWME printer?] + +lpadmin -p FollowMe_Warsaw -E -v lpd://rwamsmps.emea.roche.com/Warsaw_FollowMe -m foomatic-db-compressed-ppds:0/ppd/foomatic-ppd/Xerox-WorkCentre_7345-pxlcolor.ppd && lpadmin -p FollowMe_Poznan -o PageSize=A4 -o printer-is-shared=false creates=/etc/cups/ppd/FollowMe_Warsaw.ppd + + +==== Add person to the group lpadmin + +===== It works! + +https://askubuntu.com/questions/964040/usermod-says-account-doesnt-exist-but-adduser-says-it-does[Overflow description] + +---- +Just do this: + +sudo vim /etc/group +and add your name to the desired group, like: + +somegroup:x:25:yourusername +---- + +However, the commands: + +groups + +id + +do not return lpadmin group but I am able to play with the printer. + + + +===== It DOESN'T WORK + +[source,shell] +---- +sudo usermod -a -G group1,group2 username +---- + +I am getting the message: + +---- +kuzmal@rwauwprlc0049:/etc$ sudo usermod -a -G lpadmin kuzmal +usermod: user 'kuzmal' does not exist +---- + +==== Add printer driver + +* trying with ppd +** https://frameboxxindore.com/linux/quick-answer-how-install-ppd-file-in-ubuntu.html[Quick Answer: How install PPD file in Ubuntu?] + + +https://www.support.xerox.com/en-us/product/workcentre-7328-7335-7345-7346/downloads?platform=linux&language=en[Xerox WorkCentre 7345 Foomatic/pxlcolor] + +=== Change Password + +https://roche.service-now.com/rose?id=ticket&table=incident&sys_id=21e728131b6991947a7d99baab4bcb28[RoSE ticket] + +==== Roverflow + + +* Planowane pytanie do Roverflow +** https://overflow.roche.com/t/how-does-one-change-the-password-on-rlc/9803/14 +** 2023-02-23 + +Hi @Mihajlo_Joksimovic, +I have similar issue (probably) as @Daniel_Sabanes_Bove: +* I changed my password in CIDM, +* I was many times in the office working after this change +* I changed the disc encription password but... + +my Ubuntu 20 still wants my previous domain password to log-in and all admin/sudo actions require previous domain password. +I had some tickets done in SNOW but it hasn't change + + + +* cidm +** it does not change password in Linux +*** for disc encription, use this cmd: +**** sudo /usr/sbin/rlcaas-roche-luks-key-changer +*** for system (login + sudo) +**** login into RCN inside the Roche Infrastructure (Roche Network in the office) +**** try restarting the centrifydc service: +***** “sudo systemctl restart centrifydc.service” --> Roverflow +***** "systemctl restart centrifydc" --> RoSE ticket +***** Then the cache should actually be deleted and recreated with the new use. +*** check the Centrify status with command "adinfo" + +---- +kuzmal@rwauwprlc0049:~$ adinfo +Local host name: rwauwprlc0049 +Joined to domain: emea.roche.com +Joined as: rwauwprlc0049.emea.roche.com +Pre-win2K name: rwauwprlc0049 +Current DC: +Preferred site: ADS-CH-BaselKaiseraugst +Zone: emea.roche.com/Zones/EMEA_RLC-Clients-Global +CentrifyDC mode: disconnected +Licensed Features: Enabled +---- + +I am in the office today and try to finalize the issue. +I did: + adinfo +and got "disconnected". +Then I did: + sudo systemctl restart centrifydc.service +and afterwards: + adinfo +and... I still have "disconnected". + + +---- +kuzmal@rwauwprlc0049:~$ ip a +1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: wlp114s0: mtu 1500 qdisc mq state UP group default qlen 4096 + link/ether 9c:b6:d0:3f:67:80 brd ff:ff:ff:ff:ff:ff + inet 10.144.57.216/23 brd 10.144.57.255 scope global dynamic noprefixroute wlp114s0 + valid_lft 592132sec preferred_lft 592132sec + inet6 fe80::9eb6:d0ff:fe3f:6780/64 scope link noprefixroute + valid_lft forever preferred_lft forever +3: enxd037454c1936: mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 + link/ether d0:37:45:4c:19:36 brd ff:ff:ff:ff:ff:ff +4: enx80ce6278ff02: mtu 1500 qdisc fq_codel state UP group default qlen 1000 + link/ether 80:ce:62:78:ff:02 brd ff:ff:ff:ff:ff:ff + inet 10.144.52.165/24 brd 10.144.52.255 scope global dynamic noprefixroute enx80ce6278ff02 + valid_lft 595157sec preferred_lft 595157sec + inet6 fe80::a602:9255:669f:de9d/64 scope link noprefixroute + valid_lft forever preferred_lft forever +kuzmal@rwauwprlc0049:~$ +---- + + + + +== Problems + +=== Unblocking screen-saver or hanging log-in console + +* it was displayed during the screen-saver collapsed +* "The screen locker is broken and unlocking is not possible anymore. In order to unlock" +** switch to a virtual terminal (e.g. Ctrl+Alt+F2) +** log in +** execute the command: +*** loginctl unlock-session 3 +** switch back to the running session +*** Ctrl+Alt+F1 + + +== Tools + +=== Screen recorders + +* simplescreenrecorder - czerwone rogi a w środku czerwona kropka +** nie łapie dźwięku z youtube - przypuszczam, że i ze spotkania +* vokoscreenNG +** albo rwie dźwięk +** albo ekran nieruchomo +** trudno wymusić mikrofon + + +=== Installers + +* gem +** asciidoctor-diagram +** asciidoctor-pdf +* apt +* snap + +=== Ciekawe - do rozważenia + +* Zajętość dysku, rozmiary katalogów, wieloplatformowe, wizualne obrazowanie +** https://www.linuxlinks.com/k4dirstat/[K4DirStat] + +=== Paint alternatives + +* do sprawdzenia +** mtpaint +** Pinta +** xpaint +** KolourPaint +*** taki sobi +* trudne programy (działały też pod gnome - ikony do rozczytania): +** Krita +** MyPaint +** ale oba nie biorą prosto ze schowka + + + +=== Doublecmd + +sudo apt-get install doublecmd-gtk + +=== ImageMagic - ubuntu picture conversions + +* Carefully!!! - resize with keep aspect ratio - icon:exclamation-triangle[] but it substitute pictures +** do it on YOUR COPIES of pictures +** it does for ALL picture in the directory + + # 4k + mogrify -resize '1920x1080^' *.JPG + # FullHD + mogrify -resize '1920x1080^' *.JPG + + +=== Profiles + +==== Create env variables + +---- +# Global env variables +/etc/profile +/etc/profile.d -> put your own file + +# Local env variables +/home/.../.profile -> or .bash_profile or .bash_login +---- + +https://www.baeldung.com/linux/environment-variables[Env variables] + +With Bash, we declare global variables in /etc/profile. But, we recommend declaring them in their own script files and putting those in /etc/profile.d. Bash will automatically pick these up. + +Global variables affect all users in the system. Each user can create a set of “global” environment variables for their own by creating ~/.profile in their home directory. + +==== Load profile + +source .profile + + +== Commands + +=== Counting string appearance + +==== json + +* directly in Postman +* vi counts only till 99 (so e.g. 7844 will not display, sth like this: >99) +* use with wc, wc -l -> counts number of lines + +---- +# counting the number of attributes on the given level +jq '.item | length' 2023_05_12_Substance_PROD_Active_and_Deleted.json +jq '.item[].hubStateInd' 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json | wc -l +---- + +---- +grep -o -i hubStateInd\"\:1 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json | wc -l +---- + +* jq is more about structure of json + +---- +jq '.item[] | .hubStateInd' '2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json' | wc -l +jq '.item[].hubStateInd' 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json | wc -l +---- + +* jq select element with hubStateInd=-1 +---- +jq '.item[] | select (.hubStateInd==-1)' 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json +---- + +* count all elements, which have on the 1st level of a table hubStateInd=1 or -1 (to avoid counting children) +---- +jq '.item[] | select (.hubStateInd==-1)' 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json | jq '.hubStateInd' | wc -l +212 +jq '.item[] | select (.hubStateInd==1)' 2023_05_12_Substance_PROD_Active_and_Deleted_and_Pending.json | jq '.hubStateInd' | wc -l +7787 +---- + + + +* https://stedolan.github.io/jq/[jq documentation] +* https://gist.github.com/barbietunnie/e694d8a8b3f5fd895829e44e7b2c42eb[jq Tips] + +=== Useful commands + +* whereis +* Environment variables +** printenv +* port in use +** sudo lsof -i:22 +** sudo lsof -i:8443 +** https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/ + +=== Find / Grep + +==== Sum-up of useful find: + +[source,shell] +---- +find . -type f -name *Mongo* +find / -name rlcaas-roche-luks-key-changer 2>/dev/null +find ./ -type f -name *.adoc -exec grep --include=\*.adoc -ilnw "Applause" {} \; +---- + + +==== Description of problems + +https://stackoverflow.com/questions/22552538/grep-warning-recursive-directory-loop[Problem and solution description] + +grep --include=\*.adoc -irnw "devcopse" / + +[source,log] +---- +grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/testing/ocean/monday: recursive directory loop +---- + +You have to exclude symbolic links from your grep, they are reason of this warning. You should try to use find firstly: + +find ./ -type f -exec grep -il "blah_blah_text" {} \; + +When you use find firstly you can omit -r in grep, because find is already recursive. + + +find ./ -type f -exec grep --include=\*.adoc -ilnw "security" {} \; + +=== Grep + +* https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux[grep] +** redirect warnings/errors to null: +*** 2>/dev/null + +[source,shell] +---- +grep --include=\*.adoc -irnw "devcopse" /home/users/kuzmal +fgrep --include=\*.adoc -irnw "security" /home/users/kuzmal + +# with 2>/dev/null +grep --include=\*.adoc -irnw "devcopse" /home/users/kuzmal 2>/dev/null +fgrep --include=\*.adoc -irnw "security" /home/users/kuzmal 2>/dev/null + +---- + + + +=== History + +* history +* history | grep env +* !760 - execute command no 760 +* history -d - remove command from history (e.g. sensitive data) + + +=== Info about user / profile /system + +[source,bash] +---- +cat << EOF +* Username: "${USER}" +* Hostname: "${HOST}" +* Site: $(grep 'site=' /etc/rlc-systeminfo | cut -d ' ' -f2) +* OS Version: (`cat /etc/os-release`) +* Kernel Version: (`uname -a`) +EOF +---- + + +=== Od Tomasza Marciniaka + + +==== Ctrl+C, Ctrl+V + + stty -a + stty intr ^J + + + +==== Pictures - exiftool + + exiftool img1.jpg + exiftool -all= img1.jpg + + + +==== Pictures - ImageMagick + + convert -resize 25% img1.jpg img2.jpg + identify -verbose m.jpg + + + +==== Video + + ffmpeg -i infile -vf "scale=iw/2:ih/2" outfile + ffmpeg -i infile -vf "scale=iw/2:ih/2" -b:v 150k outfile + ffmpeg -i infile -vf "scale=iw/4:ih/4" -b:v 140k -b:a 64k outfile + + + +==== Memory + + free -g / free -m + top -o %MEM + top -> f -> up/down -> s -> q (sort by something) + top -> e/E (units) + + + +==== X + + xdg-open https://github.com + xsel + + + +==== pdf + + pdfunite *.pdf 2018.pdf + + +==== TTS - festival + + apt install festival festvox-en1 festvox-us1 festvox-us2 festvox-us3 festvox-us-slt-hts festvox-kdlpc16k + echo "Hello world" | festival --tts + echo '(SayText "Hello World")' | festival --pipe + festival --tts my-text.txt + + stty intr ^C (go back to default ctrl+c handling, without this festival doesn't work properly) + festival + help + (voice.list) + (tts "text.txt" nil) + (voice_en1_mbrola) + (voice_cmu_us_slt_arctic_hts) + + + +==== TTS - espeak-ng + + apt install espeak-ng + espeak-ng --voices=en + espeak-ng -s 150 -f text.txt + espeak-ng -s 140 -f text.txt -v us-mbrola-1 + espeak-ng "Hello world" + echo "Hello world" | espeak-ng + + + +==== TTS - pico + + apt install libttspico-utils + pico2wave -w a.wav "Hello world" + aplay a.wav + cat text.txt | pico2wave -w a.wav + aplay a.wav + + +=== Linux servers + +sudo /home/adm/bin/suroot + +==== ssh + +* .ssh +** cat/more id_rsa.pub + +---- +ssh xx@server +---- + + +== Kubernetes + +=== virtualbox-7.0 + +* Configuring Secure Boot +** 4Secure2Boot! \ No newline at end of file