How To: Enable a Swapfile

Yeah, yeah… I have a modern, large SSD. I have more RAM than I’ll ever possibly use. I still want/enable swap, in this case a swapfile. Imagine my dismay when I installed Lubuntu 20.04 and found there’s no swap available during the basic installation? (It’s there in 21.04.)

no swapfile
See? There’s nothing there!

Sure, I could have made a swap partition during the installation, but that didn’t seem like something I wanted to do – besides, I can always add it later. Which, of course, I did.

There are all sorts of views about whether swap is required in my situation, or in any situation, but I’m of the mind that disk space is cheap and my computer is faster than I am. So, if it has any chance of helping, it’s all good. It should also be mentioned that swap is far more complicated than ‘a place where the kernel sticks stuff when there’s no more RAM left’. In fact, it’s a lot more complicated than that. It’s where the kernel pages content that’s seldom used, and it’ll happily use swap even when there’s plenty of RAM available.

Since it’s lacking, let’s learn how to add a swapfile to Ubuntu (and official flavors) 20.04 and presumably other similarly aged variants. It’s a pretty painless process. 

Like normal, let’s crack open your terminal emulator with CTRL + ALT + T.

Now, let’s check to see if you’ve already got some swap going on.

If it shows nothing but a new line, you have no swap. If it says anything else, you’ve got swap enabled already and probably don’t need this article.

Just so you know, I personally just did this a couple of days ago, after upgrading to Lubuntu 20.04. So, I’m pulling this data from .bash_history.

Let’s make a swapfile.

Why 8 gigabytes when I have ample RAM and an SSD? Because I never, ever want to worry about it again. I want to be able to open up every app I have and leave them open for a month. You do you and decide how big you want it to be!

Now, we need to set some permissions. We don’t want anyone writing to swap, we only want root writing to swap.

Next, we need to let the OS know that’s swap space.

And turn it on with:

And you now have swap in the form of a swapfile and it’s turned on. I suppose we should make this permanent. To do this, we need to edit fstab and nano is a good tool for this.

And add this at the bottom of that document:

Those are the 0 digit, in case the font here makes it confusing. (I think I’ll try messing with the fonts.)

Either way, you should now have a swapfile that gets loaded on reboot and is currently loaded and working. You can next edit the swappiness value. In Ubuntu, it is a default of 60. If you want to edit it, you’ll have to wait for another article.

Like always, thanks for reading. It’s missing at the moment, or not working, or I’d say subscribe and get notifications of new articles. However, I’ll have to work on that. I just haven’t made the time to do so.

Smash a Button
[Total: 0 Average: 0]
About Me: I'm just some retired dude with a little bit more free time on my hands. If you want to support the site, why not help yourself out too by ordering some inexpensive web hosting so that you can start your own site?


How To: Enable Password-less SUDO.

This isn’t the smartest thing you can do. In fact, you probably shouldn’t do this. But, if you are comfortable with your physical security, you can use sudo without a password.

In my case, there’s not a whole lot folks are going to do with sudo on my computer. Anyone with physical access to my device is someone that I trust. I also run a ton of commands when hanging out in the support sites and I am frankly just tired of typing my password when I use sudo.

So, let’s get rid of it. Start by pressing CTRL + ALT + T, and then enter:

Scroll down to the bottom and add this line:

Where “<your_username>” substitute it with your actual username on your computer. Now save it with:

CTRL + X

Y

ENTER

See that? You also may have just learned how use ‘nano’ to edit and save a text file while in the terminal. Pretty neat, huh? Anyhow, scroll up a little and look to the right. There’s a spot where you can enter a name and email address. If you do that (and confirm the email address) then you’ll get handy notices in the email when there’s a new article. I promise, I won’t send you a single non-site related email – ever.

Smash a Button
[Total: 0 Average: 0]
About Me: I'm just some retired dude with a little bit more free time on my hands. If you want to support the site, why not help yourself out too by ordering some inexpensive web hosting so that you can start your own site?


Change the sort-order in Lubuntu Quick Launch

Lubuntu has gone from LXDE to LXQt. In LXQt there’s no way to drag the icons in the quick launch to sort them to your liking. Fear not, you can still sort them.

This one is actually pretty easy, you just have to know where to look.

Edit: Press and hold CTRL and then you can drag and drop them…

Navigate to ~/.config/lxqt/ and open ‘panel.conf’ with your favorite text editor. Scroll down until you see:

[quicklaunch]

You’ll then see your quick-launch applications on their own line and they’ll have a numeric value. That numeric value is how you sort them. 

For example, mine looks like this:

In the ‘apps\1\desktop’ there is a 1. That translates to the furthest right icon in the quick launch area of the taskbar. If I wanted it to be on the furthest left, I’d change the 1 to a 6 and then change something else to be 1. It’s pretty straightforward. I was pleasantly surprised when I was able to find that section. Why we can’t just drag them around like we could on LXDE is another matter entirely.

As always, scroll on up and subscribe to get notifications when I publish something new. Or not… It’s up to you! Who the heck am I to be shouting out orders anyhow?!?

Smash a Button
[Total: 0 Average: 0]
About Me: I'm just some retired dude with a little bit more free time on my hands. If you want to support the site, why not help yourself out too by ordering some inexpensive web hosting so that you can start your own site?


How To: Enable Root User In Ubuntu

This article is just a really simple article. In it, I’m going to tell you how to enable the root account in Ubuntu (and related derivatives) by assigning a password to the account. 

First, if I may, I’d like to express some displeasures.

If you were to go ask this question on a number of sites, the people there would treat you as though you were a leper or a child. They’ll respond with things like, “You don’t need to use the root account, that’s what sudo is for.” Then, they’ll helpfully link you to a long-winded explanation of why using sudo is better.

Truth be told, they’re correct. They’re right. You shouldn’t be using the root account when it can be avoided – and it can pretty much always be avoided.

But, it demonstrates one of my pet peeves. See, they didn’t answer the question. It doesn’t matter that doing so may cause you untold horrors. What matters is that you asked a question and they opted to not answer you. It shouldn’t matter to them that you’re gonna do something stupid. What should matter to  them is giving you the answer to your damned question!

So, when someone asks me how to enable the root account – I tell them. Of course, I also mention that doing so is absolutely a bad idea, but I actually answer the question. This applies to other questions. If you ask a question, I do my best to answer it – if I am indeed taking the time to answer it. Maybe you just want to know how to do something? Maybe you have a good reason for it? It doesn’t matter to me, I answer the question to the best of my ability. Included in that is the appropriate warning, but I at least answer the question.

Linux is about freedom, and that freedom should include doing things that go against the grain. That freedom should include doing things like hosing your operating system. That freedom should include doing the ‘wrong’ things and doing them the ‘wrong’ way. 

So, keep that in mind when you’re answering questions – and not just this specific question. The person asking the question should get a real answer to their question, even if they’re asking the wrong question. If you can see it’s an X-Y problem, ask them for more information – but don’t be snide or aloof. If you’re not going to answer the question, just click that X in the upper right corner and close the tab. Sure, give them a warning – but also give them an answer.

So, on that note, here’s how you enable the root account in Ubuntu and distros derived from Ubuntu.

CTRL + ALT + T to open your terminal and enter:

Now, don’t get confused, it’s going to ask you for your password. Enter that, your normal account password, and press the enter button.

Next, it’s going to ask you to enter your new password for root. So, type that in and press enter. Then, it’s going to ask you to type that same password again, and again you’ll press enter when you’re done.

That’s it. Root is now enabled and you could login as root via TTY (this does not allow you to login as root via the GUI login during boot, that’s for a different article) or whatnot. You just probably shouldn’t. See, root has access to everything. It’s a security risk and it’s increasing the likelihood that you’ll irrevocably ruin your operating system when you fat-finger a command. Seriously, don’t do this. It’s just a bad idea and you can easily use ‘sudo’.

Like always, thanks for reading. Look to the right sidebar and enter a name and email address. That way, you’ll know when I publish something! You want to know that, don’t you?

Smash a Button
[Total: 2 Average: 4.5]
About Me: I'm just some retired dude with a little bit more free time on my hands. If you want to support the site, why not help yourself out too by ordering some inexpensive web hosting so that you can start your own site?


Use .htaccess to Stop People From Viewing Files in a Directory.

Open the directory with your favorite FTP client – unless you’re local and can just navigate to the directory.

Add a file called .htaccess. The ‘.’ is important and mandatory.

The permissions for .htaccess should be 644.

Edit the .htaccess file with a plain-text editor (don’t use a word-processor application) and add the following line:

Save the file.

What this will do is prevent indexing the files in the folder. If people try to access the folder directly, they’ll get a 403 forbidden error.

At the same time, you can still link directly to files in that folder.

So, let’s say you added the .htaccess to a directory called /tmp. You can still link to, use, and send people to /tmp/picture.jpg like normal, but people won’t be able to browse the directory and find files you don’t want them to see.

For more information,  click this.

Smash a Button
[Total: 0 Average: 0]
About Me: I'm just some retired dude with a little bit more free time on my hands. If you want to support the site, why not help yourself out too by ordering some inexpensive web hosting so that you can start your own site?