CarlHolmberg

  • 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.
    • compressing
      • zip –r filename.zip 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.
    • 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 README.md files into html for preview on localhost web service.
      • python3 setup.py bdist # create *.tar.gz in the ./dist directory
      • python3 setup.py 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.
    • 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.
    • 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: https://vim.fandom.com/wiki/Shifting_blocks_visually
      • flake-8, a PEP8 format checker for Python files: https://github.com/nvie/vim-flake8

UserForm edit

FirstName Carl
LastName Holmberg
OrganisationName LBTO
OrganisationURL https://www.lbto.org
Profession Software engineer
Country United States
State AZ
Address
Location
Telephone
VoIP
InstantMessaging (IM)
Email
HomePage
Comment
Topic revision: r24 - 06 May 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