Chapter 2 - Installing Arch Linux #
I am working on a new install guide located at
archnew , though it is still a work in progress. The new guide is based on the offical install guide, among other pages from the wiki, and adds running commentry and advice in an attempt to help new users while still sticking to some of the Arch ethos.
Some Background #
Unlike Windows or Mac which are primarily differentiated by versions (Windows XP, Vista, 7, 10…), Linux has two important things to look out for:
- The distribution name (Arch, Ubuntu, Mint, Debian, etc.)
- Kernel version number (5.12 last time this page was updated)
So, what do each of these mean?
Well, Linux is actually just the name of the underlying ‘core’ of the system, known as the kernel, as such, there are literally thousands of Linux variations or ‘distributions’. Some of the well known variants include Ubuntu, Fedora, OpenSuse, and Arch (No disrespect to the other distros out there!). Each of these has a different target audience, with some meant for servers, some meant for casual users as an alternative to Windows, others as work station for hard core computing. They also ship with different software pre-installed to be accessed after the first boot.
The other differentiating factor is the version of the Linux Kernel that they use. Some chose to use an older, battle hardened kernel that is known to be very, very stable, others chose a nice middle ground, while yet others continuously release an update to the newest available kernel. There are pros and cons to each model and each has its place; however, the distro I’m going to have you install, Arch, uses the (almost) the newest available, updating very regularly. Arch has a reputation as one of the hardest distros to work with, but also one of the most cutting edge, fun to tinker around in, and best documented.

