• Linux related notes
    • bash
      • sudo -E bash -c '<a shell command>' # preserve user environment (aliases & variables) when issuing a command under sudo.
      • sudo ls -l /proc/$(pidof <process name>) | grep exe # to check which file a process is run from.
      • sudo ls -l /proc/$(pidof <process name>) | grep fd # what files/sockets/etc the process has open.
      • head -c 1G /dev/urandom >myfile # create a file full of rubbish.
      • nohup sudo <command> # protect an elevated process from a console hang up.
    • compressing
      • zip –r directory_name # recursively zip a directory
    • git
      • git reset <hash> # make a previous commit the current state.
      • git commit --amend --no-edit # don't pollute the commit log when making heaps of small changes.
      • git push -f origin <branch> # and force that commit to the branch.
      • git branch -d <branch> # delete local branch
    • mongo
      • control
        • sudo systemctl enable mongod.service
        • sudo systemctl start mongod.service
      • shell
        • mongo # if locally hosted
        • show dbs
        • use <dbs name>
        • show collections
        • db.<collection name>( {} ) # equiv to SQL select * from <table>
        • db.<collection name>.find( { <tag>: "<value>" } ) # equiv to SQL select * from <table> where <field> = "<value>"
    • php
      • php -f <file>.php # run script from console.
    • python
      • grip # renders files into html for preview on localhost web service.
      • python3 bdist # create *.tar.gz in the ./dist directory
      • python3 bdist_rpm # create rpm in the ./dist directory
    • rpm
      • sudo dnf config-manager --add-repo /etc/yum.repos.d/.repo
      • sudo dnf config-manager --set-enabled
      • rpm -qlpv ./path/to/test.rpm # list files in RPM package file.
      • rpm2cpio ./path/to/test.rpm | cpio -idmv # unpack contents of RPM package to working directory.
      • rpm -qp --scripts ./path/to/test.rpm # view un/install scripts for RPM package.
      • rpm --showrc | grep sitelib # show values for options set in rpmrc, look for where pure Perl/Python modules are kept.
      • sudo yum --disablerepo="*" --enablerepo="mpia" list available # list packages available in a single repo.
      • sudo flatpak uninstall --unused # clears out unused app runtime library crap filling up /var.
    • systemd
      • reading logs in systemd
      • journalctl -n 50 | grep sendmail > sendmail.log # get the last 50 system log messages, and filter.
      • /usr/lib/systemd/system/ # location of systemd *.service descriptions.
      • list units: systemctl list-unit-files | grep [disabled|enabled|static]
    • vim
      • :set fileformat=[dos|unix]
      • :set [list|nolist] # to show hidden characters
      • :%s/<find>/<replace>/g # global replace
      • :set [paste|nopaste|pastetoggle] # to control automatic indentation when pasting in code.
      • :set [spell|nospell] # spelling highlighting
      • select: V (start @ line), v (start @ cursor), ctrl-v (start @ column), gv (reselect block), move cursor, then y or d.
      • block comment out: ctrl-v (rect vis sel mode), j for each line, Shift-i, type // (or # or " or ...), Esc key.
      • more block shifting:
      • flake-8, a PEP8 format checker for Python files:
      • hex edit with xxd, enable :%!xxd disable :%!xxd -r
    • cron format:

UserForm edit

FirstName Carl
LastName Holmberg
OrganisationName LBTO
Profession Software engineer
Country United States
State AZ
InstantMessaging (IM)
Topic attachments
I Attachment ActionSorted ascending Size Date Who Comment
cron-job-format-1.jpgjpg cron-job-format-1.jpg manage 6 K 11 Jun 2020 - 23:03 CarlHolmberg cron format image
Topic revision: r29 - 12 Nov 2020, CarlHolmberg
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback