Disallow SSH Login For A Specific User

In today’s article, we’re going to learn how to disallow SSH login for a specific user. The reasons you might want to do this should be obvious, so that’ll save some time! Read on to learn how!

I’ve covered SSH in many articles. If you search for “SSH”, you’ll find a bunch of articles covering the subject. I’m not sure why there are so many, but there are. I seem to have a lot of notes on the subject. 

Here, this link will help you search for SSH articles.

SSH is “Secure Shell”, a method to login to remote computers so that you can manage them without being their physically. It’s used by systems administrators regularly, without ever needing a GUI to manage their Linux systems.

It’s also used by people like me, too lazy to walk to the other side of the room. I’m literally using SSH to manage stuff on my laptop from here on this desktop as I write this. On top of that, while not logged in right now, I was using SSH to manage a VPS earlier today.

So, SSH isn’t just for professional system administrators and, if you use SSH at home, you might as well know how to secure it. This article will help you secure your system – by learning how to disallow SSH login for a specific user.

Disallow SSH Login For A Specific User:

This article requires an open terminal on (and connection to) the computer you wish to change. That may require you to login to that computer remotely. If you’re on a local device and 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. Otherwise, SSH into it like a boss.

With your terminal/connection now open, enter the following command:

Find a place to make a new line and enter the following with some care:

Now, this one is a bit picky. Obviously, you substitute <username> with the real name – but in between “DenyUsers” and the username you absolutely MUST press the TAB key. If you try to just use spaces, it will not work! You MUST use the TAB key which will appear to insert spaces for you!

Assuming you’ve done everything correctly, you’ll need to restart SSH for the changes to take effect. You can do that with this command:

If you were logged into a remote system to make the changes on that system, the above command is gonna log you out and you’ll need to login again. You knew that, but I figure I’ll mention it.

Hmm… If you’re a barbarian that doesn’t use systemd, try this:

When SSH restarts, the prohibited user will get a “Permission Denied” message when they try to login. Ha! That’ll teach Jerry in accounting from thinking he’s a system admin!

Closure:

Whelp… You have another article. This one has shown you how to disable SSH login for a specific user (Jerry in accounting, who had no business accessing the server anyhow). You’re welcome!

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 Delete An Entry In Your Bash History

In today’s article, we’re going to learn how to delete an entry in your ‘bash’ history. It’s a useful skill to have, for any number of reasons. It’s not all that difficult and this shouldn’t be a very long article. Read on, my dear readers! Even a long-term Linux user might learn something – but I make no promises!

I’ve previously covered how to remove duplicates from your bash history. It may be worth checking that article out, as most of you are going to be using bash. Sure, there are other shells, but bash is the most common on desktops and servers. So, we might as well learn with bash.

If you don’t know, bash is both a language and an application. Unless otherwise specified, you’re almost certainly using bash when you open a terminal or TTY. 

When you enter a command in the terminal or TTY, it’s saved to your bash history. In fact, it’s saved to the hidden file ~/.bash_history. If you so wanted, you could just open the .bash_history file with a text editor and remove lines as you wished. That works just fine.

However, in this article we’ll be using the ‘history’ command. It’s a handy command, useful for recalling previously entered commands and managing those stored commands. I guess this is really more an article about performing some very basic tasks with the history command. Like I said, it’s good for you to know this sort of stuff – especially as a Linux beginner.

Delete An Entry In Your Bash History:

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 right up and be ready for use!

So, with your handy-dandy freshly-cracked-open terminal, let’s just display your bash history. You’re going to do that with just the following command:

You’ll notice that every stored command from your bash history is assigned a number that’s shown on the left (or right, if you use a RTL language). Well, that’s how you delete it. You use that number in the following command:

You can use that command to delete an entry in your bash history, and you can do so as often as you’d like. While you’re there, you can also just plain clear your entire bash history with this command:

That will clear all of your bash history – more or less. Your current session may have not been written to the history at the time you issued that command. It might not be saved until you close the terminal instance. This makes it slightly more complicated to make sure the history is truly empty. However, it’s definitely close enough.

Anyhow, you might want to delete your bash history to remove commands that you’ve memorized. You might want to remove commands that didn’t work. If there are sensitive commands in your bash history, this is a way to remove them, surgically or en masse. There are all sorts of reasons why you might want to go through your bash history to delete past commands – and now you can!

Closure:

Yay! It’s another back-to-basics kind of article. In this one, we learn how to delete an entry in your bash history file. In some cases, it may be easier for you to just do so with a GUI and a GUI text editor. You don’t even need ‘sudo’ to make the changes and removing a lot of entries might be faster with a graphical application. Just remove the lines you don’t want showing up in the history any longer.

Also, I should mention somewhere that you can see the history by just pressing the up arrow, but I suspect folks will already know that. ‘Snot the best way to go about managing them, but you can see and select them, running them again as you wish.

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.

Use ‘apt’ To Download A Program And Its Dependencies

In this article, we’ll discuss a way to use ‘apt’ to download a program and its dependencies. The usual reason to do this is to install said program on an offline computer. We’ll be doing it all nice and neatly, just using the ‘apt’ application along the way. It won’t be all that difficult, but will be easy to link to and reference.

As I said, the usual reason to do this is because you have a computer that’s not online and you want to install some software on that computer. This could be a remedy for when you need wireless drivers in order to connect the device, or other sorts of situations. It’s a handy way to get those drivers up and running, so we might as well learn how to do so today.

We’ll be using ‘apt’ for this. We’ve used ‘apt’ for all sorts of software management tasks in the past. In fact, in the past this required a bit more effort. You’d use the ‘–download-only’ flag and get some files in your apt archives directory. Today, it’s just a quick task that outputs a handy file that is extremely portable.

In fact, this article really only needs one command, making ‘apt’ do its thing. It’s not all that difficult, either. By the way, if you don’t already know, ‘apt’ stands for Advanced Package Tool. Anyhow, I’ll still make it an article – as it’s a useful one to know and reference.

Download A Program And Its Dependencies:

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.

With your terminal emulator now open, you need to know the name of the program you want to download. For example, I tested this with ‘openjdk-17-jre’ and it worked as expected. (For the commands you’ll use, I’ll just use my traditional brackets.) Before I tested with openjdk, I made sure it had dependencies, and it did. To see if it had dependencies, I used this command:

Once you see that it has dependencies, you can go straight to downloading the program and its dependencies. You no longer need any long commands, it’s just (even if it doesn’t have dependencies):

All you have to do at that point is wait for the files to download. When they’re done downloading you can find the file in your ~/Downloads directory combined into a single compressed file. In my case, the filename was openjdk-17-jre.tar.gq and the download completed without error.

The process is the same if you have dependencies or not. The reason we pay attention to dependencies in this article is so that you know to check and make sure those dependencies are included, so that you’re able to install the software on your offline computer.

And, with all that said, now is a good time to verify that it contains all the files it should contain. Assuming the files are what you expected, with dependencies as needed, now is the time to sneakernet them to the offline computer, where you can install the program by first installing the dependencies before installing the program.

NOTES: It does build an ‘install.sh’ which should let you install the program and dependencies in one fell swoop, but it accessed the ‘net in my testing. So, just do ’em manually if you want to be sure, otherwise make it executable and give it a shot. This will only work if the versions are all compatible with the offline computer. If that’s not the case, you could end up in dependency hell or perhaps not able to install the program at all.

Closure:

And there you have it… You have yet another article! This one is handy if you want to install a program and its dependencies on an offline computer. It may also be handy if you want to establish a base-line and standardize on that specific version of the software. In that case, you’ll have a copy of what it once was. It’s something you can reference and restore as needed. But, yeah, it’s most likely to be used by people who want to install software on offline 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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Change The UUID For Your Disk Partitions

Today, in an article of little use to anyone, we’re going to learn how to change the UUID for your disk partitions. It’s not something you’ll want to do often, or even at all. There really isn’t much motivation to do so. In fact, this might just be one of the more useless articles (that isn’t a meta article) on the entire site! (I should mark it as ‘important’ for my own amusement.)

Why then is this an article? Well, it’s kinda neat, a little informative, and it was in my notes! As to why it is in my notes, I think I documented the process for a person on one of the various forums. I have no idea why they wanted to do this, but it is something you can do. I did check to ensure that it should still work.

A ‘UUID’ is a Universally Unique Identification. Your partitions have one. It’s a 128-bit alpha-numeric identification used internally seldom by you the user. At 128 bits, odds are very good that your ID is truly unique – but there’s no actual verification or anything. Your system generates ’em more or less pseudo-randomly and that’s the end of it.

If you want, run this command in your terminal (open a terminal, per my usual remarks):

That should show you your partitions and their UUID. It’ll also spit out a bunch of information that will help you identify it – such as the label field. That’s good, as you’ll want to pick one that you just don’t like and we’ll work on changing that one UUID to something new.

Change The UUID For Your Disk Partitions:

Up above, you should have opened a terminal and loaded up some information about your various partitions. Lemme see if I can get you a good example output – I’ll plug in an external drive with a bunch of partitions:

So, there… You can see some data and see the UUID. Should you want to actually change the UUID, now’s the time to pick it.

Now, we’re going to generate a new UUID. Yup, you can do that. Try one of the following two commands – though both should probably do the trick:

Or:

One, or both, of those will surely work on any modern Linux distro – unless it’s stripped down. If you don’t like the first one, you can keep generating them until you’re happy with the results. (You’re very, very unlikely to have a duplicate – as I’ll explain later, in the closure section.)

Now that you have your new UUID in hand, you’ll need to unmount the partition you’re going to change. If you don’t know how to do that, it’s just:

For example, that might be /dev/sdb2 or /dev/sdb4 that you’ll use to unmount the partition.

With that unmounted, let’s go ahead and finally change the UUID! You do that with:

Be sure to change the obvious for the obvious. Copy and paste from your terminal, perhaps even using two terminals, to ensure you get all the information correct.

When you’re done, the effects should be immediate. though you may need to mount the partition first. Run the following command to check:

If you’re satisfied with the results, great! If you need to first mount the partition, you can try this:

All should be wrapped up nicely in a bow, with your UUID happily changed to something else. Again, I don’t really have any good reasons for doing this – but you can do so if you want. I did mention that this was pretty useless… You were warned!

Closure:

Well, there you have it – another article? Hmm… Let’s really wrap it up. You know how it says it’s a “Universally Unique Identification”? Let’s look into that with some math.

Well, it’s 128 bits. That’s 2128 (less if a signed integer) which is equal to ~3.4 x 1038. I decided to look that up and find someone who did the work for me. This is that number represented in English:

three hundred forty undecillion, two hundred eighty-two decillion, three hundred sixty-six nonillion, nine hundred twenty octillion, nine hundred thirty-eight septillion, four hundred sixty-three sextillion, four hundred sixty-three quintillion, three hundred seventy-four quadrillion, six hundred seven trillion, four hundred thirty-one billion, seven hundred sixty-eight million, two hundred eleven thousand, four hundred fifty-five

Source: Quora

So, is the UUID you have truly unique? If you change the UUID, is it truly unique among all others? Perhaps, but you have better odds of winning the lottery multiple times in a row than you have of finding a matching UUID anywhere on the planet. 128 bits is a lot, an amount your human brain isn’t able to understand, which is also kinda why we will likely be a while longer before we move there from 64 bit. 64 bit is still pretty darned huge and there’s no real need for 128 bits at this time.

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.

Check Your (Write) Disk Speed In The Terminal

Today we’re going to discuss one way for you to check your write disk speed in the terminal. That is, we’re going to learn how long it takes you to write data to your disk drives. It’s a very simple set of commands and easy enough for anyone to try. There are other methods, this is just one of them.

After all, I recently did an article that let you check your (read) disk speed in the terminal. I might as well do an article that lets you check your write disk speed in the terminal. The former article was about how fast you can read data from your disk drives. The current article is about how fast you can write data to your disk drives.

There’s not really all that much real world work that this is going to benefit. You’re able to read and write data as fast as you’re able to read and write data. If you want to change that, invest in different hardware. Knowing the read and write rates really doesn’t do you much good – it’s just an interesting bit of information and maybe a reason for you to brag to your friends.

Today we’ll be using the ‘dd’ command. Be sure to be careful with this command because once you set it loose it does exactly what you told it to do. It can and will cause you to reach for your backups… If you don’t know, ‘dd’ defines itself as a tool to convert and copy files. You should read the man page sometime. It’s a rather robust, and potentially complicated, application.

Anyhow…

Check Your (Write) Disk Speed In The Terminal:

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 thing we’re going to do is make a new directory and move to it.

Now, let’s start testing. I’m going to assume you have at least 10 GB worth of space (we’ll be using ~5.5 GB, or 5 GiB). If you do not have enough space, don’t run this command until you do have that much free disk space. The command to run the test is:

Here’s a test result on a slower, in use SSD, about what I expect most users to have:

It will show you the progress, as we’ve enabled that in the dd command. It won’t take all that long for the test to complete. Unless your drive was otherwise heavily occupied, there’s little to gain from running the test multiple times.

Anyhow,  how about we cleanup after ourselves? As the file was made with ‘sudo’ so too shall it be removed with ‘sudo’. It will probably even ask you for confirmation.

And delete the directory:

That should have cleaned up our mess, all nice and fancy like. There’s no real reason to keep a 5.4 GB test file hanging around and you already have the test results.

Closure:

There you have it! You now have another article and this one will show you how to check your write disk speeds for your drives. If you want to test other drives, just write the file to those drives by navigating there first in the terminal. ‘Snot all that difficult.

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.

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.