Guest Article: Kickstart Vol. III

Today is the third guest article in a row, and is one more article about Kickstart. There will be more Kickstart articles, but we’ll release those in time. This is the third one in a row, so we’ll try to mix it up a bit.

By now, we should all have at least a little familiarity with Kickstart. Frankly, I’ve still not had a chance to use it – but it does seem like it’d be fun to play around with it. If I were an admin of anything major, I’d definitely look to Kickstart as a solution. Again, if you read this on day one, be sure to check back later as the author may suggest some edits.

See the previous articles here:

Guest Article: Kickstart Vol. I
Guest Article: Kickstart Vol. II

Kickstart Vol. III

Now we need to create a menu for your Kickstart, so you can select which OS you want to install.

Now edit a new file named grub.cfg. It must be named grub.cfg. Here is an example of what it should look like.

The set-default lets you pick which is the default install, it starts at zero, so the options here would be 0, 1 and 2.

Note the IP address of my Kickstart server is here, the path to my extracted iso directory is here, and the location of my boot kernels is here.You can change all of these to fit your needs.

Now we need the actual anaconda-kickstart.cfg files, this is what actually does all the work.The location of these, is set in the grub.cfg file above. You will want these to be in the extracted iso directory, but not in the “dvd” sub-directory.

Here is an example of what one of these would look like. This one is fairly basic.

Again you see the IP address of my kickstart server here, you see the location of my extracted iso files here.Now there are a few things you will need to know in advance.

What I typically do, is install the OS from a USB the first time.In the case of fedora/redhat/CentOS there will be a file at /root/anaconda.cfg. You can copy this file as a starting template for your kickstart of this OS.

(Yes I am re-naming the file here.)

Also you will need the password has strings for your users.

(Or whatever user name you use.)

You will need to know the name of the LAN interface, and you will need to know the size of your hard, and how big the partitions should be.All of these things will be in your anaconda.cfg file

Now change and edit a few things in your fed35srv/fed35.cfg file now.

Change the graphical install to..testskipx This uses a cli interface, not a GUI when installing.

Change the url line to the location of your extracted iso directory in your web server. Note you don’t put the full path, only the path from your webroot.

I like to turn off seLinux, but you can delete that line if you like.

Change your timezone to whatever is appropriate for you.

Using the two example user lines above (those aren’t real hashes, I just typed a bunch of random characters to simulate what it looks like). Edit the user lines to be whatever your values are.

That’s it, you’re don! Now boot your test computer on the kickstart network. A Kickstart menu should appear. Select the appropriate OS.

I’ve found this usually works best with a few settings on the test computer. CSM should be disabled. Network stack should be enabled. Some UEFI settings let you pick PXEboot IPv4 as a boot option. This is preferred. I’ve found it works best with a freshly formatted hard-drive, that way it doesn’t try to boot into the installed OS.

Good luck!

Closure:

And there you have it! You have a guest article, from dos2unix, about Kickstart. There are now three of them and there are a couple of others sitting in the potential queue. We’ll get to them. These few days off have been a very welcomed respite!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Guest Article: Kickstart Vol. II

Today’s guest article is a continuation of the Kickstart theme. The first Kickstart article can be found here. Thanks goes out to dos2unix from the Linux.org forums.

I should mention again that I don’t actually know anything about Kickstart, other than what I’ve read in these articles. I’m extremely grateful, but you may want to check back a few times to ensure all the editing is complete!

Kickstart Vol. II:

Now that we have your web server, dhcp, and tftp server configured, we will need to enable the firewall for them.

On Fedora it looks like this:

Now we need to extract the iso files you have handy (you did already download these, right?) I should have mentioned you will need the “server” version of these iso’s. There is a way to make the workstation iso’s work, but that’s for another more advanced article.

For the example here, I put everything in: 

When that gets done copying, we can add another OS’s iso if you like:

If you have more iso’s repeat the same for CentOS or Redhat or whatever you have.

Again, when it gets done copying, simply umount the iso image. I confess, I’m something of a minimalist. I like short names like pub/fed35srv. If you like long names you could have something like /public/fedora35-server/x86_64/ I’m too lazy to type all of that in all my config files.

Now we will install the boot kernels. This isn’t actually the full kernel yet, just a lite kernel with enough parts to boot the system from the network.

Just about all computers have one of two types of internal configuration systems. Legacy BIOS and UEFI. Most newer computers in the last 8 years or so,are UEFI, but there are still plenty of Legacy BIOS systems around. For the purpose of this article we will set-up for both types.

