Let’s Root Around In The /proc Directory

Today, we’re going to root around in the /proc directory. Why? So we can learn about our Linux system. See, there’s quite a bit of information hidden in there and I’m going to show you how to get it out of there. You’ll have to root around for it, as I’m not going to document every possible combination, but you’ll have the tools to do so.

We will be using the terminal for this, but we’ll only be using a couple of tools. The first tool we’ll use is the ‘ls’ command. We’ve used it before to sort files by time and sort files by size and even to show hidden files and folders. So, as you can guess, it’s a pretty handy command.

The other application we’ll be using is ‘cat’. We’ve used that less often, but we’ve used it before, but here’s a brief overview of the ‘cat’ command. You might want to read that. But, basically, we use the cat command to read files in the terminal. 

The ‘cat’ command is also a pretty handy command. You can try it out yourself. If we assume you’re using bash and have history enabled (the vast majority of Linux users) you can do something like:

That command should spit out the history of commands you’ve typed into the terminal. Perhaps some of ’em will have been things you learned right here on Linux-Tips! Well, maybe… I mean, people tell me they learn stuff here, though I’m never quite sure how! 😉 Anyhow…

So, this will be a fairly informal article. It should also be quick and easy. You’re welcome!

Rooting Around In The /proc Directory:

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.

Like I said, this is a fairly informal article. Quick and easy, right? Well, I’m going to show you everything you need to know in one command. Ready?

You’ll see a whole lot of files. What you want to do is use ‘cat’ on those files. Like, if you want to read/check your CPU information, you’d use:

Do you want to see the information the system has for your memory?

Not all the files have useful data, but some of them do. That’s why you’ve gotta root around in there. You’ve gotta learn which files contain which information – but I’ve given you a head start with two of them. You’re on a path of discovery, ’cause I’m surely not going to go through all of ’em to tell you what they do. I give you the tools, you do the work. Or something like that…

Closure:

See? Nice and easy, and very much an informal article. You can now root around in the /proc directory to get some system information. You may need elevated permissions to read some files, and some of them contain what’s pure gibberish to me. They might make more sense to you!

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.

Smash a button!
[Total: 2 Average: 5]

How About A Brief Overview Of The Cat Command?

This is just a brief overview of the cat command. There are all sorts of ways to use the cat command, and I’m just going to cover some of the most common ways – the ways you’re most likely to use the command in day to day activities.

You’ll find ‘cat’ popping up in various tutorials and may find it being used for all sorts of things. As a command, it has existed since the earliest days of Unix (about 50 years ago, as of the time of this writing) and it gets used still today. If you check the man page, you’ll see that cat describes itself as:

cat – concatenate files and print on the standard output

But I find the Wikipedia description to be even better, at least more descriptive:

cat is a standard Unix utility that reads files sequentially, writing them to standard output.

If you’re curious, ‘concatenate’ just means linking stuff together in a chain or series – but ‘cat’ is more frequently used just to read the contents of a file by writing them to the standard output.

You can use this output in a number of ways, though this article aims to be just a fairly brief article, just an overview of the cat command. I haven’t written it yet, but i expect it to be reasonably brief!

An Overview Of The Cat Command:

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.

Next, I want you to run the following commands:

That just downloads a text file with some random numbers in it. It’s harmless. Now, let’s view it in the terminal:

If you don’t want to display all the results at once, just try piping it to the ‘less’ command. You can do that because cat handily outputs to the standard output. It’s just:

Alright, that was fun! Let’s try something nifty.

That will take the output of the cat command and add it to a document that you just created at the same time. So, if you want to see your handiwork, just try this command:

You’ll see the contents of ‘rnd-num.txt’ are now in the new file. If you use > it overwrites the contents of the file, but if you use >> it appends the content to the new file. To test that again, try this:

Now, if you cat the ‘new-file.txt’ you’ll see that it has twice as many lines as it did have. If you want to see it for certain, cat will helpfully add line numbers! Try this:

Then run (and it should show 100 lines):

Or, for even more fun, you can actually combine those (or just show the output from multiple files without the -n flag) with this:

Anyhow, those are a few examples as an overview of the cat command. Use the man cat command to learn more about it.

Closure:

And there’s another article! Thanks for reading! For a bonus, you can also use cat like touch and create a new file, like so:

When you use ls you’ll see the new file has been created called ‘example.txt’. Tada! Really, read the man page and learn all the wonderful things you can do with the cat command. This has been just a brief overview of the cat command, and there’s so many more nifty things that can be done.

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.

Smash a button!
[Total: 7 Average: 4.9]
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.
Zoom to top!