Short: Show File Creation, Modification, and Access Times

Today’s article is short because there’s no reason to make it longer and we’ll just show file creation, modification, and access times. This is just a simple process and won’t take all that much to learn. It shouldn’t take too long to explain.

Files contain metadata. This can be everything from the GPS location of an image file to the kind of camera used. You can even add your metadata fields with audio files, for example.

For example, we’ve previously covered metadata in these articles:

How To: Sanitize Exif Data From Your Digital Images For Privacy Sake
Review: MetaClean (Clean Exif/meta Data From Email Attachments Automatically)

Well, your files contain other metadata. This information includes things like file creation, modification, and access times. You can easily find out when a file was created. It’s easy to show when the file was modified and just as easy to see when the file was last accessed.

Nice and simple, right?

Well, we’ll be using the stat command.

The stat Command:

You won’t need to install anything. You’ll find that the stat application is already available. You can verify this with:

The outcome should match:

You can check the man page with this command:

Doing so will show you that stat is described like:

Which is exactly what we need to show creation, modification, and access times. This will be the correct tool for the job.

Show File Creation, Modification, and Access Times:

This is a terminal-based process and you can usually access your default terminal by pressing CTRL + ALT + T. If that doesn’t work, find the terminal in your application menu.

With your terminal open, list the files:

Now, pick a file…

When you’ve picked a file, use the stat command. The syntax is easy:

When you opened your default terminal, you probably opened it in your home directory. Most of you will have a ~/.bashrc  file, so we’ll use that. An example of this stat command would be:

Here’s an example output:

As you can see, there’s the ‘birth’ (file creation time), an access time, and a changed time. There’s a lot of other information, but that’s outside the scope of this article.

Be sure to read the man page:

You can use several flags to extract just the information you want. If you wanted to, this would be useful for scripting or other programming. You don’t have to have the full output. For this simple and short article, the information isn’t that overwhelming. I see no reason to cover any particular flags unless I intended to cover a half dozen of them. You can find those just fine on your own.

Closure:

This has just been a short article. I wanted to cover the stat command and there’s not much to it – for the average user. File management is a pretty advanced topic and we cover that often. This time around, it’s just file creation, modification, and access times. Nothing too advanced.

I don’t do many of these short articles. I probably should, as they’re quick and get straight to the point. They’re quick articles that should be plenty easy to process and you don’t have to wade through a lot of text to get to the point of the article. If you like them, let me know.

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 Your USB Devices In The Linux Terminal

Today’s article won’t be all that long or complicated because we’re just going to show your USB devices in the Linux terminal. This is something easily done and not something too unusual. You never know when you’ll want to show your USB devices, but this is your chance to do so.

We have covered the lsusb command in the past, but we’ll include that and go beyond that. Why? Because we can. It’s okay to revisit earlier material if we’re going to add to it.

USB stands for Universal Serial Bus and there are many versions. I’d like to think that my readers don’t need to be told what USB is. You’ve probably used USB devices in the past, including using a USB storage device to install Linux or use as an input device like your keyboard and mouse. 

Not having to explain that will save a lot of time!

Show Your USB Devices:

You can learn quite a bit about your USB devices in the terminal. You can learn what the devices are, maybe the product name, where it’s plugged in, and more. So, we’ll cover that in this article.

The two tools we’re going to use shouldn’t require any new software. Sweet!

lsusb:

The first tool we’ll cover is the lsusb application. You won’t need to install this. It will be installed by default. You can confirm that you have lsusb installed with the following command:

Sure enough, you can check the man page to see that this is a good tool for this task. That command is:

With that information, you can see that it’s described like this:

lsusb – list USB devices

See? It’s exactly the tool for the job!

To run this command, you simply run it in your terminal – like so:

That will output a bunch of USB information.

usb-devices:

Now this is a command that I’ve not previously covered. It’s a simple command to operate but the output is different from the above. This command gives a great deal more information than the above lsusb command does. 

You can ensure that usb-devices is installed with this command:

If you want to check the man page, run this command:

You’ll see that this is a useful tool if you want to show USB devices. In fact, you’ll see that it’s possibly better than the plain lsusb command. It’s described like:

usb-devices – print USB device details

The important part is ‘details’. This command will show you a great deal of the details regarding the USB devices.

NOTE: This will only show the details for things that are active. If you have inactive USB devices it will not show them. That explains the difference between the lsusb command and the usb-devices command. Well, that and this command spits out a lot more information.

If you want to run this command in your terminal, it’s simply done like so:

That’s not very complicated at all and will reveal quite a bit more information than you’d get with the previous lsusb command. It’s worth running both in some situations, but run this usb-devices command if you need detailed information.

Closure:

See? I told you that this one wouldn’t take all that long. I probably could have labeled this one as a short article, but I didn’t. It’s also written in a different format – not even telling you how to open your terminal. If you need to know that, you can figure it out – or you already know. I did mention the terminal in the headline.

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.

Generate A Process Tree

This shouldn’t be a very long (or complicated) article as we’re simply going to cover one way to generate a process tree. This is more useful than it may sound, especially in process management.

We’ll be doing this in distros that support apt. So, that’d be distros like Debian, Ubuntu, Linux Mint, Elementary, and many others. That’s distros within the Debian family. That’s a good chunk of the available distros, so this will apply to many of you.

It’s not that this won’t work on other distros. It’s that I haven’t tested this on other distros. You can likely follow along and figure it out with your package manager, I’ve just not done so. I do have a limited amount of time and the only human resource I have is myself. Man, I could use an editor!

For the record, this seems like something you’ll find installed by default on any major system. You may not need to install anything at all. This might just be already available.

Anyhow… About processes…

Everything running on Linux is a process. There are a whole lot of processes that make up a running system. For the most part, you can ignore all this and keep computing. However, when you troubleshoot a system you may be interested in which processes are running. If you’re recovering from a slow system, you may be interested in killing processes.

One process may spawn other processes. For example, you may have a browser with open tabs. The browser is itself one process. The open tabs may be separate processes. This is a good thing for things like compartmentalization and even security, but that’s outside of the scope of this article.

So, what tools will we be using?

psmisc:

I believe the correct term for psmisc is that it’s a meta-package. That is, psmisc is a package that contains some other tools. If you want to follow along with this article, that’s the package you’ll likely want to install. I’ll cover installing it with apt, which is nice.

If you’re interested in psmisc, here’s the psmisc project page. The package includes the following applications:

  • fuser – Identifies processes using files or sockets
  • killall – kills processes by name, e.g. killall -HUP named
  • prtstat – prints statistics of a process
  • pslog – prints log path(s) of a process
  • pstree – shows the currently running processes as a tree
  • peekfd – shows the data travelling [sic] over a file descriptor

Of these, we’re interested in ‘pstree’. We have mentioned the killall command before and chances are that you won’t need to install anything for this at all. I did mention that above…

pstree:

This is the tool we’ll be using to generate a process tree. It comes with the above package and is one of those tools I think is likely available by default. I’ll cover how to use apt to install it below, but it seems like one of those things that you’re going to find on other distros. You’ll likely find that it’s installed by default on all those distros.

You can verify that you have this available with the following command:

The output should match this:

Don’t worry if that’s not available, we’ll install it below.

If you want to generate a process tree, you’ll see that the man page confirms that this is a good tool to do so, though the name should have clued you in. To read the man page, just run this command:

See? It’s not all that involved. It’s a pretty simple application.

Generate A Process Tree:

To generate a process tree in Linux, you’ll need an open terminal. Well, if you’re going to use pstree to generate a process tree in Linux, you will need an open terminal. Most of you can just open a terminal by pressing CTRL + ALT + T on your keyboard.

With your terminal open, let’s make sure that you have installed psmisc.

Now that you have psmisc installed, you can use the pstree command. Don’t blame me for this, I didn’t do it. 

You can simply run the command as it stands:

However, I previously wrote this article:

How To: Kill Processes By Their PID (Process ID)

I want to tie into that article. You can use the pstree command, which is a nice and easily understood output, to show the PID. That command would look like this command:

However, there’s a more useful command for those dealing with sudden issues. You can use a flag known as --color=age to get an idea about how new the processes are.

Green would be within the past 60 seconds, yellow would be within the past hour – or so I’m told. Every time I try, it shows up red. You can try it if you want, like so:

Good luck with that one! Seriously… Good luck!

Even if that doesn’t work, you can now generate a process tree to show the running processes on your system. This seems like a good thing to know.

Closure:

I was recently asked if I was running out of ideas for articles and the answer I gave them was that I am not. There’s always something to write about, even if it’s just a simple task like generating a process tree. Ideally, these articles will stand as a solution for those with specific problems. This is one of those articles.

Don’t forget that you can sponsor an article!

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.

Monitor Wireless Link Quality

If you’ve ever had issues with your wireless connection, and many of us have, you might have wanted to monitor wireless link quality. This is a good task for an article, so let’s learn together one way to monitor wireless link quality. This will be a pretty easy article to follow.

You need a wireless adapter and wireless connection to follow along with this article. It’s not complicated, but you will need those things. Even if you don’t use wireless often, you might want to learn how to monitor the link’s quality – just in case you’re put in a position where you’re using wireless. It’s better to be prepared!

Wireless connectivity issues have plagued many people. Some of those people will jump to it being a hardware problem, like a driver acting up. They’ll try all sorts of things before checking the link quality. I’d suggest checking link quality early on in the troubleshooting process.