In your /var/lib/tftpboot directory, we will make two directories. One for BIOS and one for UEFI.

Technically you could rename the efi directory to something else, but the pxelinux for legacy BIOS systems is hardcoded in some files.

Now you will need to download a couple of files. I recommend using the Fedora 35 version, even if you are going to be installing Redhat or CentOS. They are newer, have more features, bug fixes, and support more hardware.

But you can use the CentOS or Rehat versions if you want to. Shim-x64, grub2-efi-x86, and grub2-efi-x64-modules. We will need to extract these rpms. You can do this in /tmp or somewhere safe.

If it says this is already installed, replace install with reinstall. These are the efi files you will need for efi based systems.

This will create 3 directies in /tmp.

You can delete these directories in /tmp if you like, you are done with them. Make sure you don’t put a leading / and actually delete /usr and /etc.

The next part depends on what iso’s you have downloaded and extracted. But hopefully you will get the idea.I am using Fedora 32, Fedora 35, and Redhat 9 as my examples. You can use whatever directory names you like.

That’s enough for this article, will add next part later.

Closure:

And there you have it, another article and this one is a guest article – just like yesterday and probably just like tomorrow. I’m extremely grateful for the respite and wish I knew more about Kickstart. I think, for future reference, I’m gonna ask that folks register and write the draft here. I think it’d streamline it.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Guest Article: Kickstart Vol. I

This is an article about Kickstart written by guest author, dos2unix from the Linux.org Forum. It’s the first of a few articles from them, so let’s give them a warm welcome and enjoy their article!

Kickstart Vol. I

Kickstart is really Redhat/CentOS/Fedora-centric. There are some attempts for parts of this work on Ubuntu and SuSE, but so far there is really little support for this. Kickstart does a lot of the mundane work for you. It sets up the filesystems for you, you control this size and format of them. It creates user accounts for you, sets up your network for you, and installs the packages you want to be installed (or not installed). You can even run a shell script automatically when everything is done.

Now if you only have one computer, and you only install the OS once a year, this isn’t going to save you much time. However if you have quite a few computers, for example a data-center with dozens or hundreds of servers. Or even a few test systems that have to be rebuilt every day or every few days. Then this can save you a lot of time.

The Kickstart computer itself doesn’t have to be anything fancy. In fact, it doesn’t even have to run one of Redhat type OS’s listed above. It can be Debian, Ubuntu, or whatever you like. It’s best if it has two LAN (Ethernet) interfaces. Most computers cannot be Kickstarted over WiFi yet. You can use a single network interface, but it makes things a little more difficult. If you have a lot of computers to Kickstart, I recommend that you get a small un-managed switch. 5 or 8 ports should be plenty, unless you’re at a data-center.I have worked in data-centers, but now I work at a place that writes software, and we test it over and over again, so I have to “rebuild” the OS sometimes several times a day.

Obviously you’ll need a computer to do this. If possible you’ll want a second computer to test on. One that will be the computer that’s being “Kickstarted”. You’ll need about 20 GB of free space on your Kickstart server to install .ISO images of the OS(es) you want to install.

Your Kickstart server will need three items installed. There are multiple ways to do this. We will discuss a couple of the most common ones. Perhaps a follow-up article will offer more options if there is enough interest.

First you need a web server like Apache httpd, or NGINX, you could even use the simple Python web-server, it doesn’t matter that much.

Second you’ll need a DHCP server, again you could use either BIND or dnsmasq, we will discuss both ways. Finally you’ll need a tftp server. If you use dnsmasq,it has a tftp server of sorts built-in.

It’s beyond the scope of this article to teach you how to install these items, it is assumed you already know how to install software.Note that this will have to be on a different network that your normal home/work/datacenter network.

You don’t want Kickstart erasing, wiping out, and re-installing the OS’s on your every day driver. This is why I recommend one with two interfaces. Otherwise, you’ll have to re-configure your network to download packages, install updates,and add more packages if necessary, and then re-configure it back to your Kickstart network. That gets old in a hurry, trust me.

I’m using Fedora as my Kickstart server. I currently have configurations to install Redhat 8, Redhat 9, CentOS 8, Fedora 33, Fedora 34, and Fedora 35. I install all of these on 3 different computer hardware types. You don’t have to install the same OS that your Kickstart server is running. For this first example, I’m going to use NGINX as my web server, dhcpd (BIND) as my DHCP server, and tftp-server, as well… My tftp server. My Kickstart has two LAN interfaces, it doesn’t really matter too much how you have the first interface configured.

