Join Scott Simpson for an in-depth discussion in this video Find disk and system information, part of Learning Linux Command Line (2016).
- [Voiceover] Let's take a look at finding out some information about the system you're working with. If you're using a physical computer, or a virtual machine you set up yourself, you know some parameters about it, like how much RAM it has, what kind of processing resources it has, and how much hard drive space there is. But if you're working on a remote system, it can be helpful to get a sense of what your resources are. First, let's find out how much RAM this machine has. To do this, I'll use the free command with the -h option, which gives us values in human-readable numbers.
Here under total memory, I can see that I have a gigabyte of RAM on this machine. Next, let's take a look at what our processor resources are. There's a file in the proc directory called cpuinfo. So let's take a look at that. I'll write cat /proc/cpuinfo. There's a lot of information here. I'll scroll up a little bit, and I can see I have an Intel Xeon processor, since I'm running this virtual machine on a 2013 Mac Pro. And I can see it's a 2.7 gigahertz one, and under cpu cores, I can see that this virtual machine has one cpu core.
I can also find out how much space is taken up and available on the system's hard drive. For that, I'll use the df command with the -h option. Again, to show human-readable sizes. This shows space across a few different volumes, but the most interesting one to me is slash or root, since that's where my user data is, and where I'm likely to be taking up space if I install software. The rest of these are managed by the system, so I'm not too worried about those. I can see I have about 20 gigabytes of total space on this virtual machine, and of that, 12 gigabytes is free.
You can also use the du command to see how much space files and folders take up on your system. Let's have a look at how much space is taken up across my whole system. I'll write sudo du, slash for root, -hd1. I have to use sudo, because my user can't see into all of the folders at the root of the drive. Then there's the du command for disk usage, and then slash, which is the level I want to start from, right at the root. The -h option gives me sizes in human-readable formats, kilobytes, megabytes, gigabytes, etc.
And the d option shows du what level of detail to show. In this case, I'm giving it the argument of one, meaning just show me one level deep, the first level away from the root, adding everything up within each of those folders. Let's take a look. This command takes a little bit of time to run. And here I can see the /var folder takes up 1.1 gigs. The /usr folder takes up 3.9, and the home folders for the system take up 11 megabytes. You don't always need to know all of these details about your system, but in case you do need this info, now you know how to get it.
This course will establish the foundation for more advanced Linux topics. Find other Linux training courses here.
- What is the Linux command line?
- Writing Linux commands at the prompt
- Finding help for Linux commands
- Editing files and folders
- Configuring user roles and file permissions
- Using pipes to connect commands
- Peeking at files
- Searching and editing text
- Finding disk and system information
- Installing and updating software