If you don’t know, wireless signal strength is measured in decibel milliwatts (dBm). They’re measured between 0 and -100 dBm. In this case, higher is better. -30 is perfect and -90 is disconnected. In simple terms, -30 is closer to 0. I don’t have a great connection, but it’s adequate. 

We won’t need to install any tools for this exercise. You have everything you need already installed and enabled, or you should. These are fairly basic low-level commands. They’ll be a part of any major distro for regular desktop use.

So, what will we be using?

The watch command:

The watch command is used with other applications, allowing you to monitor the process and to get continually updated information from that command. For example, the following command will watch your memory usage:

If you check the man page (with man watch), you’ll see that this is the correct tool for the job. You’ll also see that it’s not that difficult to learn how to use the watch command.

I’ve not yet written a watch article, but it’s pretty basic. In this case, we’ll introduce the -n flag but that’s just an indicator of frequency. You could simply use the watch command without any flag and it’ll refresh every two seconds. So, there’s that.

If you want to verify that watch is installed before going further, just run this:

The output should match this:

Which is where these sorts of things belong.

By the way, I’ve covered the which command before:

Find A Command’s Binary

You could also use the ‘whereis’ command.

Another Way To Find The Binary For A Specific Command

See? Lots of information is available. 

The cat Command:

We’ll also be using the cat command. The cat command is used to show the text in a file. When used in conjunction with the watch command, you can monitor a file to see if it changes. That’s exactly what we’ll be doing in this article.

Once again, you can check the man page ( man cat) for more information, but doing so will show you that the cat command is described as such:

cat – concatenate files and print on the standard output

The cat command is also useful for linking things together, such as the content from multiple files. We’re just concerned with the standard output (that’s what shows up in your terminal) and printing to said standard output. 

You can verify that cat is installed with:

Of course, the output is:

You can also read:

A Quick Look At The Cat Command

It’s not something you should have to install. Any desktop (or server) is going to include these two commands by default. They’re considered basic building blocks of a POSIX-compliant system. That’s something we all want!

Those are the only two tools you’ll need if you want to …

Monitor Wireless Link Quality:

If the commands mentioned in the intro section weren’t enough of a clue, this is one of those things you do in the terminal. That’s also something your distro came equipped with. Most folks should be able to open their default terminal emulator by pressing CTRL + ALT + T.

With your terminal open, you can check the current status of your wireless connection’s link quality. You simply need to run the following command:

That output is just for a single snapshot in time. If you’re having connectivity issues, you may want to monitor the state of your wireless connection over time. That’s why we use the watch command.

In its basic form, a command to monitor wireless link quality would look like:

That will run the cat /proc/net/wireless command every two seconds and output the results to your terminal (that is standard output). That’s all you need.

Of course, you can change that watch command a bit to change the frequency. You can make it more or less frequent, but the syntax is simple.

A reasonable interval might be every 10 seconds. That looks like this:

Every ten seconds, your system will run the command and output the results to the terminal you used to run said command. It’s quite basic, I’d think. 

While you probably don’t want to do so for this command, you could use decimal values. If you wanted the command to run 5 times every second, your input would be:

Here’s an example of that command. Yes, I made you a video!

The quality of the link is as a percentage. No, I do not know why. If you know why, leave a comment. The noise is measured according to dBm. If you’ve ever heard the expression ‘signal to noise ratio’ this is a good example of this. You want more signal and less noise, so you want a higher signal-to-noise ratio – which is something people often get backward when used conversationally.

This just shows you something you can do with just two basic Linux commands. That’s just two commands that you have installed already and you can use them to monitor wireless link quality. There’s nothing fancy here. There’s nothing advanced here. You can perform this sort of troubleshooting without any additional applications being installed – and you probably should do so if you’re having wireless connectivity issues.

Oh, before I forget, you can exit the watch command by pressing CTRL + C. That’s about all you’ll really need to know.

Closure:

One of the reasons why I wrote this article was because I wanted to show something that looks advanced but isn’t. This isn’t something that requires much. You only need the tools you have installed already. These tools are going to be available on any Linux desktop (and server) you are likely to touch. 

It also seems like a good idea to share how you can monitor wireless link quality in the Linux terminal. It’s something everyone can do and it’s something you can remember easily enough. If you’re having wireless issues, check to ensure that you have a good signal. It’s as basic as checking to make sure the power cord is plugged in and the device is turned on.

Don’t forget that you can sponsor an article. LOL You can do this even without something to promote. It’d pretty much be a donation, but you’d get a cool message and a link to almost anything you want. (If it’s just a donation and a personal thing, you can do so for much cheaper than the listed price.) I’m hoping to turn this sponsorship thing into a thing, meaning no more of the ads folks are used to and block.

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.