How To: Remove A PDF Password

This will be a straightforward task for anyone who would like to know how to remove a PDF password in the Linux terminal. If you deal with a lot of PDFs and want to remove the password, it’s a fairly easy task. Read this to learn more!

As mentioned before, PDF stands for Portable Document Format. This is a ratified ISO standard (ISO 32000) and is an open standard. You can see a bit about the PDF standard here on the ISO website. However, unless you have a subscription, they’ll want you to pay for this. I am not paying for this as I do not need to know the specifics.

Many people think that it’s proprietary because it comes from Adobe, but it’s an open standard and there’s a bunch of software available to manipulate and create PDF files. The standard has been open since 2008 which explains the myriad choices for editors.

Seeing as you’re here, you might as well read this interesting Wikipedia article:

History of PDF

PDFs can come with different levels of security. They can have passwords that lock the ability to edit the file and they can have passwords that you need just to open the PDF file.

This article assumes that you know the password! The exercise in this article only applies if you already know the password. I did write an article about cracking a PDF password, but that can take a long time.

How To: Crack A PDF Password

So then, which tools are we going to use?

poppler:

We’ll be installing a meta package known as poppler. This may come pre-installed on your system, or you may need to install poppler manually. We’ll go over installation instructions for a variety of distros, as it’s widely packaged and available in the various distro’s default repositories.

You’ll find that poppler is a meta package. That is, it contains other packages. In this case, poppler contains other applications that are used to manipulate PDF files. There’s no such thing as man poppler for example. It’s just the package name for a package that contains other packages. (That’s a meta-package.)

If you dig into it, you’ll find that poppler contains applications like pdffonts and pdfimages. At this point, we’ve previously covered pdftotext. This time around, we’ll be using pdftops. We’ve not yet used this tool in other articles, so now is as good a time as any to learn about it.

pdftops:

This pdftop application is mostly intended to turn PDF files into PS (PostScript) files but has other uses. Sort of like how a medication can be prescribed off-label, so too can you use this tool for other things. This time around, we’ll be using the pdftops to remove a PDF password.

If you had poppler installed already and checked the man page, you’d see something that should be close to this:

pdftops – Portable Document Format (PDF) to PostScript converter (version 3.03)

We’ll be skipping that whole bit about converting it to a file formatted for PostScript. That’s not necessary for our goal – removing a password from a PDF-formatted document.

But, this tool contains the necessary commands to remove a PDF password. If the file has multiple passwords it will remove the password specified. Your best bet is to remove the password that enables editing. This will also unlock the PDF for viewing purposes.

Remove A PDF Password:

If you want to remove a PDF password, you can use a GUI tool and then choose the ‘export’ option – or maybe the ‘save as’ option. In our case, and as mentioned above, we’ll be using the terminal to remove a PDF password. If you don’t know how to open a terminal, that’s usually accomplished by finding the application in your menu or by pressing CTRL + ALT + T on your keyboard.

With your terminal now open, we need to install the poppler meta package. I’ll include the commands as I understand them but you may need to doublecheck my work. Depending on your package manager, try the following:

Debian/Ubuntu/etc:

RHEL/CentOS/etc:

OpenSUSE/SUSE/etc:

Gentoo:

Arch/Manjaro/etc:

One of those should work with all the major distros out there. If you’re using an obscure distro with an obscure package manager, the poppler utilities should be available to you. You’ll just need to edit your installation command to match your package manager.

Also, if you do need to do that, please let me know. If you let me know, I can include the command in the article, thereby making the article more useful to more people. One of my primary goals is to be useful. It’s good to be useful to more people.

On to the meat of the article:

Removing A PDF Password:

As you’ve already got your terminal open, you might as well keep that terminal open. The application we’re using is pdftops and you can use the following command to ensure that pdftops is properly installed:

The output should look similar to this:

While you’re there, you can check the man page. There are many options available for the pdftops command and you can check them with this command:

Now that we’ve checked the man page, we’re looking for the -upw flag. That’s the flag that’s going to do the heavy lifting and the man page describes it like so:

Specify the user password for the PDF file.

So, you can see where this is going…

The syntax is quite simple. It will look like this:

If you want to specify the owner password, you use the -opw flag. You can pick which password it is that you’re using and the output file will not have that password. Specifying this flag will remove all restrictions, of course.

Let’s try to give you an example…

I wrote an article about how to crack a PDF password and I included a link. For the sake of clarity, you can now download that PDF file.

Example PDF File

The password for that file is ‘abab’ and not one of you took the time to crack it. I made it nice and simple for you, but not one of you took the time to crack the password.

Still, we can use that in our example:

Rather than converting to PostScript, we are just opening and unlocking the file. At that point, we’re redirecting that unlocked content to a new PDF file. In the process, we’re stripping the existing password, meaning you can easily access the file in the future – even if you’ve long since forgotten the password.

Closure:

I’m not sure how often you work with PDF files, but this might be something you can use. You don’t need to remember complex passwords unless you want to. Very few people are interested in maintaining a mental list of all the passwords they use.

It’s not like there’s a password manager for PDF files (as far as I know). You’re stuck referencing the original place the password was shared or keeping some sort of list. Well, you do have another choice. You can learn how to remove a PDF password in the Linux terminal and be done with it. It’s up to you.

Anyhow, I figured this would make a good article. I don’t mention PDFs often and don’t write many articles on the PDF subject. There have been a few of them but there’s always more to cover. Today we just covered how to remove a PDF password. Maybe we’ll cover something else in the next article – but I’m more likely to skip a few articles so that it’s not just PDF content for a week.

Thanks for reading! If you want to help, or if the site has helped you, you can donateregister to helpwrite 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.

Seeing as you’re here, why not visit our friends at Blunix?

Here’s why you might just want to visit Blunix:

“Blunix GmbH offers Debian and Ubuntu focussed Linux Emergency Support 24/7, Project-based Linux Consulting, FOSS-based Managed Hosting on your company IaaS provider account as well as custom Training and Workshops. We prioritize fair business partnerships and employee quality of life over profit. We focus on reasonable security by default and encourage your employees and developers to keep things secure enough to avoid 99% of security issues with automated attack vectors. We focus exclusively on this and do partner with other companies to refer customers that do not fit exactly what we do, or where we require additional help (for example we have a security-focused company that we partner with for higher risk factor hosting setups).”

Click to visit Blunix GmbH

Another Way To View Attached Storage Devices

Linux offers myriad ways to accomplish the same task, which is a good thing, and this is another way to view attached storage devices. This is a useful way to learn more about your storage devices and is a bit more advanced than others.

There are many ways to view attached storage devices. While not the same, you can learn which storage devices are attached to your system with any of the following articles:

Show Your Filesystem In The Linux Terminal
Show Mounted Partitions
How To: List Mounted Partitions
Yet Another Way To Check Filesystem Space Use

Stuff like that…

Well, you can also just plain old view attached storage devices in the Linux terminal. The application I’ll be showing you will do more than this, but we’ll concentrate on just showing attached storage devices.

The tool we’ll be using is known as:

lsscsi:

Yes, we’ll be making use of the lsscsi application for this article. This won’t take very long and you should find that lsscsi is available for pretty much every operating system out there. It does what you’d think, list SCSI devices.

Once installed, you could check the man page to see that this is the correct tool if your goal is to view attached storage devices. The man page describes the lsscsi application like this:

lsscsi – list SCSI devices (or hosts), list NVMe devices

It’s a simple application, at least for our needs. You’ll find that you can get some of the same information with the following command:

However, that command won’t give you things like the path. Mounted storage devices tend to have a path of something like /dev/<path>, and that information isn’t available with the cat command listed above. As we often want to know the path information, and there are many tools to do this, you might as well learn about lsscsi. 

By the way, your GUI disk manager (such as gnome-disks) will happily give you some of this information. It’s also a graphical environment, which may be easier for some folks. This is for those needing that information while using the terminal, or for those who are just interested in doing more in the terminal.

But, when it comes to disk and data management, you may need to know this information – especially the paths. So, this is a good command to have in your pocket. You never know when it will come in handy.

View Attached Storage Devices:

If you’re unfamiliar with the lsscsi application, it’s a terminal-based application. If you’re already familiar with the lsscsi application, I’m not sure why you’re still reading the article! Either way now is the time when you open a terminal. Oftentimes, you can open a terminal by just using your keyboard. Try pressing CTRL + ALT + T and your default terminal should open.

