############################################################################### # Text file containing Linux commands and information (mostly in Dutch). # # Written by Karel Zimmer , CC0 1.0 Universal # , 2010-2023. ############################################################################### UNIX, Linux, and distro's ------------------------- Linux is gestandaardiseerd op drie manieren: 1. POSIX Zelfs POSIX+ 2. Freedsktop desktop entry spec, systemd, basedir, ... 3. LSB (Linux Standard Base) modules, naamgeving, compiler-opties, FHS (Filesystem Hierarchy Standard) Unix: Boek UNIX het *standaard* operating system, H.J. Thomassen, Academic Services. Linux: Boek LINUX: Rute User's Tutorial and Exposition, Paul Sheer, Prentice Hall PTR Distro: Boek The Official Ubuntu Book - Ninth Edition, Matthew Helmke et.al, Prentice Hall Boek The Official Ubuntu Server Book - Third Edition, Kyle Rankin and Benjamin Mako Hill, Prentice Hall Boek The Debian (The *Universal* Operating System) Administrator's Handbook, Raphaël Hertzog and Roland Mas, Freexian Repair NTFS ----------- sudo apt install ntfs-3g -y findmnt # TARGET SOURCE FSTYPE OPTIONS # /media/... /dev/sdb2 ntfs3 rw,nosuid,nodev,relatime,uid=... sudo ntfsfix /dev/sdb2 Git/GitHub ---------- Lokale git repo voor teksten of scripts: sudo apt-get instal git git config --global user.name 'Karel Zimmer' git config --global user.email 'karel.zimmer@gmail.com' git config --list mkdir article cd article git init Aanmaken/wijzigen/verwijderen documenten: git add . git status git commit -m "Initial version of article" git commit --amend -m "First version of article" Remote git repo voor documenten of scripts, e.g. GitHub: Maak repo op website. download: git clone https://github.com/karelzimmer/kz-docs.git ~ git clone https://github.com/karelzimmer/kz-scripts.git ~ git config --global user.name 'Karel Zimmer' git config --global user.email 'karel.zimmer@gmail.com' Upload: git config --global credential.helper store Hierna geen username/password meer nodig. Terugdraaien: git config --global --unset credential.helper git push Username for 'https://github.com': USERNAME Password for 'https://USERNAME@github.com': PASSWORD Git config levels and files: --local lokaal configuratiebestand in repo's .git directory: .git/config --global globaal configuratiebestand in ~ /.gitconfig --system systeem configuratiebestand in $(prefix)/etc/gitconfig Git Branching & Merging: main standard branch na 'git init' # Of: # master < oktober 2020, gewijzigd naar main ivm culturele aspecten zoals master/slave BRANCH branch is in feite een verwijzing naar een momentopname van je wijzigingen HEAD verwijst naar de huidige commit die je aan het bekijken bent ("pointer") git branch list active (*) and other branches git branch BRANCH maak BRANCH git checkout BRANCH checkout naar BRANCH git checkout -b BRANCH --branch, maak en checkout naar BRANCH There are five different branch types in total: Main Develop Feature Release Hotfix Some suggestions for naming your feature branches: users/username/description users/username/workitem bugfix/description feature/feature-name feature/feature-area/feature-name hotfix/description git status wijzigingen zijn zichtbaar in main & BRANCH git add . wijzigingen zijn zichtbaar in main & BRANCH git commit -m MESSAGE wijzigingen zijn zichtbaar alleen in BRANCH git checkout main checkout naar main (HEAD BRANCH -> main) git merge BRANCH maak main gelijk aan de BRANCH git branch -d BRANCH --delete BRANCH git status git push Git Branching & Merging voorbeeld: git checkout dev git branch * dev master Change files: git status git restore FILE undo changes git add . git restore --staged FILE reverse add git commit -m 'File added' git checkout main git branch # dev # * main git merge dev git push git branch -d dev Informatie: git reflog git config --list raadplegen git remote set-url origin NEW_URL wijzigen git log git log -10 git log --oneline git show SHA1 git diff working <-> staged git diff 'SHA1-A' 'SHA1-B' log --oneline # fatal: CRLF would be replaced by LF in file.txt git config --global core.autocrlf false Rename branch master to main: git branch -m master main git fetch origin git branch -u origin/main main git remote set-head origin -a Git-ignore: vi .gitignore In root van de repo. Verwijder FILE uit repo, maar houd hem in werkmap als ignored file. git rm --cached FILE git rm -r --cached DIR Persé lege dirs in repo? Doe in lege map voor de push: touch .gitignore Meldingen over git pull en fast-forward?: git pull git config pull.ff only git config --global pull.ff only git clean -d -f . Squash commit in vscode ======================= VOORBERIDING ----------- Installeer vscode extensie Git Graph WERKWIJZE --------- 1. Checkout naar main 2. Klik links op pictogram van Source Control (Crl+Shift+G G) 3. Open SOURCE CONTROL als nodig door te klikken op SOURCE CONTROL 4. Klik rechts van SOURCE CONTROL op pictogram van View Git Graph (git log) 5. Klik rechts op branch die (squash) gemerged moet worden met main en kies Merge with current branch 6. Vink aan Squash Commits 7. Klik op Yes, merge 8. Los eventuele merge-conflicten op in het 3-venster scherm 9. Geef commit message en doe de commit VOORBEELD --------- Hoe cool, 1 commit 'Changes for t9n' in main, tegen 73 dezelfde commits in feature/t9n: $ git log commit ef16d17af1fb152981dd1efe680cf13547a16cd8 (HEAD -> main) Author: Karel Zimmer Date: Fri Mar 3 10:33:56 2023 +0100 Changes for t9n commit 7ff89479024c8dc1343181cf51370b776e6b5e5d (origin/main, origin/HEAD) Author: Karel Zimmer Date: Tue Feb 21 08:45:00 2023 +0100 Added check if all repo' s are on branch main etc... (1 commit voor Changes for t9n!) $ git checkout feature/t9n $ git log commit e0429689659a75924850c4baa65b8f39d14b3195 (HEAD -> feature/t9n, origin/feature/t9n) Author: Karel Zimmer Date: Fri Mar 3 09:45:48 2023 +0100 Changes for t9n commit 2dd93b3b70c0b2757e716df35f1c1e3c91849661 Author: Karel Zimmer Date: Fri Mar 3 09:05:35 2023 +0100 Changes for t9n etc... (73 commits voor Changes for t9n!) # Of: git checkout main git merge --squash git commit -m'squash-commit-msg' Gettext .pot/.po/.mo files -------------------------- # WERKWIJZE # --------- cd ~/scripts # ### 1-MALIG ### # sudo apt install gettext # mkdir --parents nl/LC_MESSAGES # Voeg 1 of meer gettext's toe in script: #-------------------------------------------------------------------------------- #!/bin/bash # # export TEXTDOMAIN=helloworld # export TEXTDOMAINDIR=/home/karel/scripts # # source /usr/bin/gettext.sh # # program_name=helloworld.sh # # printf '%s\n' "$(eval_gettext "Program name: \$program_name")" # # printf '%s\n' "$(gettext 'Hello world!')" #-------------------------------------------------------------------------------- # xgettext --language=Shell --no-location --output=helloworld.pot helloworld.sh # ### OF ### #-------------------------------------------------------------------------------- #!/bin/python # # import gettext # # gettext.bindtextdomain('helloworld', '/home/karel/scripts') # gettext.textdomain('helloworld') # _ = gettext.gettext # # program_name = 'helloworld.py' # # print(_('Program name: {}').format(program_name)) # # print(_('Hello world!')) #-------------------------------------------------------------------------------- # xgettext --language=Python --no-location --output=helloworld.pot helloworld.py # # msginit --locale=nl --input=helloworld.pot --output-file=nl/LC_MESSAGES/helloworld.po # Wijzig 1-malig .po: # Content-Type: text/plain; charset=UTF-8\n" <== UTF-8 # PACKAGE -> helloworld # VERSION -> 0.1 # Voeg gettext's toe in script. # Daarna: xgettext --language=Shell --join-existing --no-location --output=helloworld.pot helloworld.sh # Of: xgettext --language=Python --join-existing --no-location --output=helloworld.pot helloworld.py msgmerge --update --backup=none --previous --no-location nl/LC_MESSAGES/helloworld.po helloworld.pot Zie ook ~/bin/pogen. # Wijzig als vertaler .po: # msgid "Hello world!" # msgstr "" --> "Hallo wereld!" # Etc. # Maak .mo aan na iedere vertaling: msgfmt --output-file=nl/LC_MESSAGES/helloworld.mo nl/LC_MESSAGES/helloworld.po # Voor systeem: sudo cp nl/LC_MESSAGES/helloworld.mo /usr/share/locale/nl/LC_MESSAGES Zie ook ~/bin/mogen. # Vertaalbestanden worden t.z.t. gedistribueerd en geinstalleerd met "kz.deb". # ├── helloworld.pot (Portable Object Template/GNU gettext message catalogue) # ├── helloworld.sh # ├── nl # │   └── LC_MESSAGES # │   ├── helloworld.mo (Machine Object/GNU message catalog) # │   ├── helloworld.po (Portable Object/GNU gettext message catalogue) # Vind duplicates in PO bestand: msguniq --repeated nl/LC_MESSAGES/helloworld.po # Combineer PO bestanden: msgcat --repeated File1.po File2.po --output-file=File3.po # TESTEN # ------ echo "$LANGUAGE" # nl:en LANGUAGE=nl ./helloworld.sh # Programmanaam: ./helloworld.sh # # Hallo wereld! LANGUAGE=en ./helloworld.sh # Program name: ./helloworld.sh # # Hello world! man