Add User To The ‘sudoers’ Group

Today we’ll have a pretty straightforward article that’s meant for those who want to add a user to the ‘sudoers’ group. I have tested this in Ubuntu, specifically in Lubuntu, and it works. It shouldn’t be a complicated article, one easy enough for anyone to follow.

I am not 100% certain if this will work in other distros, so comment and let me know if it works with others. It should work in Debian, the official Ubuntu flavors, Mint, POP!_OS, ElementaryOS, and more. That much I’m pretty confident of, but I’ve done limited testing.

This article is going to assume you’re using ‘nano’ as your default text editor. That’s important for this, otherwise, you’ll need to change the directions to match your text editor of choice.

Let’s Install Nano (With Some Bonus Information)

We’ll be using a tool known as ‘visudo’. The man page defines it as:

visudo — edit the sudoers file

It’s important to use visudo to edit the sudoers file because it checks for errors and will prevent you from making syntax errors. It can’t correct bad information, but it can prevent you from making some basic mistakes.

What is the ‘sudoers’ file? 

Well, simply put, that’s the file that decides who has the rights to access sudo, and what rights they have to do so. A sudo user has administrative privileges, that is the ability to edit files that can’t be edited by a regular user. The sudo users can do things like change system files, change system settings, and add or remove software. They’re administrators (though you technically can give them limited rights, which is a topic for another article) so to speak.

So, What Is ‘sudo’ Anyhow?

You should make good choices when deciding which accounts have sudo access. They, at least by default, have the keys to the kingdom. A user with sudo access has complete control over the system. This isn’t always a good thing.

Many distros, including Ubuntu, use sudo instead of a root account. Root also has the keys to the kingdom. It’s a good way to view sudo as temporarily elevating the user’s rights to that of the root user. It should be obvious why this is beneficial.

Most of us don’t want our account to have root access all the time because it stops us from editing files we might not want to access – and the software we use also only has our regular user’s limited access to the system. Some folks are into running as root, and some distros have root enabled by default. The great thing about Linux is the choices available, including choices about security.

How To: Enable The Root Account in Ubuntu
How To: Graphically Login as Root in Ubuntu

(It’s generally suggested you not follow the directions given at those two URLs, but I’m a big fan of choice and of sharing information. So, you can do what you want. I do ask that you be careful and be a good netizen.)

That’s what we’ll be doing today. We’ll be learning how to add a user to the ‘sudoers’ group (file I suppose). Those user accounts will then have sudo access, the keys to the kingdom. There are a ton of valid reasons for doing this, and some not-so-good reasons. It’s your device. You do you!

Add A User To The ‘sudoers’ Group:

Yes, this article requires a terminal. I don’t know of a GUI way to accomplish this task. I’m sure there is one, but I don’t know. If you know of one, feel free to add a comment. Otherwise, press CTRL + ALT + T and your terminal should pop open.

With your terminal now open, you can easily just run the following command:

Of course, that’s the easy way…

If you want, you can manually edit the sudoers file. You’ll want to know how to do this if you only want to give the user elevated permissions to certain directories or files. So, I’ll include that. We can use this article as a reference article for a future article.

To manually edit the sudoers file,  you just run the following command:

You’ll then add the following line at the bottom of the file:

Replace the obvious with the obvious, as always. Be extra careful to avoid typographical errors. Then, you’ll save the file. As we’re using nano, the process to save the file is pressing CTRL + X, then Y, and then ENTER – and that should save the file. Congrats, you now know how to add a user to the ‘sudoers’ file.

Closure:

Well, it’s another article. As I mentioned, there are legitimate reasons to add a user to the sudoers file. There are also legitimate reasons for not doing so. It depends on you and your circumstances – and your computing goals are your own. This is Linux. We can do what we want!

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Dealing With “Could not get lock /var/lib/apt/lists/lock”

Today’s article is a rather specific article, where we examine a couple of ways to deal with the message “Could not get lock /var/lib/apt/lists/lock”. This is an error message that you’ll get when something is already updating (or installing) and you try to install something else or if you try to perform updates.

Basically, when you update something, apt will lock a file so that nothing can interfere with it. This is a good thing, ensuring your updates go smoothly. This is something you want to have to happen.

However…

Things don’t always go according to plan. Things may freeze, things may take too long, and things can stop the upgrade (or update, let’s use those words largely interchangeably). You may find yourself coming across this message and not knowing what to do.

A bit on update and upgrade

First, obviously, this article only applies to distros that use ‘apt’ as their package manager. So, that’s Debian, Ubuntu, Mint, and many more that are derived from Debian or Ubuntu.

You have on your computer a database of software available in the repositories you’ve enabled. Then you update this database software with ‘sudo apt update‘. You then upgrade your software when you run ‘sudo apt upgrade‘. So, in the very specific terminology used, there’s a difference between update and upgrade. I know this, but will use the words interchangeably. 