With your terminal now open, it’s time to install lsscsi. The directions to do so will depend on your package manager, but I’m going to cover most of them because this application is widely available and packaged for almost anything you can think of.

Installing lsscsi:

With your terminal open, use the correct command for your package manager:

Debian/Ubuntu/etc:

RHEL/CentOS/etc:

Gentoo:

OpenSUSE/SUSE/etc:

Arch/Manjaro/etc:

One of those should work for most of you. If not, let me know in the comments and I’ll amend the application. If they’re wrong, please do let me know in the comments. I did not test all of these. I’m going with a combination of my notes and what I’m able to scrape from the internet.

Using lsscsi:

With that open terminal, just enter the name of the command and you have about all the use you’ll really need from the application. The command is simply:

If you want, there’s more to the application – which you might need for some advanced operations. You can just check the man page with this command:

Here’s an example output:

Here’s another example output:

If you look at the bottom one, there’s a bit of an Easter Egg. You’ll see that it starts with an N and that means it’s an NVMe device. You don’t need any special tools beyond lsscsi to view NVMe devices, which is nice. The program happily recognizes it and other attached storage devices.

Closure:

You never know when you’re going to want to view attached storage devices. However, the odds are good that you’ll eventually want to know this information. It’s always good to verify the path of a dd command, for example. A malformed command can really cause you some problems.

So, now you know how to view attached storage devices – a task that has many solutions in Linux. There’s nothing wrong with variety and each of the various tools will have different strengths. Knowing what to use and when to use it is something you’ll learn as you make progress.

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.

Turn PDF Into Text

Today’s exercise is simple, though it will rely on the terminal because we’re just going to turn PDF into text. This isn’t something complicated and it’s fairly effective. It’s also an exercise anyone can follow along with. So, if you want to turn PDF into text, read this article!

I’m sure this works in multiple distros, but I only have instructions for a few in my notes. Most everyone should be able to follow along with this article and turn PDF into text. You’ll see…

While I’m sure everyone is familiar with PDF, I’ll explain…

PDF stands for Portable Document Format and is one of many standards for documents. Specifically, it’s ISO 32000 and is a file format brought to use by Adobe. Adobe is a proprietary product but the standard is open, meaning you have your choice of PDF readers, editors, and creators.

On the other hand, PDF may not be as easily parsed as other file formats. You may also just want to extract some text from a PDF or turn it into something more information-dense, sans pictures and fluffy formatting. There are any number of reasons why you might want to turn PDF to text and it’s a simple operation that’s going to give you ‘acceptable’ results most of the time.

The tool we’ll be using…

pdftotext:

We’ll use a tool known as ‘pdftotext’ which does as its name implies. It’s a tool that lets you turn PDF into text, so from .pdf to .txt is the goal. Like many Linux tools, this is a terminal-based operation.

You can check to see if pdftotext is already installed with this command:

If the output matches this, you can skip the installation step:

If you want, you can check the man page and see that it is indeed the correct tool for the job if your job is to turn PDF into text. That’s this command:

That command will show you that the description is indeed what we want to accomplish in today’s article. That description is basically:

pdftotext – Portable Document Format (PDF) to text converter

(It may also tell you the version in that section, which is odd but is what it is.)

So, you can see that pdftotext is the correct tool for the job when you want to…

Turn PDF Into Text:

As I mentioned in the intro, if you want to turn PDF into text one of the ways to do so will require using the terminal. There are all sorts of GUI tools you can use to do this very same job, but we’ll do this in the terminal. So, you can usually get away with pressing CTRL + ALT + T to open your default terminal emulator. Otherwise, check your application menu and you’ll find a terminal option in there.

With your terminal open, we first will install a meta package so that we can use pdftotext to turn PDF into text. That application is ‘poppler’. You can pick from the following to match your package manager to install this.

Debian/Ubuntu/etc:

Arch/Manjaro/etc:

RHEL/Fedora/etc:

The poppler package contains pdftotext which is the tool we’re after in our quest to turn PDF into text. It’s a noble quest!

Now, the syntax is quite simple:

That will create a <file_name>.txt file in the same directory.

Now, if you checked the man page above, you’d see that there’s not a whole lot to this application. You can largely ignore all the options (and we will), though there aren’t that many.

The two options we are most interested in would be about just converting single pages into text. For that, you want the -f (first page) and -l last page flags. They do exactly what you’d expect and the syntax is as follows:

I’ll give you an example…

Let’s say you want to print pages 1 through 3. The syntax would be:

Sometimes this whole pdftotext thing doesn’t do a great job. If the PDF file is formatted in a fancy manner, it may just not come out in text all that well. Fortunately, PDF is an open standard and you can help it along with the -layout flag. 

The -layout flag is described like this:

Maintain (as best as possible) the original physical layout of the text. The default is to ´undo’ physical layout (columns, hyphenation, etc.) and output the text in reading order.

So, that flag will do its best to turn the layout into what it was in the original PDF. This is a handy flag for when the output isn’t usable. It’s possible to retain columns, advanced formatting, and all of that stuff, meaning the text file output is more useful. You won’t always need this option, but it can come in handy. You can safely ignore the remainder of the man page for the vast majority of what folks are going to do with this command.

That’s pretty much all you need to know about the pdftotext application. It does what you think it’d do. It’s the tool you use to turn PDF into text, just like it says on the tin! Pretty handy!

Closure:

So, that’s an article… 

If you’ve ever wanted to turn PDF into text, you now know how. You can use this to make a PDF easier to parse, easier to read, etc. It’s up to you how you use pdftotext. You now have the knowledge! You now have the power! Indeed, you have life by the horns. (Which is a rather silly place to grab onto.)

Man, this is a lot of articles… At this point, it’s almost habitual. Technically, I have published something every other day – for a long time. A couple of those articles weren’t really articles. They were placeholders because Mother Nature is a fickle beast and I live in a very remote location. We had a few major (deadly even) storms that took out our infrastructure. I think I can be forgiven for that – and I did upload articles saying that there’d be no article. 

The site has come a long way…

I haven’t done a meta article in a while…

Seriously, without you (my readers) I’d have never kept going this long. It’s obviously not a money-making operation, but it is an educational operation. That’s more important than money.

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.

Show USB Devices In A GUI In Lubuntu

Today’s article will be easy to follow and is for those who’d like to show USB devices in a GUI in Lubuntu. Though truth be told, this is applicable for other distros. I’ve just tested it on Lubuntu and Linux Mint.

I want to assume that all my readers are familiar with USB. There are all sorts of things that can use USB, which stands for Universal Serial Bus. You can plug in USB storage, fans, power devices, and (with USB C) even connect external monitors or graphics cards. The standard has existed since 1998 and the most recent version is USB4. It has come a long way.

Linux is pretty good at enumerating USB devices and can use many of the various USB-powered tools. It’s possible to show the USB devices in the terminal, of course. I just figured I’d cover a way to do so graphically. You never know who wants to show USB devices in a GUI, so why not cover it in an article?

I’ve covered ways to show USB devices before. I’ve done so multiple times, so it seems. Click one of the links below to view another article.

Show Your USB Devices In The Linux Terminal
A Little About The ‘lsusb’ Command.
How To: List USB Devices

As this article is for Lubuntu, I’ll give directions as though you’re using Lubuntu. This is going to work on any Debian/Ubuntu-based operating system. The tool we’ll be using is also available for Arch and, I assume, other package managers.

So, what will we be using?

usbview:

We’ll be using a small application known as usbview. This is available in your default repositories and is easy to install. I’ll cover the installation methods below.

If one were to check the man page, you’d see it’s the right tool for the job.

usbview – display information on USB devices

Further, you can see this on the man page:

No command line options are accepted by usbview.

So, usbview a graphical (GUI) tool. There are no options for the terminal – but you’ll need to start it from a terminal. For reasons beyond my knowledge, there’s no application menu added when you install usbview. That’s something to keep in mind. It’s a GUI tool – but you start it from the terminal. Got it? Good!

Show USB Devices In A GUI In Lubuntu:

As mentioned above, you’re going to need an open terminal. As you’re using Lubuntu, you can just press CTRL + ALT + T and your default terminal should open.

With your terminal open, you first install usbview…

That’s nice and simple.

Now, you can run usbview with this command:

Yes, you need elevated permissions. It throws an error otherwise.

You’ll get a new window that looks something like this:

using usbview to show usb devices
This is pretty self-explanatory, though I don’t have much plugged in.

