Enable x11 Forwarding With SSH (Remotely Use GUI Applications)

In the last article, I explained how to enable SSH. In today’s article, we’re going to learn how to forward GUI application windows with SSH. x11 forwarding is easy and beneficial. Once you learn how, you may decide to stop using VNC or TeamViewer.

Just to quickly clear up a misconception, x11 forwarding works just fine with Wayland. Way back in the earliest days of Wayland development, it was agreed that it should retain backwards compatibility with x11 forwarding.

What is this strange thing, this x11 forwarding?

Well, when you’re connected to another computer via SSH you can use the terminal to control the computer. That’s great, but what if you want to use a GUI application? Sure, you could set up some sort of remote desktop application, such as VNC. Or, alternatively, and often more simply, you can just forward graphic applications over SSH. It’s remarkably easy!

Perhaps a picture is in order. Check this:

gedit in action
That’s GEdit running on a different computer, but forwarded to this one. Pretty neat, huh?

That’s right. That’s GEdit running on my laptop. I’ve just forwarded the GUI application to this computer. If I write something and save it, it’d be saved on the computer that I’m connected to and not the computer that I’m using.

Amusingly, I used this exact process just recently. I had to move a complex password to my laptop and I was being lazy. So, I opened GEdit remotely and pasted in my password, transferring my new password to the other device. See? It comes in handier than you might think.

Let’s Enable x11 Forwarding:

How do you do this? Well, first you need to crack open your terminal. To do that, you just press CTRL + ALT + T on your keyboard and your default terminal emulator should open.

Now, in said terminal, you need to run the following command:

Once you have that file opened with nano, you just need to remove the appropriate pound sign (“uncomment” it out) for the right line. Look for the line that says:

And change it to:

Then save the file with nano by pressing CTRL + X, then Y, and then ENTER. (You may want to learn that, as that’s how you save files in nano.)

Next up, you’ll restart the SSH service and be done with it:

And that’s it! You can now use x11 forwarding over SSH. To do so, you just need to add the -X switch. That’s not as complicated as you might think. Nothing in this article is all that difficult.

To try to make sense of that above command, if I were to remotely connect to the MSI laptop, then my command would look just like:

You can also use the IP address, instead of the hostname, just like we discussed in the previous article about SSH. To do that, it looks like this:

x11 Forwarding in Action:

Once you’re there, just go ahead and start an application. For example, open gedit by typing just that into the terminal. You may find some applications won’t work, often due to ownership and permissions issues, but you’ll find many that work just fine. If you find one that doesn’t work, you can always check any errors thrown and go from there.

Firefox forwarded over SSH
See? Note the carefully drawn arrow that shows where it was forwarded from. Tada!

That’s an example of Firefox forwarded over SSH using x11 forwarding and you may notice the washed out look. I haven’t really dug into it, but I am reasonably confident that washed out look is because of compression. I’ve never needed to dig into that and, amazingly enough, I don’t know everything.

Conclusion:

Anyhow, there you have it. One more article in the books and one more bit of knowledge plastered across the internet. Thanks for reading! If you want to help, you can donate, you can share the site on social media, you can vote to show what type of articles you enjoy, and sign up for the newsletter. You can even buy inexpensive hosting and start your own site while supporting this site or write your own article!

Install SSH to Remotely Control Your Linux Computers

If this article’s headline looks vaguely familiar, it’s probably because I previously wrote an article that told you how to install SSH. That article was on the earlier site. This article will show you how to install SSH, so that you can remotely control your Linux computers.

The old site, while up, will redirect to this address. It’s also a bit of a misnomer. We’ll be installing ‘OpenSSH‘ and enabling SSH. SSH is the protocol, OpenSSH is the application, specifically the ‘openssh-server’.

Let’s say your computer is in another room, in another state, over in another country, or perhaps on another continent entirely. How are you going to manage it? Servers are scattered across the world and it is not even remotely economical to send a person to administer each one of them in person. You’ll need to manage these devices remotely.

One of the best tools for this job is SSH.

As a home-use note; SSH is perfectly suitable to manage my own router. It’s quick, easy, lightweight, effective, doesn’t require an attached monitor, and more. What’s not to like? I SSH into my computers all the time! In fact, right this minute I’m connected to two other computers via SSH!

SSH has been around since 1995 and it lets you issue commands on a remote computer. In fact, the man page describes it like this:

ssh — OpenSSH remote login client

Which, as you can guess, means it lets you login to remote computers so that you can control them. It’s a pretty handy tool to have in your toolbox and it’s actually simple to install.

Install SSH:

SSH is really the protocol, and you can do many things over it. OpenSSH is the application that we’ll really be installing. Once that’s installed, you can login to the computer remotely and manage it that way. I use it quite often.

My homemade router doesn’t have a keyboard attached. It doesn’t even have a monitor attached. It’s not like I can just easily walk over and deal with it. I just got a laptop that, and it’s only used to test Lubuntu. I don’t always want to have to go over to the device and physically use it to start the test.

There’s also my dedicated server in Las Vegas – and I live in Maine. It wouldn’t be practical to fly out to Vegas every few days to run updates on the server. It wouldn’t make financial sense to go out there every time the server needed to be rebooted!

Those are all situations where you can use SSH. It’s available in pretty much every default repository out there. I’m surprised more people don’t use it. To get started, you just open your terminal (press CTRL + ALT + T on your keyboard) and enter the following:

If you’re using a distro with apt:

If you’re using a distro with yum:

Simply adjust that for your distro. For example, in OpenSUSE you may have installed it during the OS installation process. If it wasn’t installed during the initial OS installation then it’s just called ‘openssh’ – if you want to install a few of the applications surrounding openssh. You can also do a ‘sudo zypper install openssh-server’ like the rest of us.

Anyhow, once you’ve installed it, you may not even need to start it. If you install it on Ubuntu, you can go right ahead and test it immediately. If your distro requires that you start it manually, you should do that.

Once you’re done, you can test it easily enough. Try this:

If that works, you’ve properly installed openssh-server and can now make use of SSH. You may also need to enable it in  your firewall. Chances are that your firewall knows what SSH is.

To connect to your device from a remote computer, you’d do:

You can use a specific username in that command, like demonstrated in the testing command just above this command. It’s not mandatory, but doing so will skip a step.

Closure:

You can expect a couple more SSH articles, as this is woefully incomplete. A lot more can be done with SSH, plus SSH should be properly secured. For most of you, behind a NATed router, you don’t really have to worry too much unless you enable port forwarding. If you’re making the port available to the world-wide-web, you’re definitely going to need to add some security. Otherwise, there are a few nifty things you can do once SSH is enabled. We’ll cover those in future articles.

You can also connect with your hostname – probably. In many instances, you’d do this (distro-dependent):

For example, to connect to my testing laptop, I use the following command:

Go ahead and play around with it. There’s a number of ways to help secure SSH and we’ll go over some of that in a future article. I’ve been maintaining the ‘article every two days’ thing for a while now. I see no reason to expect that to not continue.

Y’all have been chewing through bandwidth, so if you’d like to donate that’d be awesome. There are also ads that you can unblock. It’s very much against Google’s rules to ask people to click on them, but I can ask you to unblock them!

You can also register to help, write an article of your own, leave comments, vote on articles, sign up for the newsletter below, or even help support the site by buying inexpensive hosting. Equally important, please share these articles on social media! The more traffic, the happier I am – even if I’ve gotta pay for it myself! Until next time…

Repair Your Linux Filesystem With a Live USB or DVD

It’s possible for your filesystem to become so corrupted that you can’t repair it easily. In that case, you can repair your Linux filesystem with a live USB or DVD.

Your filesystem may become corrupted for any number of reasons. One of the most common reasons is an improper shutdown, where your filesystem doesn’t have time to properly write everything to disk because it wasn’t shut down properly. You might see that sort of thing when you suffer from a power outage. 

There are any number of reasons why your filesystem will have become corrupted and, in most instances, your system will automatically repair your Linux filesystem when you boot your computer.

It’s also possible that a simple boot won’t repair your Linux filesystem. In that case, your OS probably has some sort of recovery mode and you can use that mode to repair your filesystem. 

Once in a while, your filesystem may have become so corrupted that you can’t fix it in recovery mode because you can’t get to recovery mode to fix it. Not to worry. This is something you can easily do with a live USB or DVD.

This article assumes you already have a USB or DVD with an OS that runs live. I’ll use Ubuntu as the example OS, as it’s really common. Adjust for your distro and you’ll be okay.

Here’s a link if you need to know how to access your temporary boot menu

NOTE: If you’re using Btrfs, you shouldn’t need to run fsck, it should heal itself. If not, here are Btrfs-specific commands that you should learn.

Repair Your Linux Filesystem:

The first thing you’re going to do is boot to the USB or DVD. You’ll need to be patient as the live instance loads into RAM. Once the OS has loaded to a GUI, you’ll want to select “Try Ubuntu”. (Remember to adjust that for your own distro, should you not be using Ubuntu.)

Again, this will take a minute – especially on older hardware. Eventually, the GUI will load and you’ll have a functional live instance running. If you needed to use nomodeset, acpi=off, or anything similar, you’ll probably also need to use those things to get the live instance of Linux running.

The tool we’re going to use is known as ‘fsck‘, which is a tool in and of itself and a front end for other tools. fsck interacts with more specific tools for your specific filesystem, but that’s not important right now. 

If you’re curious, fsck stands for ‘file system consistency check‘ and the man page helpfully describes it as:

fsck – check and repair a Linux filesystem

Now that you have a functional live desktop, it’s time to repair your Linux filesystem. The first step is, as is often the case, opening up your terminal. You can use your keyboard to do this, just press CTRL + ALT + T and a terminal should pop right up.

At this point, you’ll want to identify the correct disk. To do that, you run:

You’ll want to identify the disk where you installed Linux. That’s the disk that has the corrupted filesystem that is preventing you from booting. It’s often something like ‘/dev/sda1’ or maybe even ‘/dev/nvme0n1p1’.

Once you have the disk identified, it’s time to repair your Linux filesystem. Enter this:

NOTE: Change the /dev/sda* to match the data from the fdisk command you ran earlier.

That ‘fsck’ command should find and fix any errors automatically. If you really know what you’re doing, you can run ‘fsck’ manually and maybe do a better job than the automatic method. Then again, if you know that much then I’d suspect you don’t actually need this article.

This shouldn’t take very long to run, unless there were a whole lot of errors. Next, all you need to do is reboot and you should find that you were able to successfully repair your Linux filesystem. To do that from the terminal, you can just type:

When prompted, remove the disk from the drive and press the ENTER button.

Closure:

There you have it, another way to run fsck and to repair your Linux filesystem when it is broken. This method works even when the recovery mode will have worked.

Thanks for reading! If you want to help, you can buy some cheap hosting, unblock ads, donate, sign up for the newsletter (below), write an article, leave a comment, register to help, or just vote for the article below and leave a comment!

How To: Generate a List of Installed Applications in Linux

Before making this site, I had a similar article that explained how to list installed applications in Linux, but it was only relevant to those that used distros with ‘dpkg’. This expanded article will explain how to generate a list of installed applications for multiple distros, in order to be more complete.

There are any number of reasons why you might want a list like this. Maybe it’s for compliance reasons, needing to know everything installed on the machine. Maybe it’s for making a manifest to establish a baseline for future installs. You could also just be curious, need a list for support questions, or want a list for backup purposes.

Whatever your reason, you can generate a list of installed applications fairly easily. You can also do a couple of other neat things that I’ll explain below.

Generate a List of Installed Applications:

For all of these commands, you’ll want a terminal. You can probably open your default terminal by using your keyboard to press CTRL + ALT + T. If that doesn’t work, you can just open it from a menu or whatever shortcut you’ve set up for yourself. (I’m looking at you, you people with strange window managers!)

The command you’ll use will vary depending on your distro. I’ve got a few of them covered below. In some cases, you may need elevated permissions, so a ‘sudo’ in the front of the commands should do the trick for you.

Debian (& dpkg using distros):

If you’re using Ubuntu, or a distro with snaps, you can list those with:

If you’re using flatpak applications with any distro:

Arch (& Mandriva, etc.):

RHEL (& Fedora, etc.):

OpenSUSE (& derivatives):

Those are the major distros. There are smaller distros, independent distros, and they’ll have their own package management systems and ways to make a list of installed applications.

Bonus:

You can actually do a few things with this listing. Two immediately come to mind and I’ll share them.

First, you can count them. At the end of each of these commands, you can pipe it and count the lines. It may not be a 100% accurate number, but it will be pretty close. (Some of the commands output more than just a list of installed applications.)

That’ll give you an output similar to:

You can also write the list of installed applications to a text file, to save for archiving or whatever. I like to make a list now and then and check against it when I do a new installation. Your reasons are your own, but here’s how:

The .txt isn’t mandatory and you can write the file to anywhere you want, assuming you have the correct permissions. It’s your list, you can do anything you want with it!

Closure:

And, there you have it. You can now make a list of all applications that you’ve installed. You can even count the list, and you can write the list to a file for storage. If you want, you can generate a list of installed applications on one computer, generate a list of all applications on a second computer, and then use ‘diff’ to see what the differences between them are. There’s all sorts of things you can do with this list.

As always, thanks for reading. Your reading and feedback help me stay motivated. My goal is to keep up this publication rate for a year, though we’ll see where we are when that year ends. I have enough notes for that, and more. 

If you’d like to contribute, you can unblock ads, you can sign up for the newsletter, you can write an article, you can donate, and you can register for the site to regularly contribute. You can also comment, vote for articles you do like, and share this site/page with others via social media! You can even buy inexpensive Linux hosting! Alternatively, you can even just enjoy the articles. It’s all good!

What is my Hostname in Linux?

For most of you, your hostname in Linux is going to be the same as your username. This article will help you figure out your hostname in Linux, and it should be a relatively short article. If this article looks familiar, it’s because it existed at the old site, but with far less information.

Let’s start at the beginning, by learning what a hostname is.

A hostname is generally meant to be a human-readable way to identify a computer. Yes, the computer is truly identified by the associated IP address, but the hostname resolves to that computer. It is meant to be easily remembered instead of having to remember a bunch of IP addresses. Without it, the web (and your own local networks) would be more difficult to navagate.

In many instances, it’s a FQDN (Fully Qualified Domain Name), such as a domain name like linux-tips.us. However, this site doesn’t have a dedicated IP address, so it’s known by a virtual hostname as a FQDN. If the site had been constructed differently, you’d be able to access it with the IP address. For example, https://172.217.10.14 will take you to Google (after some warnings).

So, your hostname in Linux isn’t always going to be the same as your username. For most of the readers here on L-T.us, it will be. You probably don’t really need to worry a whole lot about things like virtual hosts and stuff like that. But, even as a home user, you can make use of this information.

How is it useful? Well, if I want to SSH into my MSI laptop, I don’t have to use the IP address. Not only that, if the IP address changes then I don’t need to look it up. I just connect with something like:

You may notice that I added the .local. You too can just add .local with many distros, in others the default might be something like .localdomain – which you can keep as the default or change it easily enough.

So, let’s figure out how to find your hostname in Linux.

Find your hostname:

Let’s start by cracking open the terminal. You can use your keyboard to do this, just press CTRL + ALT + T and your default terminal should open up.

Now, we can try the following:

Or you can try:

Or you can also try:

As near as I can tell, one of those should work on all major distros. If it none of them work for you, please leave a comment letting me know what does work – helping those who come behind you.

Using Your hostname in Linux:

There are a number of ways that this information can be used. With many distros, as mentioned above, you can add .local to the hostname and just use that instead of IP addresses. Here’s a picture that shows a few examples:

using hostname in Linux
Instead of using the IP address, use the hostname. It’s a pretty handy feature.

There are, of course, other things you can do with this information. Those are just a few examples. The great thing about using a hostname in Linux is that you’ll not have to recall IP addresses. You’ll only need to recall a name – a name that you picked.

You can change your hostname, but that goes beyond the scope of this article. I’d expect to see an article about that in the future! In the meantime, if you can think of any ways that you’d use the hostname, please leave a comment.

Closure:

Thank you, my dear reader, for your viewership. Your comments and feedback keep me motivated and your feedback helps to improve this site. For those who have been keeping track, you can actually now click on large images to see the larger versions. This will only be for future articles, as I’m unlikely to go back through every previous article and change it. But, it was direct feedback that resulted in the change.

If you’d like to contribute, there are a number of ways. You can donate, write an article, unblock ads, buy hosting, and sign up for the newsletter. I promise, I’ll never share your email address with anyone and I won’t send you any spam. Until next time…

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.