Arch Linux Logo from archlinux.org
For most distros like Ubuntu or OpenSuse (feel free to look these up, this page isn’t going anywhere) there’s a nice graphical, point and click installer which helps you install the system and somewhat mitigates potential risk of killing your original OS (Mac/Win) or losing data; however, the goal of this guide is to learn. Arch’s install process, entirely by typing commands in this terminal is hard, but that difficulty leads to a deeper understanding and respect for the system as a whole
When we’re done you’ll have a system that has exactly what you need and nothing you don’t. You won’t find weird forcibly installed software like Win 10’s Candy Crush App here, and your system will only do exactly what you tell it. Of course, this implies you know how to speak it’s language and tell it what you want. Thankfully with some practice you’ll get used to running Arch and you’ll wonder why you ever dealt with other systems to begin with.
Preparation #
Install instructions will vary dependent on your hardware, but I’m going to assume you have a desktop or laptop which shipped with Windows 10 and has a UEFI system. Most laptops newer than ~2016 should be in this category. If your system uses a BIOS or Legacy boot instead, or if you have a mac, this won’t apply to you, but you should be able to follow some of the resources I used to make this guide which are linked below along with some searching online to figure it out.
Alright, so what exactly are you getting yourself into? Well, I’ll be real with you, a lot. Installing Arch sucks. Things can go wrong, it’s not user friendly at all, and is generally a pain, and if you screw up you’ll need someone who can restore your computer to at least having Windows on it again so I’ll say it again- Make a backup of your entire hard drive before proceeding, if you don’t know how to do this, look up how to use Clonezilla.
Okay, so, with that said let’s dive into it. After you have a backup, you’ll need to head on over to https://www.archlinux.org/download/ and if you have a torrent client installed use the provided BitTorrent Downloads, if you have no idea what that is, look at the below box
BitTorrent: Torrenting is type of download that runs over distributed peer to peer connections, this means you’re directly downloading the file from multiple people rather than from one large server. Popular clients on Windows include uTorrent, qBittorrent, and Deluge
You may want to go grab a coffee while it downloads depending on your connection, though the image should be rather small. Once that’s done downloading your torrent client should automatically confirm the image by checksum, but as this is a good learning opportunity let’s do a manual double check as well.
checksum: a mathematical summing of the bits in a file combined with some sort of cypher to produce a ‘hash’ which can be checked to against one that is known, any modification would result in a different hash. This protects against malicious actors putting bad things in the code as well as from a corrupted download.
Windows #
open up a command prompt by pressing ctr+r and typing ‘cmd’ then enter, and we’ll need to navigate to the location of the downloaded file it should be named something along the lines of archlinux-20xx.xx.xx-x86_64.iso and be in your Downloads folder. When you open a command prompt on Windows it should start out in your user folder (C:\Users%username%). To list the folders in this folder you can type ‘dir’ and press enter. You should, at minimum, see folders like ‘Downloads’ ‘Desktop’ and ‘Documents’ to enter the Downloads folder simply type ‘cd Dow’ and press tab, the line should auto-complete to ‘cd Downloads’, then press enter. Now you can type ‘certutil -hashfile arch’ , press tab to complete it to ‘certutil -hashfile archlinux-20xx.xx.xx-x86_64.iso’ then add ‘sha1’ on the end so the finally command looks like
|
|
Note, if this spits out “The process cannot access the file because it is being used by another process.” you’ll need to close your torrent client or stop seeding the file first!
So let’s look at this command. The first part, certutil, is a program on your computer, ‘-hashfile’ says the next string of text is the name of the file we want to examine, and the last part sha1 is the checksum as mentioned before. Finally, if you go back to https://www.archlinux.org/download/ and look under ‘Checksums’ you can compare the output of the command you just ran against the SHA1 sum provided to be sure you didn’t have any errors in the file. This is mostly a security check as in theory someone could provide a ‘bad’ version of the OS containing malware, but such a version would produce an incorrect checksum, in practice this is extraordinarily uncommon. Though this does also serve to ensure the download wasn’t corrupted in any way either.
Mac #
open up a terminal by going to the Utilities fore in Applications and open ‘Terminal’. The mac terminal is very, very similar to what you’ll use in Linux actually, and the commands here are actually identical. You should see something like
|
|
waiting for input.
That ~
represents that you’re in your user or ‘home’ folder, and assuming you downloaded Arch’s install image to your downloads folder you should be able to type
MacBook:~ username$ shasum -a 1 Downloads/arch
followed by pressing tab to make that auto complete to something like
MacBook:~ username$ shasum -a 1 Downloads/archlinux-20xx.xx.xx-x86_64.iso
upon pressing enter the terminal should print out a long string of text.
So let’s look at this command. The first part, shasum, is a program on your computer, ‘-a 1’ says to use the sha1 algorithm instead of something like sha256, and the last part is the filename we want to compute the checksum of. Now, if you go back to https://www.archlinux.org/download/ and look under ‘Checksums’ you can compare the output of the command you just ran against the SHA1 sum provided to be sure you didn’t have any errors in the file. This is mostly a security check as in theory someone could provide a ‘bad’ version of the OS containing malware, but such a version would produce an incorrect checksum, in practice this is extraordinarily uncommon. Though this does also serve to ensure the download wasn’t corrupted in any way either.
Okay, so we have the OS, how do you install the damn thing? Well, get ready for a fun time. The first thing you’ll need is a flash drive with nothing on it you care about, as it’s going to be reformated, which will wipe any data on it. To install an OS you have to create ‘bootable media’ this used to be done with a CD, though mostly it’s done with flash drives now. You’ll actually be putting the OS on the flash drive and then using that to put it on your hard drive.
Let’s not get ahead of ourselves though, we need room to put the new operating system in! Thankfully Linux is small- really small. Even 50Gb should be plenty for the OS, all your programs, and tons of room to spare for data, but I typically recommend at least 100GB, and since we’ll be installing a lot of development tools, it makes sense to do this right to begin with.
Windows #
When you got your computer with windows is likely that all of the room on your hard drive was preallocated for windows (as it should be!) so we’ll need to shrink this down and make room for Linux to live along side Windows. Open the start menu and type ‘disk manag’ and hopefully “create or format hard drive partitions” will show up as an option. At the bottom you should see a few bars showing partitions on your disk(s). If you have multiple hard drives there will be multiple rows of bars, otherwise there will be only one row. If you have multiple drives it’s likely that one is a larger hard drive (HDD) and the other a smaller solid state drive (SSD), if you have room on your SSD use that, if you don’t using the HDD will be fine, but the OS may feel slower than you’re accustomed to. If you only have one drive, ignore this. Right click in what is likely the largest box, labeled ‘primary partition’ and chose ‘Shrink Volume’. After it finishes querying available disk space enter 102400 as the amount of room to shrink (This is 100GB as there are 1024MB in a GB) or a lower or higher value as you please, but realize this is data you will not be able to access from windows.
If the window shows 0MB of available shrink space first try running disk cleanup and choose cleanup system files, try turning off system restore, and finally disable the page file. In my experince it’s usually the pagefile, which kinda sucks. If none of this works, you do have another option: wiping everything and installing linux. This is actually easier, however, it’s a bit more extreme, as you won’t be able to boot back to windows for anythig. You may instead want to try linux out on an old usused computer first. Either way, you do you, but I’m not liable if things go wrong. https://medium.com/@terajournal/increasing-size-of-available-shrink-space-for-hard-drive-partition-in-windows-8fffa50535d3
Alright, we’re getting there I promise. You should now have a gray block next to that blue block of space that shows unused space, that’s perfect. Next up we’ll need to turn Fast Boot off. In my experience turning this off doesn’t effect windows boot time at all, and by having it off we’ll be able to access window’s file from inside linux later. To do this: go to ’edit power plan’, then in the top bar navigate back to ‘Power Options’, select ‘Chose what the buttons do’ on the left side, click ‘Change settings that are currently unavailable’ and then un check ‘Turn on Fast Startup’.
Okay, now we’re finally ready to copy the OS to a flash drive so we can install Arch, to do this, you’ll need to download a program called rufus https://rufus.ie/. Download, run, etc. When it opens select the flash drive as your ‘device’ , press the select button under that and select the archlinux-20xx.xx.xx-x86_64.iso file we downloaded earlier. Everything else should be fine, so click start. This may take a second, in the mean time, open this guide on another computer as the next few steps will require a lot of restarting and doing things outside of windows.
Mac #
Before we go any further I really want to warn you of two things, one, it’s going to be harder to follow this guide on a MAC. More steps are involved, and some work arounds are necessary, and more importantly, I have no experience with it. so I’m mostly regurgitating other things I’ve read. Pages like https://wiki.archlinux.org/index.php/Mac#Installation may prove helpful later.
First, you’ll need to open up ‘Disk Utility’ in Applications/Utilities, then pick your disk and click ‘Partition’ and click the ‘+’ button to make a new partition. Choose how much space you want to leave on the disk for MacOS and how much you want for Arch. The format of the new partition doesn’t matter.
Note, if your disk is encrypted, you’ll need to decrypt first.
Now, you’ll need to open a terminal like you did back when checking the checksum. Plug in either an empty flash drive or one which you don’t mind erasing, and run
diskutil list
and you should see something like /dev/diskX (external, physical)
which is your flash drive. Now run diskutil unmountDisk /dev/diskX
where X is your flash drive disk number from above, then finally run dd if=path/to/arch.iso of=/dev/rdiskX bs=1m
. Note that the of
part has /rdiskX . The path to your arch iso is probably something like ~/Downloads/archlinux-20xx.xx.xx-x86_64.iso
This command won’t print anything while it’s running, but when it’s done you’ll see a new line asking for input. Two more notes ripped straight from https://wiki.archlinux.org/index.php/USB_flash_installation_media#In_macOS:
To view progress, send SIGINFO by pressing
Ctrl+t
. NotediskX
here should not include thes1
suffix, or else the USB device will only be bootable in UEFI mode and not legacy. After completion, macOS may complain that “The disk you inserted was not readable by this computer”. Select ‘Ignore’. The USB device will be bootable.
Now you should be good to carry on with the guide
of note, the following guide will be assuming you’re installing Linux on the same drive as Windows or MacOS, making it applicable for most systems right away; however, I strongly recommend getting an extra SSD and giving Linux it’s own disk outright instead. This is far easier to do in a desktop, but if you have a laptop with a CD drive you may be able to put a SSD in it’s place. SSD prices have been steadily declining over the pas few years, but as of the time of writing a 250Gb ssd should be available for under 50 USD. I’d recommend a larger disk though, with 500Gb being plenty for most people
While this guide should lead you though step by step, it may be helpful to follow the offical installation guide as well, which is available at https://wiki.archlinux.org/index.php/installation_guide. Furthermore, while slightly outdated, this flow chat is a nice refrence as well: https://i.imgur.com/Hokk8sK.jpg
despite the technically complexity to get to it, the best place for Arch Linux support, even for installation, is in the IRC (Internet Relay Chat) channel #archlinux on Freenode. https://wiki.archlinux.org/index.php/Arch_IRC_channels
Obviously if you need this you’ll need IRC open on a different device than the one you’re installing from. There are plenty of IRC clients available for any platform though.
Installation #
☠☠☠ Seriously, backup your shit. I've done this countless times and have still managed to accidentally wipe a drive. There's a non-0 chance you're about to completely murder your windows install, It shouldn't happen, but it can. This is a necssary evil to learn, and I assure you'll be happy you've done all this, but this next bit is actual hell for people. I'm sorry it gets so bad so early. I promise it's worth it, okay? The next section requires a lot of reboots and has steps where you can't have this guide open on the computer you're working on, so you may want to have a spare system next to you to follow these insturctions on and Google if anything goes wrong.☠☠☠
To be fair, you should probably be doing backups anyway. We’ll talk about this at some point, but, if you don’t have a regular back up solution + an occasional full disk backup and you’re already pretty nerdy, you might want to remedy that sooner rather than later
MAC USERS: Beware, none of the following was writen with a MAC in mind, and as such I strongly recommend you read https://wiki.archlinux.org/index.php/Mac#Installation and look for where my instructions deviate from what’s recommended here.
Now you’ll need to power off your computer. Turn it back on and as you do mash the everliving hell out of both f2 and delete (unless you know what key gets you into the UEFI / BIOS settings). This should bring up a menu that either looks super fancy or looks stright out of the 80’s. Either is fine. The setting we’re looking for is ‘Secure Boot’ it’s probably under a menu called ‘Boot’ or ‘Security’. You’ll need to shut this off. In theory secure boot should protect against a nasty kind of virus called a rootkit, in practice it doesn’t and only serves to make installing Linux more annoying, don’t worry, I’m a security nut and am comfortable leaving it off. Exit and save settings, and as your computer boots again mash F11 or whatever key gets you to a boot menu, and select your USB key. If it shows up twice try the first one first, if that doesn’t work try the other one. (If you end up back in Windows just restart and go back into the bios settings, go to ‘Boot’ and reorder the boot menu entries so your flash drive is the first option) The system should boot first to a screen with a few options, pick Arch Linux if you have to or just wait for it to move on. You should, with any luck, see a list of text flash down the screen that looks roughly like
|
|
If something comes up as [FAILED] even though you still get to the login prompt, don’t worry about it for now
Then, you should be greeted by a minimal prompt that looks like
|
|
and that’s it. Congrats, you’ve already made massive progress.
This is arch, but it’s not actually installed yet, right now your entire computer is running off the flash drive. So let’s get it installed.
You’ll need an internet connection to do anything, if you can connect you computer to the network though ethernet directly, that should be much, much easier than doing things though wifi. If you absolutely must do things though wifi, well, first, really don’t. I mean, you can, but’s a solid pain. I’m going to assume you’re not. Cool.
If you didn’t connect your computer to ethernet before you started arch, the first thing you should type in this prompt is
|
|
this manually restarts the service that asks the network for an IP address, which you need to do since currently the system is in such a minimal state it won’t do that automatically.
Now, try
|
|
if you see something like 64 bytes from apollo.archlinux.org
, congrats! You’re online! If not, you may try a different network or wireless if applicable (seriously, it’s a pain)
From here, you’ll need to see the names of the hard drives on your system. run lsblk -f
.
but what does that even mean? well, let’s learn about another command! - man
For most commands on Linux if you type man
before the command with no flags (the -x things after the command) it’ll open a manual page for the command. Read here to figure and try to figure out what lsblk
is and what -f does.
lsblk lists information about all or the specified block devices. The lsblk command reads the sysfs filesystem to gather information.
The command prints all block devices (except RAM disks) in a tree-like format by default. Use lsblk –help to get a list of all available columns.…
The default output as well as default output from options like –topology and –fs is subject to change, so whenever possible you should avoid using default outputs in your scripts. Always explicitly define expected columns by –output columns in environment where a stable output is required.…-f, –fs : Output info about filesystems. This option is equivalent to “-o NAME,FSTYPE,LABEL,MOUNTPOINT”. The authoritative information about filesystems and raids is provided by the blkid(8) command.
Okay? Well, that probably doesn’t mean much so lets focus on the important bits
“lsblk lists information about all or the specified block devices. The lsblk command reads the sysfs filesystem to gather information.”
Block devices are devices that have ‘blocks’ of information, like hard drives, flash drives, solid state drives, sd cards, etc.
“-f, –fs … Output info about filesystems.”
This means we’ll be able to see what type of file system is on each block device.
So, we can use this command to see information like we saw graphically back when we opened disk management in windows, only now with their Linux names. In Linux each block device is actually stored as a file, as bizarre as that may seem. This file is actually located in the /dev
folder which sits on top the root folder. The root folder is simply designated by a single /
so a normal file structure may look like /home/USERNAME/Documents/office/
and so on. It’s worth noting that /
is actually a folder in itself, it’s just the absolute bottom folder, hence it’s called the root folder. So the /dev
folder is located at /dev
. In /dev
there’s a lot of things, but at the moment what we’re really concerned about is the storage devices. so, looking at this example output from lsblk
you’ll see three storage devices /dev/sda
, /dev/sdb
, and /dev/nvme0n1
|
|
What do these mean? Well, most drives in Linux are simply designated by a /dev/sdX
where x is just the next available letter in the alphabet, though on some newer systems like mine, you may find some blazing fast SSDs actually use that other odd nvme syntax. Both work exactly the same way for what were doing.
looking at that output again you’ll see each device has multiple things under it. For example /dev/sda
has /dev/sda1
all the way though /dev/sda4
. Each of these are the separate partitions. In this particular example, sda is actually the flash drive we’re running off of, so you can see that it is currently where our root file is /
on /dev/sda1
and that it’s an ext4 file system (I’ll explain this a bit more in a bit) you’ll also see there’s another partition that’s formatted as fat32 for boot, but all of these are on the flash drive because they’re on sda.
For Simplicity now we’re actually going to look at a simpler lsblk -f
output with only /dev/sda
and sdb. sda is still the boot usb stick you’re on, but sdb is now the singular drive in a laptop that has windows installed and available free space in accordance with this guide.
|
|
alright, so now on sdb we see there’s 4 partitions (sdb1,2,3,4) where in this case we have sdb2 as a ~512Mb vfat partition, sdb3 as a 300Gb NTFs partition, and then that blank partition we made on sdb4. That 512Mb partition contains the bootloader for windows, but soon we’ll add Linux. The larger NTFS file system is where Windows and all your programs documents and other things you’ve done on your computer in the past live. I hope now it’s obvious why I urged backups, as we’re about to play around with things a bit.
We’re going to need to make some changes to this list tough, as we actually need one more small division in the partition table. run the command
|
|
this should bring up a strange command line based almost graphical interface which you can used to edit, add, or remove partitions. With that 100Gb (or whatever you chose free space we made earlier), let’s divide it into two partitions, one that’s 8GB and the other that’s just what’s left. We’re doing this so we have somewhere to put SWAP in a second, but let’s get to that later, for now just use your arrow keys and highlight the large empty block and select new, select primary, then make it 8GB, which is 8*1024Mb or 8192, and then select end. Finally write it, then quit. Whew. Bit stressful even for me. Don’t worry, Linux gets much much easier, especially when we get our graphical tools back.
now, run lsblk
again. You should see something like
|
|
so now we need to format these partitions with a file system. For the root file system, where we’re gonna put all the programs, files, and the OS itself we’ll use the ext4 file system. It’s by far the most common file system for linux. To do this look at the lsblk output and look for the large empty space we left (not the 8Gb space we just made!) and run
|
|
Where xy is the correct letter and number for your partition, in the above example that’s /dev/sdb4, as sdb5 is the 8Gb partition we just made
alright, that’s actually most of the really hard stuff done. Now we need to mount both the file system we just made and the boot filesystem. run:
|
|
where x is the same as the above x and y is the number of the partition with the windows boot manager. sdby should be roughly 500 megabytes and be vfat, it may appear as ‘EFI partiton’ in cfdisk if you’re unsure.
Next up we need to install the base of the os to these drives, this is actually pretty easy just run
[TODO] Arch linux’s install has changed a bit since this was written. Now, more arguments are required at install time as the base Linux kernel is no longer included in base. I’ve changed this here slightly, but it’s very likely still missing some things.
|
|
then, we need something that tells the system the names of our partitions and how to mount them at boot. Thankfully, the system can generate (most) of this for us, just run
|
|
what this command does is looks at the id’s of the drives in /mnt (the ones we manually mounted when we ran mount a few commands ago) and redirects those id’s and the settings used to mount them (which were default) and writes that output using ‘>’ as a redirect to a file stored in /mnt/etc/fstab. Because /mnt is the location where we mounted the harddrive, it’s actually writing a file to the hard drive now, just as pacstrap just did.
Alright, next we need to use a command that you’ll probably never use again- chroot. This changes your root directly to be higher up the chain, effectively cutting off access to lower files, though we need to do this to install our bootloader, again this is easy
|
|
which will change the above to look like: ’ root@archiso ~ # ’ to ’ root@archiso / # ’ as that ‘~’ was actually a shorter representation of being in /home/root (there’s actually a user nammed root by default, and the user has it’s own home directory. It’s easy to confused root the user with root the directory, but you’ll get it eventually if you don’t now that’s okay c: )
now we can install the bootlooder with
|
|
Now we need to add a bootloader entry for arch. We’re going to use a very simple command line text editor called nano. it’s sorta like notepad on windows.
|
|
this will bring up a text editor, it says how to operate it at the bottom (ctr+o to write out = save, crt+x to exit, etc)
enter, exactly: (Note line 2 says linuZ-linux, that’s not a typo, and replace the x with your root partiton)
|
|
and for our last trick before we reboot save and exit nano with ctr+o, ctl+x then, run
|
|
and enter
|
|
then, we’re ready to reboot into the new OS!
run consecutively,
|
|
and pull the flash drive out. If all went well your system should boot to Arch. If it didn’t, first make sure it’s set to boot to arch in the BIOS/UEFI’s boot settings, and then if things are still broken try to figure out why, there are plenty of people in the community willing to help, including me.
Assuming it booted back up to a similar looking prompt but with no flash drive we have to do some house keeping but you’ll have a bad ass system in no time.
First things first enter ‘root’ for the user name, this should let you login.
then run ‘passwd’ this will prompt you to set a password. For the love of god don’t forget it.
Next you’ll need to set a hostname, this is how your computer id’s itself on the network, so might help if you make it something sensible like ‘usernamelinux’ to do this run
|
|
then let’s add a user, as using root all the time is very unsafe. To do so run:
(I recommend using the same password you used for root)
|
|
I swear to you we’re getting there.
run
|
|
then find the line that says
|
|
and remove the ‘#’
As an explanation, the ‘#’ is turning that line in that file into a comment, in programming it’s common practice to use comments to disable sections of code so say we had a program:
|
|
the #
before print(i)
is preventing it from actually executing so the output of this would be {1/2,1,3/2,2,5/2} instead of {1,1/2,2,1,3,3/2,4,2,5/2,5}
Anyway, with that out of the way let’s find fix up networking so we can get online and run updates
run ip link
and look for the name of your network interface. If it’s a wired adapter it should be enpXsY where X and Y are number, wif is similar but uses wlp instead of enp. To make sure the network brings itself up on each boot let’s enable dhcpcd
- that service we restarted way back when- on that interface. Just run
|
|
next up, we should make sure things know what language we speak. Assuming you want to use US english just run
|
|
Timezones, run each independently
|
|
It’s worth noting Linux and Windows use differenent clock standards so every time you reboot between the two windows will messup the clock, to fix it in WINDOWS you can run
|
|
in an admin command prompt
Alright, we’re getting close to graphical stuff now, I swear. Remember that 8Gb partion we made a while ago, time to use it. Now that we’re in the full OS the’re a good chance the location names of the partitions changed so run lsblk -f
again and figure out where that 8Gb portion is
|
|
then, we need to edit the fstab file we generated earlier.
Let’s look at what the fstab file looks like right now. We can read a file from the command line without opening it up for editing with cat
, so run
|
|
and you can see what it looks like. See all those super long UUID’s? We need the right one of those for our new swap area. Thankfully there’s an easier way to do this than writing it down on a sticky note.
if we run lsblk -no UUID /dev/sdxy
(obviously substitute x and y) you’ll get this UUID, so let’s just append it onto the end of the fstab file!
Remember how we used the ‘>’ character before to write the output of genfstab to /etc/fstab, well you can also use two of that same character to append an output to a file. However, before we do that let’s be safe rather than sorry and make a backup of the fstab file by first moving to the /etc directory then making a copy of the file
|
|
note we didn’t need to type /etc/ before each fstab because that’s a file in the folder we’re already in.
but we’re not done yet. use nano
to open up the fstab file and edit it so the last line we just appended looks more like:
|
|
Save and close nano and then to finish up swap all we need to do is edit one more file
|
|
Alright, lets run an update and reboot!
For now to do updates we’ll use pacman (short for package manager)
run ‘pacman -Syyu’
The -S says to Sync, or actually apply the updates, the double y’s say to force grab the newest database (usually only use one y) and u means upgrade. If you want more detail run man pacman
Once that’s done you can run systemctl reboot
Finally, we’re going to get a graphical environment running.
Once the system reboots login with your username, not root. When you type your password you won’t see anything, but it is actually typing!
then run:
|
|
This command uses sudo or ‘superuser do’ because you’re now logged in as a user, and as such need admin privileges to install software. This is part of why Linux is so secure. Pacman, again, is just ‘package manager’ , -S
tells pacman to sync the requested packages from the server and the other two things are the two packages we want right now, both are used for video output.
To install the correct driver for your graphics hardware you can run
|
|
to find the vendor of your graphics card. If the output contains NVIDIA run
|
|
for INTEL run
|
|
and for AMD run
|
|
if you have multiple, it’s safe to install both.
Alright, now we need to install the desktop environment. Because this guide to this point is probably already melting your brain I’ll take it easy for a bit and we can install KDE-Plasma.
KDE Plasma is pretty big though, so we’re gonna want to be sure we’re using fast mirrors before we do anything else
|
|
then we’re going to temporarily switch to the root account using su
all you have to do is type su and enter, then type the password
now run
|
|
Finally to install Plasma run
|
|
then
|
|
and finally, lets see the epic payoff of all the effort
|
|
Note that KDE Plasma is fairly large to download and a bit resource intensive. As an alternative if on older hardware
|
|
|
|
Alright, now you can take a few minutes to get used to how your new computer works, play with settings, etc.
before you wrap up lets do a tiny bit of housekeeping
|
|
from now on you can just open a terminal and type yay
followed by your password to run updates.
[TODO] Make NTFS drives accesible and auto mount
So Why Did I do all of that exactly? #
Linux makes development of code particularly easy, so, let’s write some code!
The first language we’re going to try out is called python. Python is an interpreted language, meaning each block to be executed can be run one at a time, to show you, let’s install it.
Because we installed yay earlier you could use either that or pacman, but let’s just use yay for simplicity. From here on out I’ll be coping directly from what my terminal prompt looks like. Yours, for now, probaly looks similar to:
|
|
However, mine looks like
|
|
so, install python just like we’ve installed other programs with python or yay
|
|
once that’s done you should be able to start the python interpreter by simply typing python
and pressing enter. This will give you a new prompt that takes python code as input
|
|
the >>>
is the prompt asking for input, go ahead and just try 1 + 1
for now
|
|
Okay, who cares though, right? let’s try something a bit cooler. Say you wanted to add up all the odd integers up to 72? This isn’t something that’s trivial to do on most calculators and would be a real pain by hand, but it’s trivial to do in python. The code to run this in python is
|
|
when you type this in the prompt you’ll actually be able to enter multiple lines when you write the for loop. There’s no clear way to explain this in text, you’ll just have to try it and see how it works, note the way python set up looping is by indentation, so you’ll need to press tab when the prompt lets you type the line sum = sum + i
so that it’s obviously a ‘child’ of the for loop.
after you run the print statment you should see the output
|
|
telling us the answer is 2628. To make you feel like a bad ass, you actually just wrote code that’s equivalent to this math \( \sum_{n=1}^{72} n \) pretty cool right? But that’s math? Who cares? Let’s do something cool!
If you’re not familiar with math like this, this is the sum from n=1 to n=72 of n, so it’d be 1+2+3+…+72
Python code doesn’t have to be written in line by line, you can put it an a file and the computer will run that file as a program, so let’s do that! But to do that we’re gonna need something better than a terminal editor or an equivalent to notepad. There are actually text editors that make writing code much easier. Let’s go grab the ‘Visual Studio Code’ editor. Hopefully by now you know the command! (The name of the package is just code
)
super quick detour: while you can open graphical programs though the start menu down in the lower left hand corner just like on Windows, you can actually open a program directly from the terminal. Interestingly, this can make a program that opens in a new window a ‘child process’ of the terminal, which is why we normally don’t do this. What this normally means is that if you start a program from the terminal - the parent- and then close the terminal, the child process, in this case the graphical program you started, will die too. Strangely, VSCode actually separates itself from it’s parent process almost immediately, which is why we can start it from a terminal and then close the terminal and it should stay running. so, let’s do that.
|
|
and a new window should pop up. It’ll probably open with a few tabs welcoming you, asking if you want to install a theme, if you are okay sending VSCode usage info, etc. Uncheck boxes so these don’t come up each time and answer questions as you please. Then, we’re going to go up to the top and chose
file -> new file
Then, down at the bottom right of the editor you should see something that says plain text
click that and a box will appear asking for the name of the language you’re working with. Obviously chose python.
alright, now we’re ready to code! Let’s put a bit more interesting of a program in and then we’ll talk about what it does line by line. I stole this code from https://matplotlib.org/2.0.2/examples/animation/animate_decay.html
|
|
So you can just copy and paste all of this into VSCode, then use ctrl+s to save it, and let’s save it in the Documents folder as test.py - the .py extension is for python files.
Before we talk about our code, let’s see it run!
Open up a terminal, and run cd Documents
to get to your documents folder, ls
to see what’s in there, then ./test.py
to run the program.
|
|
Oops! that probably didn’t run. If you look at the errors it will tell you you’re missing matplotlib ad numpy, let’s go get those
|
|
Now it should work! run ./test.py
again, and now you should see a decaying sine wave. Still not exactly something that get’s the heart racing, but it does prove the power of programming! The code did all of that in under 50 lines of text!
Frankly, the code that makes this work is a bit complicated but we can go over some of the important bits
at the very top there are four important lines:
|
|
the first line uses a shebang #!
followed by python’s location, this tells Linux to use python (specifically python3) to run the code underneath, actually, that’s the location of the python program we installed earlier. In Linux, most of your programs can be found in /bin
Next we have a bunch of imports. In most programming lanuges you don’t want to reinvent the wheel so you’ll use libraries. These are well documented, heavily tested, and optimized blocks of code you can use that you don’t really need to understand how work under the hood, only how to use them. Although not used here, the most basic example would be advanced math in the math library, like
|
|
on line 6 the math library, which gave us access to sin and exponent functions, was imported. We don’t know how math.sin()
works, but we know it does, and that’s fine.
The same is true for numpy
and matplotlib
above, both of these are libraries, matplot lib is what handled actually putting the data on the screen, and numpy as can be seen on line 12 of the program:
|
|
is used for doing some of the math. Numpy is a common python library used for doing more advanced math really fast, we’re not going to worry about that right now though.
the next thing you should notice is how the code is organized into blocks with def name():
like def data_gen(t=0):
or def init():
these blocks of code are called functions and they let programmers break up code into re-usable pieces or just wrap up a lot of complicated things to make code more readable, for example imagine a function that takes two numbers and does hundreds of lines of complicated math with them (eww)
|
|
this would make it so latter in your code anytime you needed to do this math again you could just use
|
|
this is much, much easier to read than a copy and pasted version without these functions or ‘blocks of code’ furthermore, if you accidentally made a mistake somewhere in the math in mathyMess you can fix it there rather than in each independent copy individually.
For now, we’re going to take a bit of a break from code, but we’ll be back.
Okay, so what? #
So, yeah, you can develop python just fine in Windows. Installing it is just a matter of going online and fetching an exe installer and checking the right boxes. There’s nothing here you can’t do in windows. If that’s the case why do any of this.
Frankly the answer is complicated. The gist of it is that Linux actually exposes things in a way that while might be possible in windows will probably be much more difficult. Even in the above, when we installed python and a few libraries there was no need to open a web browser and each package is maintained and verified in a way that makes installation easy, secure, and reproducible.
But more than that, Linux actually exposes the system to the user and doesn’t try to hide it’s inner workings, rather, for many things Linux implies that you should manually edit the config files, look at how programs use various resources, and peer into how the system actually handles any given task.
You’ll start to see this more as we move forward though these next few chapters.
Getting a few things you’ll need #
You’ll definitely need a web browser. I personally like Vivaldi, and it’s chromium based so everything should work exactly like it would in Chrome. you can install it with yay -S vivaldi
. Once it’s installed, open it up and in the address bar type in vivaldi:flags
, find Override software rendering list
and set it to Enabled. You may want to set Hardware-accelerated video decode
to Enabled as well, but don’t be afraid to turn that off if it seems things aren’t working correctly.
In Chapter 5 - Working on How We Work We’ll get things set up enough that, depending on what you do with your computer, you could comfortably switch to using exclusively Linux. First though, with Linux up and running we can more easily dive into the hardware and really do some things to improve the performance of the system.