Command | Description |
---|---|
awk '/^END/ { x = 0; } x { print $0; } /^BEGIN/ { x = 1; } ' |
Print text between BEGIN and END lines
(exclusive). |
create table t01_tmp as select distinct * from t01; drop table t01; alter table t01_tmp rename to t01; |
Filter duplicates from the SQLite table t01 . |
cut -d ',' -f 3,4 |
Grab columns 3 and 4 of a CSV input from stdin. |
date -d@$((0x$((perl -e'print"1B","0"x95' \| xxd -r -p; sleep 1) \| nc -u time.facebook.com 123 \| tail -c+41 \| head -c4 \| xxd -p)-64#23GDW0)) |
Query the NTP server time.facebook.com (works on Rocky
Linux’s versions of netcat / xxd ). |
find ~/mydir -name '*go' -exec go fmt {} \; |
Execute a command recursively in ~/mydir only against
files with a certain file extension. |
fuser -mv /mnt/disk |
Find all processes using the mount point
/mnt/disk . |
# Get most recent commit ID of Branch 2, say it's 49a8338 git fetch; git branch -v # Switch to Branch 1 git checkout branch1 git reset --hard 49a8338 |
Reset Branch 1 to be identical to Branch 2 in Git. |
grep -rniI ~/mydir -e 'mysearch' |
Search recursively in ~/mydir for the text
mysearch . The -I option excludes binary
files. |
ls -lart |
Easy to remember, puts most recently changed files at the bottom of the screen. |
# Run on Host 1 nc -lv 50000 # Run on Host 2 nc -v host1_hostname 50000 |
Checks if communication is open on port 50000 between two Linux
hosts with Netcat installed. Another option: python3 -m httpserver -p 50000 and
curl host1_hostname:50000 . |
nslookup time.gov 1.1.1.1 |
Does a DNS lookup of the domain time.gov against the
public DNS server at 1.1.1.1 . Useful for comparing to
nslookup time.gov , which uses its environment’s DNS
configuration. |
openssl s_client -connect npr.org:443 |
Establish a TLS connection to npr.org:443 . |
openssl verify -verbose -CAfile ~/cacert.pem ~/mycert.pem |
Determine if the CA certificate ~/cacert.pem signed the
certificate ~/mycert.pem . |
openssl x509 -in ~/mycert.pem -text |
Print the contents of the X.509 certificate
~/mycert.pem . |
echo -e ".mode csv\n.import a.csv t01" \| sqlite data.sqlite3 |
Import the CSV file a.csv into the table
t01 in the Sqlite database data.sqlite3 . |
ssh -N -L 50000:192.168.1.25:60000 pi |
Forward local port 50000 to remote port
60000 on SSH host pi . |
ssh -D 50000 -C -N pi |
Set up a local SOCKS listener which is tunneled to SSH host
pi . |
ssh-keygen -o -a 100 -t ed25519 |
Generate an Ed25519 SSH key. |
tr -s ' ' |
Squeeze successive spaces to a single space. |