[HN Gopher] Getting better at Linux with mini-projects
       ___________________________________________________________________
        
       Getting better at Linux with mini-projects
        
       Author : carltheperson
       Score  : 598 points
       Date   : 2021-02-02 15:47 UTC (7 hours ago)
        
 (HTM) web link (carltheperson.com)
 (TXT) w3m dump (carltheperson.com)
        
       | rootsudo wrote:
       | Welp, he's done more than me. I kinda stopped writing C++
       | programs back a decade ago and Carl is making grep games and
       | seashells.
        
       | freedomben wrote:
       | Kind of a shameless plug, but you mentioned wanting to get better
       | at Awk. I had that same desire and created a small course based
       | on what I learned. The course got great feedback. I've gotten a
       | lot of nice emails from people thanking me for making Awk
       | understandable to them for the first time. I love getting those
       | kinds of messages!
       | 
       | There is a video presentation, and a set of "challenges" you can
       | use to incrementally get more complex with awk, starting from
       | super simple.
       | 
       | The challenges repo is on github here:
       | https://github.com/FreedomBen/awk-hack-the-planet
       | 
       | If you want to watch the videos, there are links in the github
       | repo but for convenience:
       | 
       | Presentation video: https://youtu.be/43BNFcOdBlY
       | 
       | My solutions to exercises video: https://youtu.be/4UGLsRYDfo8
        
         | Defenestresque wrote:
         | Hey, thanks for making the course free! I'm sure it took a lot
         | of time and effort. I'll be definitely checking it out.
        
       | dakna wrote:
       | > The first thing I did was to read the entire Wikipedia page on
       | UNIX. I also read this original paper written by Dennis Ritchie
       | and Ken Thompson from 1974
       | 
       | We need more people like you. Kudos for having the attention span
       | to do this. Enjoy your HN top spot, well deserved.
        
         | RicoElectrico wrote:
         | I find good Wikipedia articles with competent copy-editing,
         | pure fact and no nonsense to be a good read - at least much
         | more so that many pseudo-intellectually-sounding articles from
         | a few outlets that get posted on HN regularly.
        
           | moehm wrote:
           | If you find yourself one day without a good Wikipedia article
           | to read, I collect (good) articles and their respective
           | discussions posted on HN here:
           | 
           | https://www.mostdiscussed.com/
        
             | dakna wrote:
             | Nice work combining the two sources, saved!
        
         | mistoffelees wrote:
         | That level of attention span is incomprehensible to me!
        
         | segmondy wrote:
         | When I got into Unix in the 90's, the first thing I did was
         | read all the man page for every command and tried to run as
         | many of them as I could with as many options. Decades later it
         | still pays off. If you want to get good at sometime, just dive
         | in.
        
           | carltheperson wrote:
           | Interesting how Unix/Linux knowledge stays relevant for so
           | long. It feels like a lot of tech knowledge today gets
           | obsolete every few years.
        
       | unixhero wrote:
       | Getting better at the shell
       | 
       | Actually I recommend reading the entire man page for bash.
       | 
       | Edit:
       | 
       | https://linux.die.net/man/1/bash
        
         | cpach wrote:
         | I take it you mean the _Info manual_ for Bash? ;-)
        
           | unixhero wrote:
           | Maybe I am! :)
           | 
           | I think maybe you are referring to those numbers people used
           | to quote after mentioning a manpage (1) (5) and so on. I
           | totally missed the boat on that one, and never learnt what
           | these designations meant.
        
             | _kst_ wrote:
             | The numbers, as in "bash(1)" refer to sections of the
             | manual.
             | 
             | "Info" is a different documentation format, most commonly
             | used for GNU tools (including bash). The section numbers
             | don't generally apply to info documents.
             | 
             | For some tools, the man and info documents have the same
             | information. For some, the man page is a brief summary that
             | directs you to the info documentation. For some, there's
             | only a man page. (And for some there isn't even that.)
        
             | lordgrenville wrote:
             | https://unix.stackexchange.com/questions/3586/what-do-the-
             | nu...
        
             | cpach wrote:
             | Nope :) The joke was referring to the fact that the GNU
             | Project (and thus the Bash project) insists on writing
             | their documentation in the Texinfo format.
             | 
             | IIRC for a while they used to have man pages that basically
             | said "just read the Info pages instead". This is not the
             | case anymore, in Linux distros these days even the GNU
             | tools have decent man pages.
             | 
             | Anyway, the Bash manual is actually written in the Texinfo
             | format. It's not so bad, to be honest :)
             | 
             | https://www.gnu.org/software/bash/manual/
        
       | Arrath wrote:
       | As someone who's only exposure to non-windows systems is 20
       | minutes with the raspberry pi I picked up the other week, I think
       | this will be a great resource for me to follow along with as I
       | familiarize myself with everything. Thanks!
        
         | carltheperson wrote:
         | Let me know if you have any questions.
        
       | NexRebular wrote:
       | What a fantastic idea!
       | 
       | Should utilize something similar in teaching FreeBSD and illumos
       | too.
        
       | Farfignoggen wrote:
       | Interesting but can there be a project to get OpenCL over Vulkan
       | so maybe there can be out of the Box/ISO support for OpenCL for
       | Linux on AMD's Ryzen APUs for OpenCL compute without having to
       | install the OpenCL parts from the AMD Linux Pro driver stack.
       | 
       | MESA appears to be All about OpenGL and Vulkan for Games but
       | there's not much attention paid to OpenCL and GPGPU compute for
       | Things Like Blender 3D's GPU Accelerated Cycles rendering, and
       | other Applications like Dark Table, Gimp, etc. that need OpenCL
       | for GPGPU/Compute acceleration workloads!
       | 
       | There really needs to be a Primer for Linux and How that OpenCL
       | is plumbed into the system and what files are used to get that
       | all working on Both Integrated and Discrete GPU based laptops! So
       | What's the Linux equivalent of MS's WDDM and how does the Linux
       | Kernel get Graphics and the Graphics APIs and Drivers working
       | properly for User Space Applications to make use of.
        
       | mqus wrote:
       | Another more Linuxy-Thing to try: build a pam
       | (authentication/authorization/etc) module to embed your own
       | secret or come up with a fun/unique way to enter your password
       | (e.g. you can not login unless you plugged your headphones in,
       | etc :) )
       | 
       | This makes you very aware of the way login works in linux and
       | teaches you how to compile your library as a shared object
       | conforming to an interface. Of course, you should be aware that
       | you just baked your own security mechanism, so use it that way
       | and better avoid using it for anything sensitive :)
        
       | uyt wrote:
       | Projects like these is exactly what university use for teaching
       | too! You're way ahead of the curve.
       | 
       | For example CMU also makes you write your own shell. The main
       | focus is implementing job control like: jobs, fg, bg, and various
       | signal handlers in order to understand how forking child
       | processes work.
       | 
       | I see that your shell doesn't handle much other than cd so this
       | might be a nice next step if you want to continue working on it.
       | (I can't find a good public link for it but you can probably
       | follow along using:
       | http://www.cs.cmu.edu/afs/cs/academic/class/15213-s02/www/ap...)
        
         | mav3rick wrote:
         | 213 is a wonderful course
        
       | temp0826 wrote:
       | Surprised that Linux From Scratch hasn't been mentioned. Probably
       | the best soup-to-nuts walkthrough out there for learning deeply
       | about Linux. And I do agree with others that this is commendable-
       | I remember my struggles with getting into *nix vividly. Keeping a
       | beginner's mindset and staying humble will take you far.
       | 
       | http://linuxfromscratch.org/
        
       | code_scrapping wrote:
       | Hi Carl,
       | 
       | purely judging from your profile picture it seems that you're
       | about half my age :) and I think it's excellent that you're doing
       | a bunch of things - personal blog, linux, tutorial post... Just
       | remember - most of the guys around here tend to do it for
       | marketing reasons (i.e. we want to find a job and we're
       | advertising our capabilities), and those projects might not be
       | the most interesting things out there.
       | 
       | Bottom line is - just because everybody else is doing it, might
       | be because they have different motives than you, and I hope
       | you'll do/build firstly what's interesting and fun, and secondly
       | what's financially viable.
       | 
       | Good luck, have fun!
        
         | dj_mc_merlin wrote:
         | I got hired at (probably about his age?) just due to side
         | projects like this. If nothing, it shows motivation. So it's
         | got a marketing reason nonetheless.
        
         | carltheperson wrote:
         | I'm 18 (:
         | 
         | Thank you so much for the heads up. I'm only doing this because
         | it's fun! I love using Linux and I feel like I learned a ton
         | from this.
        
           | smlckz wrote:
           | being slightly younger than you, i can not but envy you: i
           | have done zero projects or had fun like you have had. hmm.
        
             | log101 wrote:
             | Envy = Desire, I'm sure you'll do similar side-projects
             | soon!
        
           | jvanderbot wrote:
           | At what point did the smiley face reverse? It seems anyone
           | under 24-ish uses (: where as I know it as :)
        
             | colonwqbang wrote:
             | Many services will auto-translate :) into something else,
             | like a colourful unicode icon. If you prefer to keep your
             | smiley looking like just a smiley, (: is an effective
             | workaround.
        
               | adembudak wrote:
               | > tac "(:"
               | 
               | > :)
        
               | NoodleIncident wrote:
               | There's also an upside-down emoji smiley with its own
               | distinct mood. Hopefully services don't start translating
               | (: into that, they're used quite differently!
               | 
               | https://blog.emojipedia.org/emojiology-upside-down-face/
        
             | thebruce87m wrote:
             | And when did the nose fall off too?
        
               | newnamenewface wrote:
               | I blame reddit for this one. :^) needs to be escaped for
               | else the mouth floats away.
        
       | imhoguy wrote:
       | Another programming exercise: writing own userspace VFS (Virtual
       | File System).
        
       | tyingq wrote:
       | _" Since this is just a reverse version of cat, I called the
       | program recat."_
       | 
       | Curious if you compared the end result with "tac".
       | 
       | Source:
       | https://github.com/coreutils/coreutils/blob/master/src/tac.c
       | 
       | Walkthrough of how it works:
       | http://www.maizure.org/projects/decoded-gnu-coreutils/tac.ht...
        
         | bloak wrote:
         | See also "rev": https://git.kernel.org/pub/scm/utils/util-
         | linux/util-linux.g...
        
           | tyingq wrote:
           | Ah, yes, though that reverses each line of text individually
           | while maintaining line order, versus reversing the whole
           | file.
        
           | bewuethr wrote:
           | The recat tool shown seems to have the same effect as
           | tac | rev
        
             | tyingq wrote:
             | Ah, I see what it does now, thanks for that.
             | 
             | It's not exactly the same as "tac | rev" though. For a
             | typical text file with each line ending in a newline...this
             | recat tool outputs a newline first, and the last line is
             | missing a newline. So it's a true reverse printing of last
             | byte to first.
        
           | _kst_ wrote:
           | Years ago, I wrote a filter that reversed lines and reversed
           | characters within each line after padding with blanks. I ran
           | a text file through it, printed the result, turned the paper
           | upside down, and complained to a sysadmin that the printer
           | was rotating each character in place. (I didn't keep them
           | hanging for long.)
        
       | jvanderbot wrote:
       | What a great bundle of projects. Kudos.
        
       | trilinearnz wrote:
       | Wholesome, and tangible results to boot. A great role model of
       | 'growth mindset' for other people who are interested in
       | technology.
        
       | jldugger wrote:
       | > That thing ended up being a program that reverses the contents
       | of a text file. Since this is just a reverse version of cat, I
       | called the program recat.
       | 
       | because `tac` was already taken ;)
        
       | leephillips wrote:
       | I'd like to echo some other comments and mention that this is the
       | way to learn things like this. If I want to learn a new
       | programming language, I write a program in it. I think the
       | author's Createservice script might be useful!
        
       | geocrasher wrote:
       | According to a post in the comments, the author is 18 years old
       | which means that I've been using Linux longer than the author has
       | been making use of the blood in his veins. But that does not mean
       | that I didn't learn something from his post!
       | 
       | While the technical accomplishments and understanding are
       | commendable, I think that the main takeaway for me is the
       | excellent approach to learning. Keeping it simple and taking an
       | open-minded approach to learning (as exemplified by his attitude
       | toward systemd) is an approach that more people could stand to
       | take. So often we complicate things in our heads to the point
       | where they seem unknowable and so we assume that they are too
       | difficult and we don't try. I have seen this in myself at times
       | and I see it others as well.
       | 
       | I'll be sharing this post at work so that the people who I work
       | with who don't really understand Linux so well can appreciate the
       | approach that was taken and hopefully also glean something from
       | the excellent write-up itself.
        
         | carltheperson wrote:
         | Thank you so much for your awesome comment. You made my day!
        
           | geocrasher wrote:
           | /tips hat
        
         | the_cat_kittles wrote:
         | its also refreshing to see someone read a couple articles, do a
         | small project, and be happy with the basic understanding they
         | have gained. people think you need to be an expert at
         | everything you do, but having a working knowledge of lots of
         | tools is great and this seems like a wonderful way to acquire
         | that.
        
           | geocrasher wrote:
           | I completely agree. I pride myself in having a smattering of
           | knowledge in a wide range of topics. As a result I can have
           | an intelligent conversation nearly anyone on almost any
           | topic. This in itself is _extremely_ valuable.
        
         | ghoomketu wrote:
         | > I think that the main takeaway for me is the excellent
         | approach to learning
         | 
         | As in the well-known dictum by Richard Feynman, "What I cannot
         | create, I do not understand," successful design is also a
         | powerful way to show that a design principle has been
         | understood.
        
         | abnry wrote:
         | I am not the author but this is such a lovely comment and a
         | great thing to see on HN.
        
       | RMPR wrote:
       | > Can't knock it till you try it, so here I am trying to learn
       | Bash scripting.
       | 
       | For bash scripting I found Julia Evans' zine bite size bash very
       | interesting. Even though I had been scripting for quite some time
       | I found hidden gems in there.
        
       | __soter__ wrote:
       | This kinda mirrors advice I would give my younger sibling when he
       | was struggling to pick up programming, even though that is the
       | direction he wanted his career to go. He thought he needed to
       | know everything and saw that as an impossible mountain to climb.
       | My advice to him was to find a small problem he cared about in
       | the world or at home and develop a solution. When it's a problem
       | you care about or want resolved, you are more invested and
       | learning becomes fun. Then you can build on those skills with
       | what ever you find to work on next.
        
       | fuball63 wrote:
       | I really like the idea of using games to teach command line
       | concepts, like the author did with grep and find. There have been
       | several other ones that have popped up about using vim [1] and
       | navigating a filesystem via cd/ls[2].
       | 
       | I've always wanted to make a unix sandbox environment, using
       | FreeBSD jails provisioned from a webapp, that has little
       | challenges and games to teach the basics of the command line all
       | the way up to hosting a basic HTML website with Apache.
       | 
       | Is this something people would find useful? I've been thinking
       | about implementations but I don't want to jump too far into it
       | without validation that this would be something people would find
       | helpful and interesting.
       | 
       | [1] https://vim-adventures.com/ [2]
       | https://gitlab.com/slackermedia/bashcrawl
        
         | krylon wrote:
         | It sounds like a brilliant idea. I remember learning my way
         | around vim and emacs from interactive tutorials that were
         | basically just text files. I had _no_ idea what I was doing,
         | but it was fun to experiment.
         | 
         | If you implemented your game, I would definitely give it a try.
         | More for fun than for the learning experience, but if I happen
         | to learn something new along the way, I certainly would not
         | complain. ;-)
        
       | AdmiralAsshat wrote:
       | I always thought about writing a GNU/POSIX utility called 'pp'
       | (prepend), that would simply take an input file and insert it
       | above the first line of a target file. So, essentially, if I have
       | a CSV file without a header and want to quickly insert the header
       | file, I would run:                 pp header.txt spreadsheet.csv
       | 
       | And it would be the equivalent of:                 cat header.txt
       | spreadsheet.csv > temp       mv temp spreadsheet.csv
       | 
       | But also support all of the expected POSIX niceties, reading from
       | stdin, etc.
       | 
       | But I never got around to it, and it's been a few years since I
       | had to use C at my day-job (which was never great to begin with),
       | so it fell to the wayside.
        
         | dj_mc_merlin wrote:
         | Why not just `pp() { echo -e "$(cat $1 $2)" > $2;}`? It can
         | read from stdin just fine.
        
         | jamespwilliams wrote:
         | sponge from moreutils is useful for this, eg
         | cat a b | sponge a
        
         | tyingq wrote:
         | The old line editor, ed, is good at this for files. I assume
         | you could tinker a bit to get stdin support.
         | echo -e "0r header.txt\nw" | ed spreadsheet.csv
        
       | jlangemeier wrote:
       | One of the biggest improvements I saw in my Linux usage/admin was
       | when I started trying to challenge myself to use the mouse as
       | little as possible; it was absolutely eye-opening when I could
       | navigate around my machine, do all of my everyday processes, and
       | never really leave "home row". It also made VM'ing into a windows
       | server a total pain because it was fairly quickly back to
       | "clicky-clicky" navigation and processing (although win+R,
       | tabbing and arrow keys could get you by about 90% of the time).
       | 
       | Great article, and great approach to learning the inner workings
       | of the standard Linux suite!
        
       | acomjean wrote:
       | neat. Great way to explore the systems.
       | 
       | For me out of university, it was a co-workers books (some of
       | which I ended up buying) that help me understand the role of UNIX
       | better (I used the alpha machines at university, but was thrown
       | into HPUX/Solaris at work..)
       | 
       | I think this was one: https://www.amazon.com/Advanced-
       | Programming-UNIX-Environment...
       | 
       | Of course a little out of date now, but a lot of the general
       | concepts are the same.
       | 
       | Unix Power Tools helped me a lot as well.
       | https://www.oreilly.com/library/view/unix-power-tools/059600...
       | 
       | How did others learn this stuff?
        
       | smlckz wrote:
       | On 8. Processes - Stranger Danger: some improvements
       | sudo ps -ef | awk -v user=$USER '$1 != user && $1 != "root"'
        
       | FactCore wrote:
       | I've been sniffing around for projects to do to improve my coding
       | ability and understanding of different programs/languages. Your
       | article really motivated me to start some small projects of my
       | own! I like the idea of not getting yourself down with giant
       | projects and instead just making small applications of new
       | technologies you want to learn.
        
         | carltheperson wrote:
         | It makes me so happy that I motivated you to create projects.
         | Good luck!
        
       | mraza007 wrote:
       | What a great way to learn more about linux. really interesting
       | article, I love how you implemented the programs in Golang.
       | 
       | I had a very similar idea of implementing the Linux programs in
       | python back then.
       | 
       | Keep it up !!!
        
         | carltheperson wrote:
         | The main reason behind why I choose Golang was that it compiles
         | to binaries, but it is also a really simple and easy to learn
         | language.
        
       | jzer0cool wrote:
       | When I took a programming class a student sitting next to me
       | introduced me to Linux. I was like "what is that?" I honestly
       | thought these kinds of machines were just in the movies. I loved
       | how it boot in a black screen, text scrolling, and there was a
       | penguin. Unlike today, there was no Ubuntu. I didn't have
       | wireless at home.
       | 
       | It took a while to get Disks burned to install. I had struggles
       | moving back and forth between two machines across rooms to look
       | up "help" documentation from the internet. When it was all
       | installed, nothing worked. Network cards, sound, etc. When my
       | network card worked, it felt like heaven. When my screen
       | resolution was fixed (x11 settings), felt like heaven. Repeat.
       | 
       | He had asked, do you really want to learn how it works? I said,
       | yes, let's start there. I was very confused with all the Linux
       | variants so he recommended one. Now I look back and unsure that
       | is where I should have started. L.O.L.
        
       ___________________________________________________________________
       (page generated 2021-02-02 23:00 UTC)