You can not only view USB devices, you can learn more about them. There’s not much to configure and you can ignore all the buttons except the Quit button. You’ll want that to quit the application.

But, there you go… That’s how you show USB devices in a GUI in Lubuntu!

Closure:

Anyhow, now you’ve learned how to show USB devices in a GUI in Lubuntu. This is a good thing and something you can trivially apply to other distros. I’m sure there’s a way to build usbview if you don’t already have usbview in your repositories. If graphically viewing USB devices is your goal, usbview is a possible solution.

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.

Seeing as you’re here, why not visit our friends at Blunix?

Here’s why you might just want to visit Blunix:

“Blunix GmbH offers Debian and Ubuntu focussed Linux Emergency Support 24/7, Project-based Linux Consulting, FOSS-based Managed Hosting on your company IaaS provider account as well as custom Training and Workshops. We prioritize fair business partnerships and employee quality of life over profit. We focus on reasonable security by default and encourage your employees and developers to keep things secure enough to avoid 99% of security issues with automated attack vectors. We focus exclusively on this and do partner with other companies to refer customers that do not fit exactly what we do, or where we require additional help (for example we have a security-focused company that we partner with for higher risk factor hosting setups).”

Click to visit Blunix GmbH

Save A Web Page As Text

If you’re at all like me, you document all sorts of things and you too might find it handy to know how to save a web page as text. It’s not a complicated task; you can do it in the terminal easily enough. So, if you want to save a web page as text, read on! 

This intro should be rather short. Imagine that!

I don’t have to explain what a web page is. It’s a page (just a page) on a website.

I don’t have to explain what text means. We’ll just be using .txt files.

While this isn’t something I’ve bothered with in a long time, you might find it interesting and helpful. If you’re into keeping notes of things you want to learn more about and remember, you may find saving a web page as text worthwhile.

You can organize the text files however you want and one of the best benefits is that you can perform searches on your local documents easily enough. This might be something that interests you, especially if you’re new and browsing around the web looking for things to learn.

We’ll only be using a couple of tools. We will be using the terminal.

curl:

The first application you’ll need to save a web page as a text file will be the curl application. The curl application is used to transfer a URL. A curl command downloads a file and shows it in your standard output.

If you check the man page, you’ll see:

curl – transfer a URL

See? Exactly as I had said. It’s the correct tool for the job. 

You can also see this article about curl:

Let’s Have a Limited Look at Linux’s cURL Application

html2text:

This should be obvious by the title. It should be made further obvious by the title of this article. This is an application that turns HTML (Hypertext Markup Language – what is used on web pages more often than not) into plain text.

If you check the man page, you’ll see:

html2text – an advanced HTML-to-text converter

Once again, a fine application for the task at hand. You’ll see!

Save A Web Page As Text:

As mentioned above, this is a terminal-based operation. We’re going to save a web page as text, but we’re going to do it in the Linux terminal. More often than not, a terminal can be opened by pressing CTRL + ALT + T on your keyboard.

I’ll give installation instructions for the apt-using distros out there. These packages will be available in your package manager if you’re using any of the major distros. Just adjust these commands to match your needs.

curl:
html2text:

We’re interested only in the -o (output) flag for this application of html2text.

The Process:

The syntax to save a web page as text is simple. It looks like this:

Simply, we’re using the curl application to grab the data, we then send that data through the pipe command where it’s processed by the html2text application.

An example would look like this:

You can, of course, save individual pages as text. Here’s an example:

The terminal output is interesting:

Then, you can use a plain text editor to read (and edit) the text file. You can view it in the terminal with just the cat command. That’d look like this:

Though, it’s probably easier to read the saved file with a decent plain text editor that has a GUI. There’s an abundance of text editors available for Linux, so pick your favorite and use that to read the saved output.

Closure:

Well, if you have ever wanted to save a web page as text, you now know how to do that. This was an article that came not from my notes but from my memory. I used to do this with some regularity but I’ve stopped doing so as of late. I haven’t kept so many new notes lately, though I’m not sure why not.

Anyhow, this is a nice and simple exercise that anyone should be able to follow. If you’re using a different package manager it may take a bit more effort, but it’s not complicated. The packages should be available in all the major distros, or something similar. The curl application will certainly be available and might even be installed by default.

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.