Again, it’s beyond the scope of this article to tell you how to configure your network interfaces, it is assumed you already know how to do this. You’ll want a static IP on your second interface.A gateway isn’t required, for this article, we can just 192.168.7.227, try to pick something obscure that no one else will use in the environment you are in. I will go ahead a use a /24 subnet or 255.255.255.0 for those who aren’t familiar with CIDR subnet masks.

Remember this IP address, it will be used in quite a configuration files. Again you can use any IP you like,but remember what it is, because you’ll need it several times.

So for Fedora, it’s a simple dnf install -y nginx dhcpd-server tftp-server, other OS’es may vary.

Once they are installed we will need to configure them.

The first one here is NGINX. On most Linux’s I have used, the nginx.conf file is located in /etc/nginx/nginx.conf. You have a “server section” in this file.It’ll say server with a { after it. Replace the contents of your server section with the content below. This assumes your web content will be at /usr/share/nginx/html you can adjust this accordingly. This will be where your extracted .iso images will live. So make sure you have space here (or do a soft link to another directory that has space). You can use SSL/HTTPS, but again that’s beyond the scope of this article.

I also recommend adding these two lines, below your access_log section. The other lines will likely already be there.

access_log /var/log/nginx/access.log main;

Now enable and start your web server. For Fedora it’s 
systemctl enable nginx
systemctl start nginx

Now we need to configure your DHCP server. For BIND (dhcpd) the conf file is usually located at /etc/dhcp/dhcpd.conf (not to be confused with dhcpd6.conf )

Just mv the dhcpd.conf to something like dhcpd.conf-original or whatever you like, just make sure it doesn’t end with “.conf”. Now make a new files and copy the following to it.

I’m using the entire 192.168.7.x subnet here. The IP address of my Kickstart server is 192.168.7.227.Edit this file and replace the values of your server/network accordingly. The range tells my DHCP server to only give out IP addresses between 10 and 120.

Now you may be wondering about that last line, what is the “next-server” and why does it have the same IP address as my Kickstart/DHCP server? The “next server” after I receive a DHCP address is the tftp server, it’s located at the same IP address. You could run it on a different server, but most people run it on the same server.

Again just like NGINX, let us enable and start the service.
systemctl enable dhcpdsystemctl start dhcpd

For the tftp server, you really don’t have to do much, by default tftp wants tftpboot to be at /var/lib , so…

Note this is a listening socket, not really a server per se.If you want to make sure that your tftp server if pointing to /var/lib/tftpboot you can run..
systemctl cat tftp.service

You should see a line like this somewhere:

ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot

I would recommend not changing this, as several configuration files will like in this directory.

Closure:

Honestly, I edited the above the best that I could – given that I know nothing about the subject. I appreciate the articles, but it means trusting dos2unix – and I’m perfectly willing to do that. If you have any questions, you can post them here or you can post them on the linux.org forum where I share this article (as that’s where dos2unix lives).

Either way, stay tuned – as this is just the first part of a series of articles handily written on this subject. I, for one, am going to probably use the break to get a few articles ahead so that the new year starts off right.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Learn About Absolute And Relative Paths

In your Linux journey, you’ll use both absolute and relative paths. It’s important to know the difference and, perhaps, when you want to use absolute paths or when you want to use relative paths. It’s a pretty easy lesson and not a terribly long article.

First, paths are directory names and links to files. They’re always unique names to files and folders. They’re useful for referencing things, knowing where things are, organization, and the likes. To manage a file, you should probably know where it is.

An example of an absolute path would be something like:
/home/<user>/.bash_profile

An example of a relative path would be something like:
~/.bash_aliases

An absolute path will always begin with a /, for example. As they’re the easiest, let’s cover them first:

Absolute Paths:

Let’s say you have a file in your Documents directory and it is named foo.txt. If you wanted to read that file, you could navigate to the Documents directory and use cat foo.txt to read the file. 

That’s only going to work when you’re already in the Documents directory. If you’re not in the proper directory, you’ll have to use the absolute path. That would look like cat /home/<user>/Documents/foo.txt and that would work. 

As I said already, absolute paths have to start with a /. They’ll also start with one of the root directories, such as /etc, /bin, or /media. You can see those directories in your file manager by going up a level until you can go no further, when you’re at the absolute / directory.

An absolute path works even if you’re working in a different folder in the terminal. When you’re in /home/<user>Pictures, cat /home/<user>/Documents/foo.txt will still work just fine. 

Again, they’re a unique identifier for a directory or a file. If you wanted to change the directory in the terminal, you could use cd /home/<user>/Pictures. That would work just fine.

Relative Paths:

Relative paths are paths based on where you are already. They’re based on your “PWD” or Present Working Directory. There’s a few ways that these can be used. Conversely, a relative path never begins with a /.

For example, if you’re already in /home/<user> then you can cd Documents to get to your Documents directory. As you can see, that’s much easier to type.

Of course, there’s the tilde – which already means /home/<user>. So while possibly not the same thing you’re thinking of when you think of relative paths, you can also get to the Documents directory with cd ~/Documents.

If you’ve used the ‘ls‘ command before, you may have noticed a . and a .. in there. Well, the . stands for your current directory (and some commands will want that) and the .. stands for the next highest directory.

Assuming you were in the Documents folder, you could do cat foo.txt you could also do cat ./foo.txt and get the same results.

While in the Documents directory, you could cd . and that’d take you exactly nowhere. More useful, you can cd .. and you’d be back in /home/<user>. If you did cd ../.. you’d end up in the /home directory.

You can also (though I have no idea why you’d want to) use the above mentioned $PWD environment variable, but I never do and I don’t see much of a reason why you’d want to. Assuming you were in /home/<user> you could, again if you wanted, use cd $PWD/Documents and happily reach the Documents directory just fine.

Absolute and Relative Paths:

As you can see, there are different times and places to use a relative and an absolute path. When in doubt, I prefer the absolute path. If I’m writing notes that may apply differently to different systems, I’m more likely to use the absolute path. When I’m in a hurry, I tend to use a relative path – when I can use one.

You might as well get used to using both of them. They both have a right time and place. Commands like chmod may want an absolute path or will want the directory included. So, you’ll possibly need to chmod +x ./foo.txt instead of chmod +x foo.txt. In time, you’ll adjust and know which suits your needs best.

By the way, if the tab autocomplete doesn’t work after the command, the command probably demands that you denote the current directory with the . indicator like in the chmod above. If you type chmod +x fo<tab> it will refuse to autocomplete the filename. Once again, in time you’ll learn when that’s needed.

Learning to use Linux is a journey, not a destination!

Closure:

And there you have it! You have yet another article said and done. This one isn’t like some of my normal articles, but it’s still information folks might want to know. I find as the site grows, it gets possible to reference earlier articles, which is quite nice.

There are some articles I simply can’t write until I’ve taken the time to write other articles. I kinda like that. I’ve been enjoying typing these things out. I find the better I can explain them, the better I understand them. Heck, I recommend y’all make your own sites as this is pretty darned informative for me. The feedback is awesome and helps me understand even more.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Start A Quick Python Server

Today’s article is going to show you how to transfer files between computers by using a quick Python server. It’s remarkably easy! It’s a temporary server (usually) and lasts only as long as you need it to.

Why would you do this? Well, you can transfer files from one computer to another. It also functions as an HTTP server which makes it easy to test things like simple web pages quickly and easily.

Are there better options? Quite probably. If you want to transfer a single file, then SCP is a good way to go about it. If you want to transfer multiple files, you could setup SFTP. If you want to test web pages, you can likely just write the files locally and then open them up with the browser of your choice.

You have options! And, thankfully, Linux provides all sorts of options – including setting up a quick Python server. As I said, it’s actually pretty easy.

A Quick Python Server:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The first command I want you to run will let us know what version of Python you have installed. Many distros have (at present) moved onto version 3, but some still have Python 2 installed. So, for that information you just run:

Now, if you have Python v. 2.x, you would use this command:

If you’re using Python v. 3.x then the command you’d use is:

(If you’re curious, the -m is telling Python which module to open.)

Anyhow,  you can now connect to your server with the following command:

Read how to find your IP address. Instead of an IP address, you can also use your hostname.

Anyhow, you  now have a server running on port 8000. If you want to, you can also change the port number. This is the same for both commands. In both cases, just append your chosen port number to the command. Like this:

It’d look a little like this:

See? It's a different port number.
Note the changed port number. You should probably avoid reserved ports.

When you’re done with the quick Python server, you can just close it by pressing CTRL + C. If you’re planning on running it long term, you can always run the command with nohup. If applicable, you may also need to open the port in your firewall.

Like I said, it’s a quick and easy server in Python. You definitely wouldn’t want to use this as a public facing server, but it’s fine for quick tasks. Feel free to leave a comment letting folks know how you use this in  your day-to-day tasks.

Closure:

There you have it, another article said and done! The site is going well and the schedule seems to be working well enough. It’s a bit demanding to write one every other day, but that’s what I said I’d try to do. So far, so good!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.