Tech

5 Linux Commands I Use to Keep My Devices Running Smoothly


Inside the System76 Thelio.

Jack Wallen/ZDNET

One of the great things about Linux is that you have so much power at your fingertips. With that power comes great information that can help you troubleshoot problems or just see how much RAM or storage is being used.

Over the years I have grown to rely on these tools, they are built into most Linux distributions and are quite easy to use.

Also: These Linux Distributions Are Best for Developers — Here’s Why

Before I dive into these commands, know that you probably never use them. In fact, with today’s GUI desktops, the goal should no more relying on the command line. Of course, if you’re working with servers, that’s a different story. But for desktops, you’ll be glad to know them if you get the chance.

Having said that, let’s move on to the commands.

1. top of page

The head The command prints out a real-time list of Linux processes, which can be important if an application or process crashes and you need to figure out which process it is. Top prints out a columnar list divided into the following categories:

  • PID – Process ID
  • USER – owner of the listed process
  • PR – the process of prioritization
  • NI – nice value of the process (nice determines the priority of the process)
  • VIRT – the amount of virtual memory the process is using
  • RES – amount of resident memory the process is using
  • SHR – amount of shared memory the process is using
  • S – state of the process (such as D – uninterrupted sleep, R – running, S – sleeping, T – stopped and Z – zombie)
  • %CPU – the percentage of CPU time the process is using (since last update)
  • %MEM – the physical memory that the process is using
  • TIME+ – total CPU time the process is using (in hundredths of a second)
  • COMMAND – command related to process

While you can define what is displayed, the default will work for most situations. head command can also be useful when using kill command to kill a runaway process (because you need to know the PID of that process).

To learn more about headissue order leading man

2. df

There are times when you might want to know how much of your local storage is being used. That’s where df command to enter df command shows a list of columns divided into File System, Size, Used, Available, Used% and Mounted. Obviously, df It’s also useful to find out where a specific partition is mounted, but you’ll mainly use this command to understand how much of your drive’s storage is being used.

Also: 5 Best Linux Distributions for Gamers in 2024

If you release df without any options the report will be in 1K blocks, which can be a bit confusing. Instead I prefer to run df-h (the hour is for human readable), shows available capacity in GB.

To learn more about dfissue order df man.

3. ps

The p/s command is quite important because it reports a snapshot of the currently running processes. In other words, p/s list all the processes running on your system. Problem p/s is that you need to know the right options to make it useful. If you just give the command p/sYou will only see two entries, bash and ps – these are the current processes you are running.

How to run better p/s is with the -aux option (short for all, user, And All processes are owned by you). That command is:

Why is p/s Is it that important? This is the easiest way to determine the process ID associated with a command (much better than using head).You can even use p/s with grep to find the process you are looking for. For example, LibreOffice is not responding and you need to kill it. To do so, you will need the PID. If you don’t want to scroll through the entire list of processes, you can issue a command like this:

ps -aux |grep libreoffice

This command will only list processes related to LibreOffice.

To learn more about p/sissue order ps man.

4. free

Command free of charge displays the amount of free and used memory in your system. Instead of using head, can provide too much information, you can use free of charge, List only memory and swap (if any).

Also: The First 5 Linux Commands Every New User Should Learn

The output is formatted with columns total (total installed memory), used (total used memory), free (total unused memory), shared (memory used by tempfs), buff/cache (total and used buffers), and available (estimated amount of memory available to start new applications without using swap).

The free of charge The command does nothing else, but you can display the information in a readable form with the command:

To learn more about free of chargeissue order free man.

Also: 6 Linux Commands You Need to Know to Manage Users

5. lsblk

The lsblk This command is useful when you need to mount a device or see where a device (drive) is mounted. When you issue lsblk command, you will see the result like this:

sdb 8:16 0 931.5G 0 disk └─sdb1 8:17 0 931.5G 0 part /media/jack/MINA

This means that the block device /dev/sdb1 is mounted in the /media/jack/MINA directory. An option I sometimes use is -fadd file system type to list.

To learn more about lsblk, issue order lsblk man.

These commands may come in handy someday. You may not need them at first (or ever), but knowing they exist (and their basic uses) can make troubleshooting your Linux system much easier.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *