Windows is an Operating System and if you are new to Linux there is a good chance you're running that or Mac OS. Linux is a Unix based system created by Linus Torvalds and use something called the kernel to integrate against hardware.
Flavours
There are a couple different flavours of Linux the mains two being Debian and fedora. Systems like OpenSuse, CentOS, and RedHat are based on the Fedora style and use rpm files to install packages. While Ubuntu and Kali are based off of Debian and use .deb files to install packages. Essentially they're just different ways and opinions to get the same thing done. The flavours are called distributions and can be created by anyone with a need and knowledge to do so.
Distributions
Flavours in reality are all really just distributions and people alter certain aspects of really popular distros like Debian into something like Ubuntu which has user friendliness in mind. At the same time Debian was ported over into a security focused distribution called Kali. The goal of Kali is to give security professionals all the tools they need but not everything works out of the box. They expect you to have a certain level of understanding if you are using their software compared to the folks who put Ubuntu together and expect you to never use a shell. Things like the programs installed, the desktop environment used, the package manager, and the under lying security tools like SELinux. There are tons of distributions and its become such a thing there is a site just to track it, def check it out distrowatch.com.
Common Patterns
The work we have to do is pretty much the same even though we work on may different versions of Linux. I work a lot with Alpine linux which was made to be small and secure. It was based off of a linux distribution created for network equipment so light weight and secure were the priorities when creating it. They ended up making their own package manager called apk(not like the android apk). The reason I say this is because this entire blog will focus on patterns of use. While we have apk files you install with sudo apk install thing
with a slight change we can do the same else where like ubuntu sudo apt-get install thing
or fedora sudo dnf install thing
. This is the pattern sudo
for administrative privileges, apt-get
or dnf
for the package manager, and install
as the command you want the package manager to execute followed by the package/thing
you want to install. These patterns exist every where from how we bundle software to how we release code all the way up to the code itself. Now the code, tools, and clouds we use might all be variables that change but patterns we use will always hold true.
Common Terms
- Repository - A place that stores things like code or bin files.
- Package manager - Downloads packages from repositories.
- .RPM/.DEB file - This is what is actually being installed when you run those fancy apt-get / dnf commands.
- Github - A website on the internet where we store code.
Things you need to know
We can't know it all, but some things go without saying. This is a list of things you should def know if you want to familiarize yourself with Linux.
File permissions
chmod / chown much lately?
- Check out some documentation on file permissions and how they work.
- Use chmod to alter permissions.
- Use chown to change who owns a file.
- Make sure to pay some attention to the idea of groups and user.
- Make a file root and try to access it with and without sudo.
- Where are the users stored?
- What does the
/bin/bash
represent in the file name where the users are? - How do the numbers work when reading permissions?
- How do we add a user to a group?
- What is chroot?
Shells
Shells vs Terminals they really are two different things. I use Terminator as a terminal with ZSH as my shell. Having an understanding of how PATH works with shells and terminals gives you a good idea of how to extend you system with binarys that don't normally ship with your package manager like Terraform and Helm.
- Read about stdin, stdout, stderr
- Read about $PATH
- Compare bash to something like zsh
- Compare the default terminal to something like Terminator
Operators
Operators turn commands into magic, really, you look like a wizard dropping one liners in shell.
- Read about all the operators available and what they do.
- Try piping an
ls
to agrep
and narrow down a search. - Try creating a file from an
echo
and>
. - What is the difference between one
>
and>>
?
Networking
It's a tangled web we weave..
- Ping something
- How do you pull up an ip address?
- What do your network interfaces look like?
- Can you tell me which ports are currently open?
- Which ones are open as root?
- Can you turn on SSH and open a rule in the Firewall to allow it to work?
- Nmap / Zenmap - Can you find some computers on your own network and their open ports?
- What's an IP address? (internal and external)
- What's a MAC address?
- What layer does IP work on in the OSI model?
- What layer does a MAC address work on at the OSI model?
- What is a layer 3 switch? (not so much linux but general networking)
- What is a hub? (not so much linux but general networking)
- What is a router? (not so much linux but general networking)
Scripting
Lets tie it all together.
- Create a file called script.sh.
- Give it executable permissions.
- Add
#!/bin/bash
to the top. - Add some of the commands we worked with.
- Run the script and admire its results.
- Checkout how to feed an argument to the script.
Linux isn't Windows
- How do the package managers compare to Windows update?
- Try changing the default desktop environment on Ubuntu from Unity to Gnome3 or maybe something else?
- Learn about character endings in Windows vs Linux and where to find the icon idicator in VScode for it.
Makefile
Getting gud? Try compling software from scratch on your system. Expect a pro to know all the packages you need to make this happen and some of those commands off the top of their heads.
- Makefile - What is it and how does it work.
- Devl packages - What now? Development packages for short, these suckers are the devil because if you're using them you're in "there be dragons here" land. You need these for makefile to work. No, seriously its short for development packages. They give you the ability to compile software on your machine. Compiling is the process of turning human readable code into machine readable code. The machine code is respective to the processor architecture which you compile for like x86 for Intel.
- Compiling - That conversation about how machine code gets put together for a particular language which is unique to the processor crunching the instructions. My buddy Lucas is building a compiler for a brand new programming language and the challenge he faces is getting that machine code to run on all the different processors. This is already done for you when you use a c compiler but if you're making one from scratch finding a common way to walk to all the architectures becomes a thing. This thing is called LLVM lower level virtual machine and it allows him to write one compiler that can interact with an intermediary program which will then create all the different verisions of the machine code from one set of instructions writting in llvm. This is probably a lot for beginners but we were covering this in the channel and thought it really solidifies the idea of going from something we create as humans to something the machine understands.
Next article will probably be creating an SFTP server because it gets folks thinking about folders, groups, and permissions.
Leave a Comment