As mentioned, when you’ve started this process (that is the updating of the database) you’ll be frozen out of further apt commands that can act on the system. You can still run queries like ‘apt-cache search foo‘ but you can’t install or uninstall software while this process is happening. The same is true during the upgrade portion of the process.

Well, that’s when you’re going to get this error message.

For example, I recently had to update a Linux Mint system and the update process was horrible – but mostly because it didn’t seem designed to work with bandwidth like mine.

There were constant timeout warnings even though things were still downloading. Things would also freeze entirely and it was during this that I realized I should write an article about what to do when you get the message “Could not get lock /var/lib/apt/lists/lock”. After all, I was killing that process like an assassin in a video game. I showed no mercy!

NOTE: The correct thing to do is wait. If waiting doesn’t work and much time has passed, the next correct thing to do is reboot. After you’ve rebooted, you should try the update again and follow any directions it might give you.

YOU SHOULD NOT DO THIS!

I don’t always follow directions well. Nor do I always do the right thing. This is hardly the first time I’ve given you answers about how to do the “wrong” thing right. This probably won’t be the last time I’ve told you how to do things that are generally considered a bad idea, sometimes an especially bad idea.

With that said and done…

Fix “Could not get lock /var/lib/apt/lists/lock”:

You’re going to want an open terminal for this. Yes, a terminal. You should be used to that by now. The terminal is a handy application and we use it often. In most cases, you can just press CTRL + ALT + T and your terminal should open.

We want to get rid of the message “Could not get lock /var/lib/apt/lists/lock”. and I’ll cover a couple of quick and easy ways to do this, meaning you can (generally) start the process all over again. With your terminal, we’re going to find the PID – that is Process ID – and kill it.

You can read this article:

Find An Application’s Process ID (PID)

Or you can skip that article…

We already know that we’re interested in apt’s PID, so we just run this command:

Take the output from that and enter it in the following command:

Of course, that’s the fun way. You can actually use a much easier command to deal with the “Could not get lock /var/lib/apt/lists/lock” message. It’s not nearly as fun, but it should work every time. Try this command:

That one command should always work and is fairly easy to remember. You just take the path of the lock from the command, elevate your permissions, and remove the lock. It’s not unlike using lock cutters on a real-world lock, but requires much less physical effort!

Again, I highly suggest you resolve this message in the proper manner. Wait a while, reboot if nothing changes over time, and then try the update again so that you can follow any directions it gives you. That’s the smart way to deal with this.

Closure:

Yup… Here I am giving bad advice on the internet. I figure folks might just want to do this. If they want to do this, they might as well have good directions. This isn’t the correct way to deal with “Could not get lock /var/lib/apt/lists/lock” but it’s a way of doing so. You could end up with some currupt files and impropperly installed software, so you really should not do it this way, but it’s your computer.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Temporarily Set A Static IP Address

Today we’ll have a fairly simple article that may not generate much interest as we’re just learning how to temporarily set a static IP address. This isn’t all that difficult, as I’ll just show you the syntax, but it’s something you might find worth knowing. So, if you’re interested in learning how to temporarily set a static IP address, read on!

What is an IP address?

If you have to ask that question, this article isn’t one that you need to try. You can, it’s just usually something reserved for specific circumstances.

Every networked computer is assigned a numerical IP address. You may have more than one address, including a public and a private IP address. It’s possible to have an IP address on multiple network interfaces, but every connected computer has an IP address. That’s what we use for the web – you just don’t see it as we use domain names that get resolved to IP addresses.

Some links you should read:

How To: Find Your IP Address Through Your Terminal
Find Your Network Interface Name
A Couple More Ways To Find Your Network Interfaces

Those articles aren’t all on the same subject, but they’re articles where I discuss things like IP addresses and DNS. If you’re new to this, you should read the first link, about how to find your IP address. 

The IP address we’re concerned with is our private IP address. This is different than our public IP address and is used on your local network. It’s the address your router sends data, for example. If you remotely control devices on your network, that IP address is what goes on behind the scenes as it denotes the device.

Each private IP address will almost certainly resolve to just one device. This is not true everywhere. One IP address can have many websites and some ISPs are doing IP address subnets for public IP addresses because they’ve run out of IPv4 IP addresses. You needn’t concern yourself with that and that’s just for some random information.

So, the IP address we’ll be setting as a static IP address will be your internal, that is private, IP address. I sometimes do this when I don’t want to have to hunt around for an IP address and device.local isn’t working.

This will only be a temporary change. When you reboot your computer, you may have an entirely different IP address. I don’t want to add complexity, but some routers may already assign a device the same IP address every time it sees it. While this isn’t a static IP address per se, it’s effectively the same.

