mirror, mirror on the wall

mirror, mirror on the wall

hints

Posted on .

Keep in mind it's possible some of the information to be out-of-date.

# run process as daemon in screen
$ /usr/bin/screen -S process_daemon -d -m /home/user/daemon.sh

# kill screen
$ /usr/bin/screen -S process_daemon -p 0 -X quit

# generate password
$ /usr/bin/head -c 200 /dev/urandom | tr -cd '[:graph:]' | head -c 15

# create pdf file from text file in cyrillic
$ iconv -f UTF-8 -t CP1251 < test.txt > output.txt
$ htmldoc --webpage --embedfonts --charset cp-1251 --textfont serif -f file.pdf output.txt

# create audio cd from mp3 files
$ for i in *.mp3; do lame --decode "$i" "`basename "$i" .mp3`".wav; done
$ cdrecord -v dev=1,0,0 -pad -dao -useinfo *.wav

# extract audio from the video file and save it in mp3 format
$ mplayer -vc dummy -vo null -ao pcm:waveheader:file="music.wav" file.avi
$ lame -h -b 128 music.wav music.mp3

# little regexp trick
$ export LC_ALL=C
$ for i in `ls | grep -e "[A-Z]\{6\}"`; do rm $i; done

# QEMU
$ qemu-img create /data/winxp.img 5G
$ qemu -boot d -hda /data/winxp.img -m 512 -cdrom ~/WinXPSP3.iso -localtime

# FreeBSD: mount iso file
$ mdconfig -a -t vnode -f 8.0-BETA3-i386-disc1.iso -u 0 && mount -r -t cd9660 /dev/md0 /mnt/iso

# Linux: mount iso file
$ mount -o loop disk1.iso /mnt

# record DVD
$ growisofs -Z /dev/dvd -R -J /path/to/file

# record CD
$ mkisofs -R -J . | cdrecord dev=/dev/hdc -data -

# insert csv file into mysql table
mysql>LOAD DATA LOCAL INFILE '/tmp/file.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (col_1,col_2,col_3);

# create self signed ssl certificate
$ openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem

# ssl connect
$ openssl s_client -connect cipier.net:443

# get date before
$ date +%F --date="1 days ago"

# extract pre and post scripts from rpm
$ rpm -qp --scripts some_package.rpm

# create diff between directories
$ diff -rupN original/ new/ > patch

# extract rpm
$ rpm2cpio centos_almost_rules.x86_64.rpm | cpio -idmv

# FreeBSD 9.0 change MAC
# /sbin/ifconfig sis0 ether 00:01:02:03:04:05

# git archive
$ git archive --format=tar --prefix=myproject-version/ HEAD | gzip > myproject-version.tar.gz

# strip raw color chars
$ git diff | less --RAW-CONTROL-CHARS

# FreeBSD update port and dependencies
$ portmaster -R -f -r openssl

# git clone update
$ git clone git://git.osmocom.org/libosmo-abis
$ git remote update
$ git pull

# web debugging
# yum install mod_security
# echo "SecRule REMOTE_ADDR \".*\" log" > /etc/httpd/modsecurity.d/rules.conf
# /etc/init.d/httpd reload

# FreeBSD wireless scan
# ifconfig wlan0 list scan

# fit to gpx
$ gpsbabel -i garmin_fit -f track.fit -o gpx -F track.gpx
$ gpx2map -o --notemp track.gpx
# truncate file with fixed size
$ truncate -s 16G openbsd.img

# bhyve
# sh /usr/share/examples/bhyve/vmrun.sh -i -c 1 -d /vmpool/drum.img \
      -I /home/koue/iso/FreeBSD-10.1-RELEASE-amd64-disc1.iso -m 1024M -t tap0 drum
# sh /usr/share/examples/bhyve/vmrun.sh -c 1 -d /vmpool/drum.img -t tap0 drum

# tmux hints
$ tmux ls
$ tmux new -s session_name
$ tmux a -t session_name

# redirect error to output
$ make |& tee build.log

### OpenBSD cvs
# checkout
$ cvs -qd anoncvs@ftp5.eu.openbsd.org:/cvs get -P src
# update
$ cd src/
$ cvs -qd anoncvs@ftp5.eu.openbsd.org:/cvs up -Pd
# checkout module
$ cvs -qd anoncvs@ftp5.eu.openbsd.org:/cvs get -P src/usr.sbin/dhcpd
# update module
$ cd src/usr.sbin/dhcpd
$ cvs -qd anoncvs@ftp5.eu.openbsd.org:/cvs up -Pd

