Inscrivez-vous maintenant pour un meilleur devis personnalisé!

Nouvelles chaudes

5 Linux commands you must know to keep your device running smoothly

Apr, 08, 2024 Hi-network.com
Inside a System76 Thelio.
Jack Wallen/

One of the many nice things about Linux is that there's always so much power at your fingertips. With that power comes great information that can help you troubleshoot issues or simply see how much RAM or storage is being used.

Over the years,I've come to depend on these tools, which are built into most Linux distributions andare fairly easy to use.

Also: Thefirst 5 Linux commands every new user should learn

Before I dive into these commands, know that you might never use them. In fact, withtoday's GUI desktops, the goalshouldbe to no longer have to depend on the command line. Of course, if you're working with a server, that's a different story. But as far as the desktopis concerned, you'll be glad you know them if the occasion ever arises.

With that said, let's jump to the commands.

1. top

Thetop command prints out a real-time list of Linux processes, which can be important should an app or process go awry and you need to find out which one. Top prints out a columned list that is broken down into the following:

  • PID - Process ID
  • USER - the owner of the listed process
  • PR - the process priority
  • NI - the nice value of the process (nice determines the process' priority)
  • VIRT - the amount of virtual memory the process is using
  • RES - the amount of resident memory the process is using
  • SHR - the amount of shared memory the process is using 
  • S - the status of the process (such as D - uninterruptable sleep, R - running, S - sleeping, T - stopped, and Z - zombie)
  • %CPU - the share of CPU time the process is using (since the last update)
  • %MEM - the share of physical memory the process is using
  • TIME+ - the total CPU time the process is using (in hundredths of a second)
  • COMMAND - the command associated with the process

Although you can define the content that is displayed, the default should work for most situations. The top command can also be helpful when using thekillcommand to end a runaway process (because you'll need to know the PID of the process in question).

To find out more abouttop, issue the commandman top.

2. df

There are times when you might want to know how much of your local storage is in use. That's where thedfcommand comes in. Thedfcommand presents a list of columns broken down into Filesystem, Size, Used, Avail, Use%, and Mounted on. Clearly,dfis also useful to find out where a particular partition is mounted, but you'll mostly use this command to understand how much of your drive's storage has been used.

Also: The6 Linux commands you need to know for user management

If you issuedfwithout any options, the report will be in 1K blocks, which can be a bit of a challenge to understand. Instead, I prefer to rundf -h(thehis forhuman readable), which presents the available space in GBs.

To find out more aboutdf, issue the commandman df.

3. ps

Thepscommand is rather important, as it reports a snapshot of the current running processes. In other words,pslists out all running processes on your system. The thing aboutpsis that you need to know the right options to make it useful. If you simply issue the commandps, you'll only see two entries, bash and ps- which are the current processes you are running.

The better way to runps is with the -aux option (which stands forall, user,and all processes owned by you). That command is:

ps-aux

Why isps so important? It is the easiest way to locate a process ID associated with a command (far better than usingtop). You can even useps with grepto find the process you're looking for. Say, for example, LibreOffice isn't responding and you need to kill it. To do that, you'll need the PID. If you don't want to scroll through the entire list of processes, you could issue something like:

ps -aux |grep libreoffice|grep libreoffice

This command will list only the processes associated with LibreOffice.

To find out more aboutps, issue the commandman ps.

4. free

The commandfreedisplays the amount of freeand used memory in your system. Instead of usingtop, which might offer too much information, you can usefree, which only lists memory and swap (if applicable). 

Also: My top 5 user-friendly GUI backup tools for the Linux desktop (and why you need one)

The output is formatted in columns of total (total installed memory), used (total used memory), free (total unused memory), shared (memory used by tempfs), buff/cache (sum of buffers and cache memory in use), and available (an estimation of how much memory is available for starting new applications without using swap).

The free command doesn't do anything else, but you can display the information in a human-readable form with:

free -h

To find out more aboutaboutfree, issue the commandman free.

5. lsblk

The lsblkcommand comes in handy when you need to mount a device or see where a device (a drive) is mounted. When you issue thelsblkcommand, you'll see output like this:

sdb       8:16   0 931.5G  0 disk  a??a??sdb1    8:17   0 931.5G  0 part  /media/jack/MINA

This means that block device /dev/sdb1 is mounted to the folder /media/jack/MINA. One option I sometimes use is-f, which adds the filesystem type to the listing.

To find out more about lsblk,issue the commandman lsblk.

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

tag-icon Tags chauds: technologie

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.
Our company's operations and information are independent of the manufacturers' positions, nor a part of any listed trademarks company.