[ prog / sol / mona ]

prog


random Unix things

1 2020-04-02 04:08

C-s unix in the thread list -> failing I-search unix

Here's a thread to post our clever one-liners, miscellaneous hacks, OS rants, configuration files and so on.

Not mandatory but recommended reading: The UNIX-HATERS Handbook https://web.mit.edu/~simsong/www/ugh.pdf

2 2020-04-02 04:56 *

https://www.grymoire.com/Unix/index.html
https://docstore.mik.ua/orelly/unix/upt/index.htm

3 2020-04-02 05:18 *

Some classics:
http://bofh.bjash.com/
http://www.catb.org/~esr/writings/unix-koans/

4 2020-04-02 11:07

>>3

http://bofh.bjash.com/

$ telnet towel.blinkenlights.nl 666

=== The BOFH Excuse Server ===
Someone's tie is caught in the printer, and if anything else gets printed, he'll be in it too.

Connection closed by foreign host.
5 2020-04-02 20:00

I like awk.

6 2020-04-02 22:49

>>5
awk nawk or gawk? That's the real question.

7 2020-04-03 07:35

>>6
Not him, but gawk.

8 2020-04-08 17:43

In Void Linux, /bin is a symlink to /usr/bin. While it may seems as an iconoclast move, as we all know that /bin should only contain the utilities needed in single user mode, further reading on the matter may convince you otherwise. This issue is unrelated to systemd and other distros might follow suit in the future.

https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

http://lists.busybox.net/pipermail/busybox/2010-December/074114.html

When the operating system grew too big to fit on the first RK05 disk pack (their root filesystem) they let it leak into the second one, which is where all the user home directories lived (which is why the mount was called /usr). They replicated all the OS directories under there (/bin, /sbin, /lib, /tmp...) and wrote files to those new directories because their original disk was out of space. When they got a third disk, they mounted it on /home and relocated all the user directories to there so the OS could consume all the space on both disks and grow to THREE WHOLE MEGABYTES

Of course once the split existed, some people made other rules to justify it. Root was for the OS stuff you got from upstream and /usr was for your site-local files. Then / was for the stuff you got from AT&T and /usr was for the stuff that your distro like IBM AIX or Dec Ultrix or SGI Irix added to it, and /usr/local was for your specific installation's files. Then somebody decided /usr/local wasn't a good place to install new packages, so let's add /opt! I'm still waiting for /opt/local to show up...

9 2020-04-08 17:51 *

Void Linux, pros and cons:
pro: http://www.troubleshooters.com/linux/void/whyvoid.htm
contra: http://archive.is/zI5l0

10 2020-04-23 19:28

i gotta confess. im terrified of sed and awk and similar wizard shell utilities.

the second i have to do anything more complicated than piping a command into grep or wc, i just write a python script.

11 2020-04-23 19:56

>>10
If a bearded Unix admin who's been using sed and awk daily for 30 years tells you that he never has to check something in the man pages, do not believe him. At least you're using Python right, it was only meant to do that.

12 2020-04-24 07:58

talk(1) is fine to discuss with another user on your system, but if you want to broadcast a message to every tty, something always working is:

echo 'hi every1 im new!!!!!!! *holds up spork* my name is katy but u can call me t3h PeNgU1N oF d00m!!!!!!!!' | wall


Broadcast message from katy@supersecretviphackerbox (pts/1) (Fri Apr 24 07:56:31 2020):       
                                                                               
hi every1 im new!!!!!!! *holds up spork* my name is katy but u can call me t3h 
PeNgU1N oF d00m!!!!!!!!
13 2020-04-27 12:14

Awk is really convenient for handling multi-line records. Sometimes I use it only to transform them into single line so that the rest of the tools can handle it.

14 2020-04-27 17:50

https://cacm.acm.org/magazines/2016/3/198874-lessons-learned-from-30-years-of-minix/fulltext

15 2020-04-27 18:37

Unix V6
https://www.in-ulm.de/~mascheck/various/ancient/
http://www.tom-yam.or.jp/2238/src/
http://gunkies.org/wiki/Installing_Unix_v6_(PDP-11)_on_SIMH

The Lion's book: http://www.lemis.com/grog/Documentation/Lions/

Xv6
https://pdos.csail.mit.edu/6.828/2012/xv6.html

misc
https://minnie.tuhs.org/
http://doc.cat-v.org/unix/

16 2020-04-28 07:56 *

https://olduse.net/
Usenet, updated in real time as it was thirty years ago. Also available in your local news reader via nntp.olduse.net

17 2020-04-29 06:42 *

Ррр

18 2020-05-04 20:56 *

Used this handy command line to split a PDF recently. You don't need an extra tool, Ghostscript does that perfectly.

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=5 -dLastPage=10 -sOutputFile=output.pdf input.pdf
19 2020-05-07 18:21 *

mfsbsd is a wonderful tool if you want to install FreeBSD on a dedicated server without KVM. Install instructions are never updated on the website or on the FreeBSD wiki though.

https://mfsbsd.vx.sk/

Take note of the static ip of the server and the gateway.

% fetch https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-amd64-disc1.iso
# mdconfig -a -t vnode -u 10 -f FreeBSD-12.1-RELEASE-amd64-disc1.iso
# mount_cd9660 /dev/md10 /mnt
% git clone https://github.com/mmatuska/mfsbsd.git
% cd mfsbsd
% cat << EOF > conf.rc.conf
> ifconfig_em0="inet X.X.X netmask 255.255.255.0"
> defaultrouter="X.X.X.X"
> sshd_enable="YES"
> EOF
% make BASE=/mnt/usr/freebsd-dist/
% make CUSTOM=1 BUILDWORLD=1 BUILDKERNEL=1

