GNU/Linux TCPDump QuickRef
Some tcpdump examples.
tcpdump -vv -i eth0 -w tcpdump.log 'tcp port 443'
tcpdump -vv -i eth0 -w tcpdump.log dst 145.89.57.121
All posts containing GNU/Linux-related scripts and patterns.
Some tcpdump examples.
tcpdump -vv -i eth0 -w tcpdump.log 'tcp port 443'
tcpdump -vv -i eth0 -w tcpdump.log dst 145.89.57.121
| ODATA Query Option | Description |
|---|---|
| $orderby | Uri parameter for sorting… |
| $select | Uri parameter to select specific coluimns… |
| $top | Uri parameter to limit the result… |
| $skip | Uri parameter to skip number of rows… |
| $filter | Uri parameter to filter result… |
| $expand | Uri parameter to expand related entity… |
| $inlinecount | Uri parameter to include a total record count… |
Example to retrieve metadata from JBoss DV Odata service…
https://localhost:8443/odata/vdbname/$metadata
Retrieve all records in JSON format…
https://localhost:8443/odata/vdbname/modelname?$format=json
Order by column ‘Name’ and retrieve first 5 records…
https://localhost:8443/odata/vdbname/modelname?amp;$orderby=Name&$top=5
Order by column ‘Name’ and retrieve records 6-10 records…
https://localhost:8443/odata/vdbname/modelname?$orderby=Name&skip=5&$top=5
Filter ODATA result ($filter=Name eq ‘John’)…
https://localhost:8443/odata/vdbname/modelname?$filter=Name%20eq%20%27John%27
Select specific rows…
https://localhost:8443/odata/vdbname/modelname?$select=ID,Name,Description
Test LDAP server SSL/TLS connection using LDAP commandline client…
ldapsearch -H ldaps://dc01.totietoot.nl -b "OU=Employees,OU=Totietoot,DC=Totietoot,DC=nl" "userPrincipalName=john@totietoot.nl" -W -D john@totietoot.nl -d 1
env LDAPTLS_REQCERT=never|allow|try|demand LDAPTLS_CACERT=/path/to/ca-cert.pem ldapsearch -H ldaps://dc01.totietoot.nl -b "OU=Employees,OU=Totietoot,DC=Totietoot,DC=nl" "userPrincipalName=john@totietoot.nl" -W -D john@totietoot.nl -d 1
Display basic queue information…
activemq:query -QQueue=* --view Name,EnqueueCount,DequeueCount,QueueSize
Display queue messages…
activemq:browse --amqurl tcp://localhost:61616 --user [username] --password [password] queue:[queuename]
Purge a specific message from the command line…
activemq:purge --msgsel "JMSMessageID='ID:XXXXXXXX-000000-0000000000000-0:0:00:0:0'" [queuename]
Purge all messages from a specific queue…
activemq:purge [queuename]
LocalForward/Dynamic tunnels & SFTP jumphost connection examples (commandline):
>ssh -L 1522:remote.hostname:1522 user@tunnel.hostname
>ssh -D 8080 user@tunnel.hostname
>sftp -o ProxyJump=user@jump.hostname:22 [-b ./batch.scr] user@dest.host.internal
LocalForward/Dynamic tunnels & SFTP jumphost connection examples (commandline and config):
>ssh dsthst
~/.ssh/config:
Host prxjmp
Hostname jump.hostname
Port 22
User user
LocalForward 7080 10.0.0.9:7080
DynamicForward 8080
Host dsthst
HostName dest.host.internal
Port 22
User user
ProxyJump prxjmp
IdentityFile ~/.ssh/other_key_location
Generate a SSH Key Pair:
>ssh-keygen -m PEM -t ecdsa -b 521
>ssh-keygen -m PEM -t ecdsa -b 521 -C "tim" -f /home/tim/tmp/id_ecdsa
Other algorithms:
>ssh-keygen -t ed25519
>ssh-keygen -t dsa
>ssh-keygen -t rsa -b 4096
Convert SSH2 Public Key to OpenSSH Public Key
>ssh-keygen -i -f id_ssh2.pub [-m PKCS8]
Convert OpenSSH Public Key to SSH2 Public Key
>ssh-keygen -e -f id_openssh.pub
Get Key Fingerprint MD5
ssh-keyscan -p [port] [hostname] > [hostkeyfpfile]
ssh-keygen -l -f [hostkeyfpfile] -E md5
Start session with alternate key
sftp -o IdentityFile=/home/tim/.ssh/id_rsa_2 tim@server1
Implement group restrictions in /etc/ssh/sshd_config
# Group restrictions
AllowGroups sshaccess
Match Group sshpubkeyonly
PasswordAuthentication no
Match group sftpusers
X11Forwarding no
ChrootDirectory %h
AllowTcpForwarding no
ForceCommand internal-sftp
Update repository and install packages:
>pkg upgrade
>pkg install nano
Enable SSHD:
>sysrc sshd_enable=yes
Force a OwnCloud (plugin) full scan on a FreeNAS machine:
su -m www -c '/usr/pbi/owncloud-amd64/bin/php /usr/pbi/owncloud-amd64/www/owncloud/occ files:scan --all'
Some of my most used gpg commands…
# Generate a PGP key... gpg --gen-key # Sign a key... gpg --default-key [KEYID-TO-SIGN-WITH] --sign-key [KEYID-TO-BE-SIGNED] # Revoke a key... gpg --edit-key [KEYID] >revkey # List (secret) keys... gpg --list(-secret)-keys # Export a public key in ascii armor format... gpg --armor --export [KEYID] > KeyName_Email_KEYID.pub.asc # Export a private key in ascii armor format... gpg --armor --export-secret-keys [KEYID] > KeyName_Email_KEYID.sec.asc
You can use find to script removal of old backup or logfiles from a specific directory. The example below removes all files from a directory that are older than 14 days.
find /var/local/ucs/*.ucs -type f -mtime +14 -exec rm {} \;
Clone a Repository, add files, commit and push to master
git clone [--recurse-submodules] ssh://git@gitlab.timvkn.nl:22/Project.git
git add [filename|-A]
git commit -a -m "Initial upload..."
git push -u origin master
Create a branch for the new release and check-out to the new branch
git branch release-4.1.11
git checkout release-4.1.11
git submodule update --init --recursive
Make the changes to the files and commit the changes
git commit -a -m "Change description..."
Mark as executable
git update-index --chmod=+x build.sh
Push to server
git push -u origin release-4.1.11
Merge changes with master branch
A) Merge with master takes place on server. Pull new master branch from server...
git checkout master
git pull -a
B) Merge all changes to the master locally and push to server...
git checkout master
git merge release-4.1.11
git push -u origin master
Delete old branch
git branch -d release-4.1.11
* Option -D deletes a not merged branch...
Display commits and force to specific commit
git reflog
git reset --hard e072e63
Add submodule
git submodule add https://github.com/dGlt/submodule Submodules
RegExp basic encoding…
? = 0..1
* = 0..n
NULL = 1..1
+ = 1..n
| = XOR
{3} = 3
{2,8} = 2-8 chars/numbers
^ = Matches beginning
$ = Matches end
Example RegExp
X-[0-9]?[0-9]-((0[1-9])|([1-2][0-9])|(3[0-2]))-[A-Z]{3}[0-9]{3,6}
Matching and Not-matching...
X-88-32-ABC123 -- MATCH
X-7-06-XYZ12345 -- MATCH
X-88-33-ABC123 -- NOTMATCH (33 not within 01-32)
X-88-32-ABC12 -- NOTMATCH (12 not 3-6 numbers)