# FreeBSD ssh tunnel
client# ssh -w 5:5 root@server
server# ifconfig tun5 192.168.100.1/30 192.168.100.2
client# ifconfig tun5 192.168.100.2/30 192.168.100.1

using ssh config files:
client# cat ~/.ssh/config
Host tunnel
	Hostname 10.10.10.5
	Port 22
	User root
	IdentityFile /root/.ssh/id_rsa
	StrictHostKeyChecking no
	UserKnownHostsFile /dev/null
	ExitOnForwardFailure yes
	PermitLocalCommand yes
	LocalCommand /sbin/ifconfig tun5 192.168.5.2/24 192.168.5.1
	Tunnel yes
	TunnelDevice 5:5
server# cat ~/.ssh/config
tunnel="5",command="/sbin/ifconfig tun5 192.168.5.1/24 192.168.5.2",no-user-rc ssh-rsa MY-SSH-PUB-KEY-GOES-HERE root@client
server# cat /etc/ssh/sshd_config
...
TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 3
PermitRootLogin yes
PermitTunnel yes
...
client# ssh tunnel

# docker images
# docker ps -l -q
# docker commit -m "update image" -a "user" CONTAINER_ID new_image:tag
# docker [attach|start|stop|rm] container
# docker ps -a
# docker images
# docker rmi image:tag
# docker run -d --name newguest -p 8080:80 mymod/httpd:v1 /usr/sbin/httpd -D FOREGROUND
# iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j DNAT --to 172.17.3.109:22

# buildbot sendchange
#buildbot sendchange --master 127.0.0.1:9999 --auth bang:bang --who me --repository http://path/to/the/repo --branch tags/project-1.2.3 --revision 16484 --comments "Test build." Doxyfile

# poudriere jail -c -j 91x64 -v 9.1-RELEASE -a amd64
# poudriete jail -u -j 91x64
# poudriere ports -c -p 2018Q4 -B branches/2018Q4 -m svn+https

# dd if=CentOS-7-x86_64-Minimal-1503-01.iso of=/dev/da0 bs=1M

# cvs -qd anoncvs@ftp5.eu.openbsd.org:/cvs get -P src/usr.sbin/httpd
# cvs2cl.pl --xml -l "-d2014-07-13<2016-10-07"
# cl2html.pl --entries 0 < ChangeLog > ChangeLog.html

# cat /dev/zero | ssh-keygen -q -N "" -f ~/.ssh/id_rsa

# FreeBSD single user
# mount -o rw -u /
# passwd

# search between strings
# sed -n '/#if 0.*koue.*/,/#endif .*koue.*/ p' file.c
# invert
# sed -n '/#if 0.*koue.*/,/#endif .*koue.*/ !p' file.c

# FreeBSD sed inplace
# sed -i.bak -e 's/-liconv//' Makefile

# letsencrypt certbot
# pkg install py27-certbot
# certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com
# certbot certonly --standalone -d example.com -d www.example.com
# certbot renew --dry-run
# certbot renew

# UPDATE SQLITE_SEQUENCE SET seq = n WHERE name = 'table'

# valgrind
# valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 ./command

sh$ for f in *.c; do mv ${f} $(echo $f | sed "s/-/_/g"); done

openbsd# snap -D /home -S -M ftp.hostserver.de -V 6.3

# crontab
47 7,15 * * * root su -m www -c '/usr/local/bin/rssroll -d /opt/db/rssroll.db'

# cmake
$ cmake ../ && make && ctest -V

# stdbuf
$ nc 10.20.169.4 5000 | stdbuf -i L -o L tr -dc '[:print:]\n\t' | nc -u 172.29.150.14 5000

# pw useradd lazy -u 1002 -m -G wheel -h - -c "Lazy" -d /home/lazy -k /usr/share/skel -s /bin/sh

# zcat /boot/initrd.img-4.19.0-3-amd64 | cpio -idmv

owncloud# su -m www -c 'php occ user:resetpassword koue'

# gpart destroy -F da0
# gpart create -s GPT da0
# gpart add -t freebsd-ufs -a 1M da0
# gpart show da0
# newfs -U /dev/da0p1

# pkg install fusefs-ntfs
# kldload fusefs
# ntfs-3g /dev/da1p1 /mnt/

About

github

Creative Commons

RSS