Let’s Take A Look At Logged In Users

Today is a good day to learn how to take a look at logged in users. The vast majority of my readers are desktop users, so you can mostly skip this article. On the other hand, when you take a look at logged in users, you might find users you didn’t know were logged in and discover a problem like unknown users.

Yeah, most of you – including me at the moment (which makes it difficult to do things like take useful screenshots) are using Linux (mostly) as a single user. You have a user and you login to that user account when you start your system up.

While you do have other system-configured users, you don’t generally login as those users. As such, you probably spend very little time thinking about the users you have. Those system users aren’t generally logged in but are there for permissions purposes, so they’re out of mind for most of us.

Well, for the rest of you, you can use this article to learn how look logged in users – even getting a glimpse at what they’re doing. I mentioned some difficulty in taking screenshots, so I’ll provide you with just one. Cherish it, as it’s the only one you’re getting!

Here it is:

looking at other users
See? I’ll reference some of this below, in the article itself. I might as well…

Have A Look At Logged In Users:

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.

As you can see from the image above you can see all the logged in users with the first command. The following command will list them:

You’ll see the same thing, with a bit more information, when you use the following command:

Now, in the image above, you can see where I used it once and then ran it again. What you don’t see is that, in between those two commands, I opened up another TTY and logged in again as ‘kgiii’. If you want to replicate that, just press CTRL + ALT, then F3 to F6, and login at the prompt with any user(s) you happen to have.

Finally, you can get a look at what they’re doing – like one has a desktop session open and two of those login instances just have bash sessions open in TTY sessions. To do that,  you just use:

That should be easy enough for you to remember! By the way, if you did login as an additional TTY instance, run ‘users‘ again and you’ll see the output for that command has changed accordingly. The command’s output will may also give you a good idea about how long the system has been up and what the system resources are like.

Closure:

There you have it. You have learned how to have a look at logged in users so that you can have an idea of what’s going on with your system. If you spot a user you don’t recognize, that might be indicative of a problem. If you spot a user you don’t recognize, you’ll need to do some more investigating. By the way, if you have ‘finger’ installed you can always run ‘finger <username>‘.

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.

A Few Ways To Count CPU Processors Or Cores

So, in today’s article we’re going to learn a few ways to count CPU processors or cores. This is something you might already know about the system in front of you, but may want to verify with a remote system.

To the Linux system, there’s little difference between an individual processor or a core, or even a thread. Each core will appear as its own processor – and that’s exactly how it should be. Linux will treat each as its own processor and do its best to take advantage of multi-core/multi-CPU systems.

Now… Hmm… I shouldn’t need to explain this, but your computer has a processor called a CPU. It may have more than one, though that’s unlikely in a personal computer. Instead, your CPU may have multiple processors on it – each functioning more or less independently as ‘cores’. Additionally, your CPU cores may have multiple threads and each of those threads will appear as its own CPU.

That’s a very simplistic overview and I have to do things like limit how many characters are in the title of the article – and I don’t really want to try to explain everything. 

For example, you could have a 4 core CPU that’s dual threaded. 4 x 2 = 8, so your system will see 8 CPUs. There’s only one physical processor, but you’re effectively working with 8 of them. (By the way, you can *sometimes* compile software optimized by the number of cores available.)

Count CPU Processors Or Cores:

(or threads, I suppose)

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.

Now, there are so many ways that you can count the CPU processors or cores. We’re just going to cover a few of them. Feel free to leave other solutions as a comment. I’ll approve the comments as quickly as I can.

Solution #1

We just recently used the ‘cpuinfo‘ file to learn about your CPU. So, we’ll start with that one first. We’ll process it with ‘grep’ and then do some counting:

It might look something like this:

output showing there are 8 CPUs available
You’ll have to use your imagination for the rest. I’m only making one screenshot.

Now, those are individual threads that it’s counting – on the same physical CPU. But, to the system they appear to be individual CPUs. I can assure you, I do not have 8 physical CPUs in my laptop.

Solution #2:

Now, your computer does technically know if it’s a physical CPU, CPU core, or CPU core thread. It just normally doesn’t much care. If your CPU and OEM vendor did things properly, you can learn that information using ‘dmidecode‘.

They do not always implement this properly and you will sometimes find mistakes when using ‘dmidecode‘. Let’s hope for the best when we run this more convoluted command:

That one uses egrep and picks out multiple words to include. If you run that command, you should find out that your computer really can tell the difference between cores and threads – and physical CPU count (though not with this command).

Solution #3:

This final solution is nice and easy. If you’re gonna memorize one of these, this would be the one to memorize. In fact, if you’re going to need to count CPU processors or cores, you might just as well use this one. It’s easy and effective.

That one will output the total number of CPUs, cores, or threads. That’s all it will output, just a single number. That number is how many CPUs (effectively) your computer sees – and that’s it. It’s pretty much perfect.

Closure:

There you go. You have another article, this one explaining how to count CPU processors or cores (or threads, really). It’s handy information to know, though you probably already know it. Like I mentioned above, you can optimize C/C++ code to run on the specific number of cores – and there are other reasons you might want to know this. 

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.

One Way To See CPU Information

Today, we’re going to explore one way to see CPU information. On the original site, I had a couple of articles about this sort of stuff but we didn’t cover this method. It’s a short and sweet process, though I’ll show you a couple of ways to process the output.

The date that this will be published is July 4th. That’s a holiday in the United States. Not only do I live here, the vast majority of my readers live here (according to the stats I have). So, this will be a nice and easy article. For those of you who reside elsewhere, you’re welcome. You won’t have to work too hard today to understand what’s going on.

Anyhow, we’re not going to use any special tools. We’re not going to use any applications that you don’t already have installed. While we likely could, there really isn’t any need to. This being Linux, the information we’re after is already in a file. All we need to do is read that file.

So, let’s get to it…

How To See CPU Information:

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 now open, let’s go ahead and read the file we need if we want to see the CPU information:

That’ll output a ton of text. You can read it as it is, or you can actually get it in a more readable form using the ‘less’ command. To do that, you just change out the ‘cat’ command, like so:

Now, just use the arrows on your keyboard to scroll down (or back up) through the text. When you want to close the output and return to the terminal, just press Q and it will close.

Closure:

That’s it. That’s all there is to this article that tells you how to see CPU information. It’s not a very tough article, and it’s quick. So, I met those goals! Yay me! Enjoy your holiday, even if the holiday is just a nice quick article that doesn’t require much thinking. Me? I’ll drink some beer and char some dead animal flesh.

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.

Sort Files By Size (In The Terminal)

In today’s article, we’re going to cover something nice and simple; how to sort files by size in the terminal. This is something everyone should know, because sorting files is often a prerequisite to understanding and managing said files.

Besides, not all the articles have to be something complicated. The tagline for Linux-Tips is “Getting you up to speed!” It’s supposed to be aimed squarely at new Linux users. The problem is, many of those articles are boring to write and the 2nd largest group of readers aren’t really beginners. 

So, yeah…

Today, we’ll have a nice, basic article that tells you how to sort files by size – in the terminal. In fact, some of the more regular users may not have these commands memorized. Now’s a good time to learn ’em.

We’ll be using the ‘ls’ command for this. It is said that you shouldn’t parse the output of ‘ls’ for anything important. It’s bad practice for reasons I think I’ve touched on before. However, you can safely use ‘ls’ for this process as it’s just sorting the files by size and doing so by itself.

For those that don’t know, ‘ls’ has a ton of options. It’s a tool used to show the contents of a directory. You can use man ls to get more information about the command. We’ve previously covered:

Let’s Use ‘ls’ To Sort Files By Time

Well, today we’ll use ‘ls’ to …

Sort Files By Size:

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.

You might just as well stay right there in your default location – which should be your home directory. Feel free to switch to a new directory, but you really won’t need to. It’s an easy command. 

First, we’ll show the output sorted to show the largest files first:

Of course, you can reverse that sort order and show the smallest files first. To do that, you just add -r (reverse) to your flags, like so:

That command should show you files listed with the smallest ones first and that’s really all there is to this article. Well, there’s the closure section – but nobody reads those.

Closure:

And, well, this particular closure section won’t have anything truly interesting or different in it. After all, this is just a simple article that shows you how to sort files by size. ‘Snot that much more to it. ‘Snot that much more that I can add.

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: Create A New User

Today’s article is a nice and easy one, where you’ll learn how to create a new user. It’s a skill everyone should have and it’s really not all that difficult. It’s a pretty basic skill, after all. Either way, it shouldn’t be all that long, nor all that difficult.

In fact, I’ve previously covered some of this. Oddly, I’ve covered the more difficult stuff first. I’ve covered how to create a new user without a /home directory. I’ve also covered create a new user with sudo privileges. Oddly, I’ve never covered how to just plain create a new user. So, that’s what this article will explain.

The tool we’ll be using in this article is one you’ve used before, assuming you’ve been following the site. We’ll be using ‘adduser’ which the man page helpfully describes as:

adduser, addgroup – add a user or group to the system

As a tool, it does what it says on the tin. You can see that it’s also covering the ‘addgroup’ command. We won’t be covering that today, but it’s probably pretty obvious what it does. Hint: It is used to add groups! 

Alas, we’ll just be using the ‘adduser’ bit, in this pretty simple article to follow. Anyhow, you never know when you’ll want to create a new user and Linux is very much a multi-user operating system – even if you don’t realize it. Between users and groups, you can do some pretty fancy stuff with permissions.

Create A New User:

This article requires an open terminal, like oh so many do. To crack open a terminal, just press CTRL + ALT + T and your default terminal should open. See? It’s magic!

Now, with your terminal open, you can create a new user with:

Next, you’ll be asked for a password. Don’t be fooled, they want your root/sudo password and not the intended password for the new user. That will come later, after the user is created. The application will tell you what it’s doing, such as creating the new user, creating the new user’s home directory, and copying the default files to the new user’s home directory.

After it’s done with that, it’ll ask you for some finishing information. You’ll be asked to type the password. That’s when you enter the password for the new user. You’ll be asked to confirm it to make sure you typed it properly. It’ll then confirm that it has set the password, ‘adduser’ is helpful like that.

At this point,  you can opt to include more information. None of this is required information and you can leave the fields blank. But, if you want, you can fill the fields for things like the new user’s real name, their phone number(s), and even what room they are in.

Given that most of my readers are home users, you’re probably not going to need to add that information. Either way, when you’re done with that you will need to confirm the information. This is obvious, but you enter Y to confirm the data, or N to go back and edit something. When you finish that, you will have a new user account that you can use immediately.

Closure:

There you have it. You now have a new article. This one will have taught you how to create a new user. As I’ve mentioned, Linux is a multi-user operating system by design and, as such, you’ll eventually need to know how to create a new user. And… When that happens… You’ll either remember – or you’ll be able to search linux-tips.us for the answer! We’ve got well over 200 articles, so we’ve covered a lot of subjects.

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.