
Ask HN: Best way to learn *nix and shell? - moonfleet
I got into programming fairly recently and currently I am working as a frontend dev. Often I find myself at a loss when I need to do simple tasks in the terminal, such as start a db server, handle packages, set up symlinks and paths. So, I end up going on stack overflow and mindlessly copy-pasting commands into my shell, hoping it would resolve the problem. I feel like I have a huge mess in my root directory and I don&#x27;t know how to clean it up.<p>I tried to learn unix and shell by installing and using Arch Linux on my old laptop but I just ended up following tutorials without really understanding what I am doing. Right now, I am using MacOS.<p>What are some good resources that teach you more than cd, ls, mkdir and touch? How did you learn it?
======
asicsp
I have a list of resources collected here [0] but they are mostly oriented
towards `bash` and `linux` (I think Mac uses `zsh` these days) - there are
enough differences to warrant this disclaimer

* [https://ryanstutorials.net/linuxtutorial/](https://ryanstutorials.net/linuxtutorial/) is a good place to start for beginners

* [https://mywiki.wooledge.org/BashGuide](https://mywiki.wooledge.org/BashGuide) and the rest of this wonderful wonderful site is recommended to understand `bash` and its features and gotchas

* [https://explainshell.com/](https://explainshell.com/) gives you a quick help on the various parts of the command, including documentation

* [https://www.shellcheck.net/](https://www.shellcheck.net/) is a must have tool if you are writing shell scripts

* [https://linuxjourney.com/](https://linuxjourney.com/) is probably the most complete site to understand how things work in *nix environment

[0]
[https://github.com/learnbyexample/scripting_course/blob/mast...](https://github.com/learnbyexample/scripting_course/blob/master/Linux_curated_resources.md)

~~~
moonfleet
Hey, thanks for sharing these! I will definitely check them out. And yes, zsh
is the default shell on Catalina, although bash and other common ones are
available and easy to switch to.

------
akersten
I don't have any resources beyond recommending searching something like "linux
command line basics" in your favorite search engine, but I do have some
advice. You have to conceptualize it at a higher level than "shell commands:"
the shell is just a way to run programs, and pass arguments to those programs
to do what you want. The names and parameters of most common programs like ls,
touch, mkdir, etc[1]. will become second-nature over time. There's no fast-
path to learning them, you just have to force yourself to use the command line
in your daily workflows.

They look like 'commands,' but what's actually happening is the shell is
searching directories that are listed in your $PATH environment variable, for
an executable with the name you entered. Diving more into the mechanisms of
how the shell works is potentially educational depending on your learning
style.

Starting with Arch, you're setting yourself up for a bad time, since you'll be
learning both basic command-line knowledge and how to configure linux from
scratch. Ubuntu or Fedora might be better places to start. OSX will suffice
for a unix-y environment, but there are definitely some quirks that won't
translate nicely to linux-y distros if that's the direction you want to go.

Larger objectives you mention like starting a server, the first principle is
still "what program can I run (i.e. call from the shell) to do what I want?"
And in this case, it would be the program that manages processes for your
system. Not sure what Mac uses, but many linuxes are using `systemd` nowadays.
If you search `systemd basics` it will give a good sense.

[1] Shells also have built-ins (like cd) and you can learn a lot about the
intricacies of them by doing actual shell scripting (e.g. "bash tutorial"),
but it sounds like you're mostly interested in getting your feet wet with the
basics before diving into scripting. Although it's a nice way to round out
your knowledge.

~~~
moonfleet
Thank you for your advice.

> what's actually happening is the shell is searching directories that are
> listed in your $PATH environment

These kinds of explanations is what I actually need. Many tutorials I have
followed explained which command to use when I want to have X done. Instead, I
need to know what those commands actually do on a lower level.

------
eyberg
Install a linux distro on your own laptop without X. Force yourself to do
_everything_ from the shell. {mutt, lynx, etc.}

That's how I learned not only to use a shell but also how I learned to
program.

~~~
eyberg
I forgot to add - I did this in the 90s you can do this in the 2020s. :)

~~~
sprobertson
My memory banks are truncated enough that I can do this every 5 years and
learn something new.

------
poletopole
N&R's "Learn The Bash Shell" is as good as it gets. I scanned it with my SV600
if you want a PDF copy.

~~~
moonfleet
Thanks for the book recommendation. Yes, I would love to have a PDF of that.
How would I be able to get my hands on it?