We’ll be setting that private IP address locally, establishing it on the computer itself. Any modern router should handle the change just fine. However, this may prove problematic for those who have equipment that strays from normal behavior. If that’s the case for you, either reboot or just change your IP address back to what it was originally and everything should be good. However, I can’t see this being a problem, because your original IP address will still work just fine.

Got all that figured out? Well, good! Let’s jump into the article!

Temporarily Set A Static IP Address:

Yes, you’re going to need an open terminal for this. There might be a way to do this with a GUI, but I’ve never tried it. Route around in your network manager and there might be a way. Specifically, check for DHCP and see if there’s a way to change that to a manually configured IP address. It might be the ticket. I’m seeing something similar to that in my network manager, but I haven’t tested it.

Anyhow, as you’re going to need an open terminal, you can probably just press CTRL + ALT + T to open your default terminal. If that doesn’t work, just open it from the application menu. You’ll probably find a terminal application listed under your administration (or system) tools. That’s a good spot to start looking.

With your terminal now open, we need to find the name of your network interface. I shared a link in the opening section, but the command is just this (assuming you’re using a modern distro):

Your network interface names will look something like enp2s0 (for an ethernet/wired connection) or maybe something like wlxe4beed0e5f5c for a wireless network interface. You can assume ‘en’ is ethernet and ‘we’ is wireless. That seems to be fairly consistent. 

Now, while you’re there, you need to determine your IP address, specifically your private IP address. This may look something like this:

That’s the number you’re going to change.

NOTE: Unless otherwise noted, you want to stick to Class C private network addresses. These are addresses reserved for your private networking and are 192.168.0.0 to 192.168.255.255.

So, let’s say your private IP address is indeed 192.168.1.4 and you want to change it to 192.168.1.42 (because 42 is indeed the answer). You can do that. The syntax needed to temporarily set a static IP address is as follows:

So, it’d look like this:

Next, you verify that it worked:

What this does is it adds a static IP address. Your original IP address will still work, but you’ll have designated and set a static IP address that will also work.

You can add all sorts of static IP addresses by this means. If you run the ip addr command again, you’ll see that the static IP address has been added under the fixroute <network_interface_name> heading.

For example, see this image:

setting a static ip address
Any and all of those private IP addresses will now work and remain static.

You can just reset it to the same original IP address but you shouldn’t need to. This shouldn’t break anything because the original IP address remains the same and remains usable. You can connect to that computer with any one of those private IP addresses, each of them a static IP address.

It’s possible to make this change a permanent thing, which might make an interesting future article. I don’t think anyone will find it complicated. These things are easier to do than they are to explain. I spent more time with the verbiage than anything else. It’s hard to include all that you need to know because I don’t know what you know. 

Closure:

Well, there’s another article. If you’ve ever wondered how to set a static IP address, this is the answer. It’s not complicated. Anyone should be able to figure it out, using the syntax above. I hope that I’ve made it clear. Sometimes it’s not all that easy to explain stuff in plain English without going too deep.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Decompress tar.bz2 Files

Today’s article will be simple enough, though it will have limited application, as we discuss how to decompress tar.bz2 files. While this is certainly suitable for a newbie and easy enough to learn, many folks will just choose the GUI route.

Of course, you’re not always able to use a GUI. Sometimes there’s no way to do this graphically and you’ll have to do this in the terminal – perhaps over SSH. In fact, with my crappy bandwidth, I like to upload compressed files and then extract them on the server itself. This sort of thing works for me.

We have already talked about how you go about compressing and decompressing .bz2 files. You can read that article here:

How To: Compress And Decompress .bz2 Files

This time we’re going to be working with ‘tar.bz2’ files – and decompressing these files is different than what you’ll have learned from the previous article.

What is ‘tar’?

A tar file stands for ‘Tape Archiver’ and is a compression method as old as time itself. Well, probably not that long – but a very long time. It’s sometimes referred to as a ‘tarball’ and Wikipedia tells me that it has been around since early 1979.

Here’s a good quote from Wikipedia:

The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization.

The blurb goes on to mention that POSIX has supplanted tar in favor of pax, but when was the last time you saw a .pax file? So, tar is still widely in use.

The man page describes tar as:

tar – an archiving utility

Which is exactly the kind of thing we’re looking for. Imagine that?

What is .bz2?

If you read the link above, you’d know the answer to this question. I assume my readers are creatures of habit, so they’ve done no such thing. They’re probably skipping this section entirely and reading just the middle of the article.

Anyhow, in the previous .bz2 article, I mentioned this:

If you don’t already know, .bz2 files are bzip2 files. You’ll find that bzip2 is an opensource compression program that gets some regular usage, and you’ll sometimes find downloaded files that are compressed with this format. You may also, for compatibility reasons, want to compress files with bzip2 to share with other users who are already set on using the .bz2 format.