Boot from the rescue system. In case it doesn't have enough space to upload the mfsbsd image you can dd through ssh.

% dd if=mfsbsd12.1-RELEASE-amd64.img | ssh root@rescue "dd of=/dev/ada0"

That's it, reboot from hard drive. The installer will complain about a missing MANIFEST file.

mkdir -p /usr/freebsd-dist/ 
touch /usr/freebsd-dist/MANIFEST
bsdinstall
20 2020-05-10 02:53

GodWords by Terry A. Davis

#!/bin/bash
#This prints ten random words.
echo "$(shuf -n 10 /usr/share/dict/words --random-source=/dev/urandom | tr '\n' ' ')"
$ ./GodWords 
icebergs politicizing nonvirulent Caitlin's Babel croutons guillotined dingbats polygamous gild
21 2020-05-11 00:30

Send a mail to your future self.

sendmail anon@mail.org < mail.txt | at 7:00am  11:05:2021
22 2020-05-11 08:29

11:05:2021

why?

23 2020-05-15 15:21 *

>>22
current day + 1y?

24 2020-05-31 03:04 *

https://www.youtube.com/watch?v=tc4ROCJYbm0

25 2020-05-31 18:26 *

https://github.com/NARKOZ/hacker-scripts

26 2020-05-31 19:20 *

https://www.jwz.org/hacks/

27 2020-06-05 07:03

PIPE LOGIC

Delightfully useless epiphany: Suppose the null-byte is an electron. Then, /dev/zero provides an infinite supply of electrons and /dev/null has an infinite appetite for them. Let's call these devices Vss and Vdd, respectively.

In this model, a UNIX pipe acts like a wire, that is, a conductor with parasitic capacitance. [...]

https://www.linusakesson.net/programming/pipelogic/index.php

28 2020-06-10 02:34 *

A deeper introduction in Unix dc
https://ben165.github.io/unix_dc/index.html

c
20
k
[P1] p
3 600 d n [ ] n / sq
2 400 d n / sw
[
[0 n lt 2 + Q] sk
0 sc
0 sd
0 se
0 st
[
2 lc * ld * la + si
ld 2 ^ lc 2 ^ - lb + d sr sd
li sc
lc 2 ^ ld 2 ^ + d se
4 <k
lt 1 + d st
25 >f
#[ ] n lt n
[1] n lt Q
] sf
lf x
] sj
[
_2 sb
[lj x lb lq + d sb 1 >u] su
lu x
] sE
1 sa
[ [ ] p c lE x la lw - d sa _1<W] sW
lW x
[ ] p
#1.0 sa
#lE x [ ] p c
#0.8 sa
#lE x [ ] p c
#0.6 sa
#lE x [ ] p c

dc -f mandelbrot.dc > mandelbrot.ppm outputs this image https://ben165.github.io/unix_dc/mandelbrot.gif

29 2020-12-23 11:19

In Void Linux, /bin is a symlink to /usr/bin.

every distro i've used makes /bin a symlink to /usr/bin

30 2020-12-23 12:29 *

Upgrade to the plan9 haters handbook.
>>29
Bumped half a year later.

31 2020-12-23 12:49

oh whoops

32 2020-12-26 00:48

ALL HAIL LISP OS!
https://www.microsoft.com/en-us/research/publication/a-fork-in-the-road/

33 2020-12-26 03:33 *

>>32
This is why lispers are considered inane and schemers are reasonable.

34 2021-02-09 07:40 *

prophile of the UNIX terrorist
http://phrack.org/issues/65/2.html#article

35 2021-02-16 16:20

Make your linux distro more inclusive.

$ echo "alias woman=man" >> ~/.bashrc
$ sudo ln -s /usr/share/man/man1/man.1.gz /usr/share/man/man1/woman.1.gz
$ woman woman
36 2021-02-16 17:09

>>35
Emacs already has woman: https://www.gnu.org/software/emacs/manual/html_node/woman/index.html

37 2021-02-16 17:48

>>36
Is there anything Emacs doesn't have?

38 2021-02-16 18:00

>>37
A novice of the temple once approached the Master Programmer with a question: “Master, does Emacs have the Buddha nature?” the novice asked.

The Master Programmer had been in the temple for many years and could be relied upon to know these things. He thought for several minutes before replying: “I don’t see why not. It’s bloody well got everything else.”

39 2021-02-17 19:55

>>37
Shame

40 2021-02-20 12:44 *

>>39
There was no need for it.

41 2021-02-20 18:09 *

>>34

Member of: NAMBLA

Based

42 2021-03-23 01:28 *

https://www.cyberciti.biz/open-source/command-line-hacks/tmpmail-temporary-email-right-from-linux-unix-bash-shell/

43 2023-04-27 12:28

Do you love M4, too??
http://www.cs.stir.ac.uk/~kjt/research/pdf/expl-m4.pdf
https://www.jpeek.com/articles/linuxmag/2005-02/
https://mbreen.com/m4.html
https://elly.town/d/blog/2022-01-05-m4.txt

>>6
MAWK or GAWK.
https://www.gnu.org/software/gawk/
https://linux.die.net/man/1/mawk

44 2023-05-05 08:15 *

>>43
I do not like M4. I hate Perl and I'd rather deal with Perl than deal with M4.

45


VIP:

do not edit these