- For new site : cp /etc/awstats/awstats.<existing website>.conf /etc/awstats/awstats.<new website>.conf
- Edit the /etc/awstats/awstats.<new website>.conf to configure DOMAIN etc
- Run manually to test : /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=<new website>
- Add entry in crontab to update stats daily
- @daily /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=<new website>
Saturday, 31 May 2025
awstats
pass
pass
Create a gpg key
gpg --gen-key
gpg --list-keys
Export gpg to gpg2
gpg2 --export-secret-keys > keyfile
gpg2 --import keyfile
gpg2 --edit-key D3B0B515 trust & save
Setting it up
pass init "ZX2C4 Password Storage Key"
pass git init : git repo for entries
Usage
pass : show all entries
pass Email/zx2c4.com : show password of entry
pass -c Email/zx2c4.com : don't show and copy to clipboard
pass insert Business/cheese-whiz-factory : insert new entry
pass edit Business/cheese-whiz-factory : edit entry
pass rm Business/cheese-whiz-factory : remove entry
pass generate Email/jasondonenfeld.com 15 : generate password
Export & Import
export_import
Change password of key
gpg2 --list-keys
gpg2 --edit-key 77316AB19A2366268B1CBE7FD5DF8174ED02B7CE
Friday, 30 May 2025
Thursday, 29 May 2025
postfix
# Monitor postfix mail log
journalctl -u postfix -f
# list queue
postqueue -p
# Flush queue
postqueue -f
# Postfix rewrite from
-
cat /etc/postfix/sender_canonical_maps
/.+/ email@yandex.com
-
cat /etc/postfix/header_check
/From:.*/ REPLACE From: email@yandex.com
-
add to /etc/postfix/main.cf
sender_canonical_classes = envelope_sender, header_sender sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps smtp_header_checks = regexp:/etc/postfix/header_check
ddrescue
ddrescue
Disk image creation
- cd /mnt/tmp/backupsdb
- sudo ddrescue /dev/sdb2 sdb2.img sdb2_log.txt -n -r 5 -c 64
sfdisk
Disk partition tool
Backup partition table of first disk. Verify partition name
sfdisk -d /dev/sda > sda_partition_table.txt
Restore partition table to second disk. Verify partition name
sfdisk /dev/sdb < sda_partition_table.txt
Wednesday, 28 May 2025
ufw
Frontend for iptables aiming to make configuration of a firewall easier.
More information: <https://wiki.ubuntu.com/UncomplicatedFirewall>.
Show ufw rules, along with their numbers:
ufw status numbered
Enable ufw:
ufw enable
Disable ufw:
ufw disable
Deny all incoming traffic
ufw default deny incoming comment 'deny all incoming traffic'
Allow ssh incoming traffic
ufw limit in ssh comment 'allow SSH connections in'
Allow outgoing traffic
ufw allow out 53 comment 'allow DNS calls out'
ufw allow out 123 comment 'allow NTP out'
ufw allow out http comment 'allow HTTP traffic out'
ufw allow out https comment 'allow HTTPS traffic out'
ufw allow out 68 comment 'allow the DHCP client to update'
To deny any traffic on port 99, use the command below:
ufw deny 99
Add new rule
ufw allow from 1.2.3.4 app WWW
check added rule
ufw status verbose
Delete rule
ufw delete 1
start UFW
ufw enable
status of UFW
ufw status verbose
check logs
grep -i ufw /var/log/syslog
Allow incoming traffic on port 5432 on this host with a comment identifying the service:
ufw allow 5432 comment "Service"
Allow only TCP traffic from 192.168.0.4 to any address on this host, on ports 22 & 80:
ufw allow proto tcp from 192.168.0.4 to any port 22,80
Deny traffic on port 80 on this host:
ufw deny 80
Deny all UDP traffic to ports in range 8412:8500:
ufw deny proto udp from any to any port 8412:8500
Delete a particular rule. The rule number can be retrieved from the `ufw status numbered` command:
ufw delete rule_number
Tuesday, 27 May 2025
awk
# To sum integers from a file or stdin, one integer per line:
printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}'
# To use a specific character as separator to sum integers from a file or stdin:
printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'
# To print a multiplication table:
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'
# To specify an output separator character:
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'
# To execute commands only on rows that satisfy a certain condtion
printf "george jetson\nolive oyl\nbeetle bailey" | awk '$2=="bailey"{print $0}'
#
# To execute commands only on matching rows using regex
printf "george jetson\nolive oyl\nbeetle bailey" | awk '/ley$/{print $0}'
tr
# To replace : with a new line:
echo $PATH | tr ":" "\n"
echo $PATH | tr -t ":" \n
# To remove all occurance of "ab":
echo aabbcc | tr -d "ab" # ouput: cc
# To complement "aa":
# ("Complement" means to keep "aa", and replace all others with "x")
echo aabbccd | tr -c "aa" x # output: aaxxxxx (no newline)
# To complement "ab\n":
echo aabbccd | tr -c "ab\n" x #output: aabbxxx (with newline)
# To preserve all alpha(-c). ":-[:digit:] etc" will be translated to "\n". sequeeze mode:
echo $PATH | tr -cs "[:alpha:]" "\n"
# To convert an ordered list to an unordered list:
echo "1. /usr/bin\n2. /bin" | tr -cs " /[:alpha:]\n" "+"
# To remove all NULLs:
tr < file-with-nulls -d '\000' > file-without-nulls
Monday, 26 May 2025
sed
# To replace all occurrences of "day" with "night" and write to stdout:
sed 's/day/night/g' <file>
# To replace all occurrences of "day" with "night" within <file>:
sed -i 's/day/night/g' <file>
# To replace all occurrences of "day" with "night" on stdin:
echo 'It is daytime' | sed 's/day/night/g'
# To remove leading spaces:
sed -i -r 's/^\s+//g' <file>
# To remove empty lines and print results to stdout:
sed '/^$/d' <file>
# To replace newlines in multiple lines:
sed ':a;N;$!ba;s/\n//g' <file>
# To insert a line before a matching pattern:
sed '/Once upon a time/i\Chapter 1'
# To add a line after a matching pattern:
sed '/happily ever after/a\The end.'
Home
- 7z : Compression utility
- aa : a simple utility to help create backups
- ab : Apache HTTP server benchmarking tool
- aespipe : AES encrypting or decrypting pipe
- at : Task scheduler
- atop
- awk
- aws cli : copy data from s3 bucket
- awstats : Site statistics
- badblocks
- bash
- bc : Calculator for terminal
- btop : resource monitor
- darkhttpd : simple web server
- date : check date
- ddrescue
- dnf : a package manager for RPM-based Linux distributions
- du
- dvd-slideshow
- exim : mail server
- feh : image viewer
- forwardemail : email forwarder service
- freechess : play chess online
- find
- firewalld
- flexbackup
- fping
- gpg : encryption and signing tool
- grub
- iptables
- journalctl : systemd logs
- mailman : mail distribution list
- monitorix : a lightweight system monitoring tool
- mutt : email client
- nc : network cat
- netcat
- nikto : web server scanner
- nmap : port scanner
- nnn : File manager for terminal
- nweb : simple web server
- pac: GUI to manage/launch connections to remote machines
- pass : Password manager
- pax : Archiving and copying utility.
- postfix
- rclone : data transfer to cloud
- robocopy : File copier for Windows
- rsync
- sbopkg : Install slackware packages from slackbuilds.org
- scalc
- sed
- sent : plaintext presentation tool
- sfdisk
- split
- ss
- tar
- tcpdump : packet analyzer
- TermRecord : terminal recorder
- tmux : terminal multiplexer
- tr
- ufw
- utimer : command line timer
- vim
- whatweb : Next generation web scanner version
- wordpress : permissions on linux vm
- xrandr : configure display output
vim
Cut/Delete
- dG delete from current line to end of file.
- dgg delete from current line to beginning of file.
- d`a delete from current character upto location marked by a
- d% delete upto matching pairs () {} []
- ce delete till end of word and change to Insert mode.
TermRecord
TermRecord is a simple terminal session recorder with easy-to-share self-contained HTML output! TermRecord -o /tmp/session.html
-
7z : Compression utility aa : a simple utility to help create backups ab : Apache HTTP server benchmarking tool aespipe : AES encrypti...
-
grub-mkconfig - generate a GRUB configuration file grub-mkconfig -o /boot/grub/grub.cfg
-
# To sort directories/files by size: du -sk *| sort -rn # To show cumulative human-readable size: du -sh # To show cumulative human-readabl...