That sums it up nicely, though you don’t have to worry about that. See, with this particular command and these particular tar.bz2 files, you can decompress (extract) the files in one fell swoop. 

Just for the record, you should also know that the bzip2 man page defines itself like so:

bzip2, bunzip2 – a block-sorting file compressor, v1.0.8

Your man page might be different, saying that it’s a different version. Either way, that’s what bzip2 is and that’s what it’s used for. 

So, with all that in mind, we can get to the important bits of the article…

Decompress tar.bz2 Files:

As I mentioned in the intro, you can likely do this with your built-in GUI file extraction tool (often file-roller) easily enough. However, again as suggested in the intro, we’ll be doing this in the terminal. In most cases, you can press CTRL + ALT + T to open the terminal.

With your terminal open in the correct directory, you can start by listing the files in the archive without actually decompressing them. That command would look like this:

That will happily spit out a list of all the files included. If you want, you can make the output more verbose by adding the -v flag, so that it’d be tar -tvf for example.

Next, I assume you want to decompress the tar.bz2 files, that is to extract the files within. To do that, you’d want this command:

Finally, I’ll give you a fun command. Let’s say you only want to extract files of a certain type, that is with a certain extension, from your tar.bz2 file. Well, you can do that and it’s easily done. Just use this command:

That command would decompress and extract all the files with .jpg as their extension. You can use any extension there, being sure to use the * to indicate a wildcard even though you already specified it with the –wildcard flag. It is what it is.

There’s more that you can do, but those are the ways I figure most folks are going to decompress tar.bz2 files. Just be sure to check the man page (man tar) to learn more about the command.

Closure:

Well, for better or worse, my articles have been pretty verbose lately. Yes, yes it does tell me how many words are in each article. I’m not sure why I ended up being more verbose lately, but I think it’s a good trend.

Anyhow, today we learn how to decompress tar.bz2 files in the Linux terminal. It’s a useful skill to have and a good tool to toss into your Linux toolkit. You never know when you’re going to need to use these commands, but there may come a time when you do – and you can refer back to this article to learn how.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: List Mounted Partitions

Today we’ll have a nice and simple article, simply because we can, about how to list mounted partitions in Linux. Like so many of these articles, we’re going to need an open terminal. On the other hand, we’ll just be exploring a couple of tools to help us along the way.

Your disk drives, be they solid state or hard disk drives, will be separated into partitions. It can get confusing until you realize that the outputs from these commands won’t always just represent what I’ll call physical partitions. Sometimes, there are virtual partitions – sometimes with their fun file systems.

You may have everything from mounted temporary partitions to software designed to run in its own mounted partition space. When you run these bellow commands, you’ll learn that there are all sorts of mounted partitions. This is completely normal. It’s also pretty easy to weed out the physical partitions.

Why would you want to do this? Well, I’m having a goofy error when I boot one of my computers and I need to narrow it down to which disk it is that’s giving me the error. Once I take the time to do that, I can move on to troubleshooting the problem and finding a solution for the problem.

The tools we’ll be using are ‘findmnt’ and ‘df’. They’re described as the following:

finding:

findmnt – find a filesystem

df:

df – report file system disk space usage

As you can see from the description, both of those have something to do with getting information about a file system. That makes them good tools for the job.

NOTE: There are multiple ways to list mounted partitions. You have GUI and CLI-based tools available to you. One of the goals surrounding this whole project is not just to make people more familiar with Linux but also to help them get comfortable working within the terminal. You’ll be just fine!

List Mounted Partitions:

As I mentioned above, we’ll be using a terminal for this. I do not mind which terminal you’re using but you can usually open the default terminal by pressing CTRL + ALT + T. That works most of the time.

With your terminal now open, you can try the following command:

The output from that command will list your mounted partitions. It’s a lot of text, but most folks are probably only interested in the start of the line. The output of the findmnt command may look a little something like this:

The next command you’re going to want to try will be the ‘df’ command. We’ll be using a few flags. It’s not very complicated, though it may look like it. The command is a simple ‘df’ command and looks like this:

We use the -a flag for ‘all’. Then we use the -T flag because that means type. Finally, we use the -h flag because that means the output will be “human readable” (or more easily read by us mortals.) The output of which looks something like this:

No matter which of those commands you use, it will make your terminal list mounted partitions. If you need to know which partitions are mounted, these are the tools you can start with. They’re easy enough to work with.

Closure:

Well, it’s a bit late in the evening. I almost forgot that there was an article due tomorrow. This happens when I get a lot of responses (elsewhere) on the wrong day. My brain just doesn’t click. I should probably set an automated notification to let me know which days require articles, but I haven’t failed yet. In fact, you get an interesting article about how you can list mounted partitions.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.