Chris Hoffman is Editor-in-Chief of How-To Geek. He’s written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times and Reader’s Digest, been interviewed as a technology expert on TV stations like Miami’s NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read nearly one billion times—and that’s just here at How-To Geek. Read more.
The Linux terminal has a number of useful commands that can display running processes, kill them, and change their priority level. This post lists the classic, traditional commands, as well as some more useful, modern ones.
Many of the commands here perform a single function and can be combined — that’s the Unix philosophy of designing programs. Other programs, like htop, provide a friendly interface on top of the commands.
The top command is the traditional way to view your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top.
To exit top or htop, use the Ctrl-C keyboard shortcut. This keyboard shortcut usually kills the currently running process in the terminal.
The htop command is an improved top. It’s not installed by default on most Linux distributions — here’s the command you’ll need to install it on Ubuntu:
htop displays the same information with an easier-to-understand layout. It also lets you select processes with the arrow keys and perform actions, such as killing them or changing their priority, with the F keys.
The ps command lists running processes. The following command lists all processes running on your system:
This may be too many processes to read at one time, so you can pipe the output through the less command to scroll through them at your own pace:
Press q to exit when you’re done.
You could also pipe the output through grep to search for a specific process without using any other commands. The following command would search for the Firefox process:
pstree
The pstree command is another way of visualizing processes. It displays them in tree format. So, for example, your X server and graphical environment would appear under the display manager that spawned them.
The kill command can kill a process, given its process ID. You can get this information from the ps -A, top or pgrep commands.
Technically speaking, the kill command can send any signal to a process. You can use kill -KILL or kill -9 instead to kill a stubborn process.
pgrep
Given a search term, pgrep returns the process IDs that match it. For example, you could use the following command to find Firefox’s PID:
You can also combine this command with kill to kill a specific process. Using pkill or killall is simpler, though.
pkill & killall
The pkill and killall commands can kill a process, given its name. Use either command to kill Firefox:
We’ve covered pkill in more depth in the past.
renice
The renice command changes the nice value of an already running process. The nice value determines what priority the process runs with. A value of -19 is very high priority, while a value of 19 is very low priority. A value of 0 is the default priority.
The renice command requires a process’s PID. The following command makes a process run with very low priority:
You can use the pgrep trick above with renice, too.
If you’re making a process run at a higher priority, you’ll require root permissions. On Ubuntu, use sudo for that:
xkill
The xkill command is a way of easily killing graphical programs. Run it and your cursor will turn into an x sign. Click a program’s window to kill that program. If you don’t want to kill a program, you can back out of xkill by right-clicking instead.
You don’t have to run this command from a terminal — you can also press Alt-F2, type xkill and press Enter to use it from a graphical desktop.
We’ve covered binding xkill to a hotkey to easily kill processes.
Do you have a favorite command we didn’t mention here, or another trick to share? Leave a comment and let us know.
This post is also available in: English
The Linux terminal has a number of useful commands that can display running processes, kill them, and change their priority level. This post lists the classic, traditional commands, as well as some more useful, modern ones.
Many of the commands here perform a single function and can be combined — that’s the Unix philosophy of designing programs. Other programs, like htop, provide a friendly interface on top of the commands.
The top command is the traditional way to view your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top.
To exit top or htop, use the Ctrl-C keyboard shortcut. This keyboard shortcut usually kills the currently running process in the terminal.
The htop command is an improved top. It’s not installed by default on most Linux distributions — here’s the command you’ll need to install it on Ubuntu:
htop displays the same information with an easier-to-understand layout. It also lets you select processes with the arrow keys and perform actions, such as killing them or changing their priority, with the F keys.
The ps command lists running processes. The following command lists all processes running on your system:
This may be too many processes to read at one time, so you can pipe the output through the less command to scroll through them at your own pace:
Press q to exit when you’re done.
You could also pipe the output through grep to search for a specific process without using any other commands. The following command would search for the Firefox process:
pstree
The pstree command is another way of visualizing processes. It displays them in tree format. So, for example, your X server and graphical environment would appear under the display manager that spawned them.
The kill command can kill a process, given its process ID. You can get this information from the ps -A, top or pgrep commands.
Technically speaking, the kill command can send any signal to a process. You can use kill -KILL or kill -9 instead to kill a stubborn process.
pgrep
Given a search term, pgrep returns the process IDs that match it. For example, you could use the following command to find Firefox’s PID:
You can also combine this command with kill to kill a specific process. Using pkill or killall is simpler, though.
pkill & killall
The pkill and killall commands can kill a process, given its name. Use either command to kill Firefox:
We’ve covered pkill in more depth in the past.
renice
The renice command changes the nice value of an already running process. The nice value determines what priority the process runs with. A value of -19 is very high priority, while a value of 19 is very low priority. A value of 0 is the default priority.
The renice command requires a process’s PID. The following command makes a process run with very low priority:
You can use the pgrep trick above with renice, too.
If you’re making a process run at a higher priority, you’ll require root permissions. On Ubuntu, use sudo for that:
xkill
The xkill command is a way of easily killing graphical programs. Run it and your cursor will turn into an x sign. Click a program’s window to kill that program. If you don’t want to kill a program, you can back out of xkill by right-clicking instead.
You don’t have to run this command from a terminal — you can also press Alt-F2, type xkill and press Enter to use it from a graphical desktop.
We’ve covered binding xkill to a hotkey to easily kill processes.
Do you have a favorite command we didn’t mention here, or another trick to share? Leave a comment and let us know.
Dave McKay first used computers when punched paper tape was in vogue, and he has been programming ever since. After over 30 years in the IT industry, he is now a full-time technology journalist. During his career, he has worked as a freelance programmer, manager of an international software development team, an IT services project manager, and, most recently, as a Data Protection Officer. His writing has been published by howtogeek.com, cloudsavvyit.com, itenterpriser.com, and opensource.com. Dave is a Linux evangelist and open source advocate. Read more.
Killing a process is sometimes the only way to get rid of it. Despite the harsh name, “killing” a process just means “forcing it to quit.” Here’s how to do it from the Linux or macOS command line.
What is a Process?
Running programs like your web browser, background processes associated with your desktop environment, and Linux system services are all processes.
You can lump processes into two groups:
- Foreground processes are ones that have been started or launched by a user. They may be in a terminal window, or they may be a graphical application.
- Background processes are all of the processes that are started automatically and don’t have any interaction with users. They don’t expect input from users nor do they present results or output to them. Background processes are things like services and daemons.
If the foreground processes are the front of theater staff and the actors, the background processes are the backstage “behind the scenes” team.
When processes misbehave or malfunction, they can hog too much CPU time, consume your RAM, or enter a tight computational loop and become unresponsive. Graphical applications can refuse to respond to mouse clicks. Terminal applications might never return you to the command prompt.
The Humane Answer
“Killing” a process just means “forcing the process to quit.” This may be necessary if the process is refusing to respond.
Linux provides the kill , pkill , and killall commands to allow you to do just that. These commands can be used with any type of process, graphical or command line, foreground or background.
The kill Command
To use kill , you must know the process ID (PID) of the process you wish to terminate. The ps command can be used to find the PID of a process.
To have ps search through all of the processes use the -e (all processes) option. Piping the output through less is advisable, there’s going to be quite a bit of it. Type ps , a space, -e , a space, | (a pipe character), another space and then type less . Press Enter to execute the command.
This will give you a process listing that looks similar to the below screenshot. You can search forward in less using the / key and you can search backward using the ? key.
To home in on the process you’re interested in, pipe the output from ps through grep and specify the name—or part of the name—of the process.
Once you have located the PID of the process you wish to terminate, pass it to the kill command as a parameter. To terminate the shutter process identified by the previous command, use this command:
The kill command is a silent assassin—it does not give you any feedback if it was successful.
The pkill Command
The pkill command allows you to kill a process—or processes—by name. You do not need to identify the process by PID. To use pkill you provide a search term that pkill uses to check against the list of running processes. Matching processes are terminated. So you need to be positive you’ve got that search term spelled correctly.
As a safety net, you can use the pgrep command before you use the pkill command. The pgrep command also accepts a search term. It will list the PID of each process that matches the search term. This is safe because pgrep will not issue any kill signal to the processes, and if you mistype the search term you will not kill another process by mistake. You can make sure you have the search term correctly thought out before you pass it to pkill . Both pkill and pgrep treat the search term in the same way. Their treatment is so similar that they share the same man page.
Let’s suppose there is a process with “subq” in its name. We’ll use the ps -u dave | grep command to get a peek behind the curtain. You can see that “subq” will match that process and that process alone. That was just so you can see the full name of the process.
Let’s assume our user hasn’t done that; all they know is the process name contains the substring “subq.” They use pgrep to check that there is only one match to the search term. They then use that search term with pkill .
You can use pkill to kill several processes at once. Here the user runs pgrep to check how many processes Chrome has launched. They use pkill to kill them all. They then check with pgrep that they have all been removed.
If several processes with the same name are running, but you do not want to kill them all, you can use pgrep with the -f (command line) option to identify which process is which. A simple example would be two ping processes. You want to kill one of them but not the other. You can use their command lines to distinguish between them. Note the use of quotation marks to wrap the command line parameter.
The killall Command
Warning: In the Solaris and OpenIndiana operating systems the killall command will kill all the processes that belong to you. If are root or if you have issued sudo killall you will reboot your computer! During the research for this article, this behavior was confirmed with the latest version of OpenIndiana Hipster 2018.10.
The killall command operates in a similar way to the pkill command but with a specific difference. Instead of passing a search term to the command you must provide the exact process name.
You cannot provide a partial match to a process name; you must provide the entire process name, as shown:
The -y (younger than) option allows you to kill processes that have been running for less than a specified period. The period is given in numbers followed by one of these units:
- s (seconds)
- m (minutes)
- h (hours)
- d (days)
- w (weeks)
- M (months, note, capital “M”)
- y (years)
To kill a process called ana that has just been launched and leave any older instances of ana running, you could use the following parameters with killall , if you’d reacted within two minutes:
The -o (older than) option allows you to kill processes that have been running for longer than a specified period. This command will kill all ssh connections that have been running for longer than a day:
Don’t Be Too Trigger Happy
These commands will allow you to identify and terminate errant processes with accuracy and safety correctly.
Always be cautious. First, make sure the process you’re about to kill is really the one you want. Second, double check— be careful and ensure the targeted process is the one you want to end. Proceed with terminating the process once you’re satisfied.
If you work in Linux, chances are you have to do some process management. Here are some commands to simplify that workflow.
If you only do occasional work in Linux, chances are that the work is related to processes. Processes are launched with the systemd service manager. You need Linux process management commands to effectively allocate compute power and keep track of jobs.
Systemd is the service manager for Linux . If you need services, you can deploy the systemctl command, which requires root privileges . To access these privileges add sudo to the systemctl stop sshd command, making it sudo systemctl stop sshd.
The systemctl command uses many variants, but for occasional Linux use, you’ll only need a few. To start, use the systemctl list-units -t service command. This prompt gives you a list of all the currently running services. Use the arrow keys to navigate through the list and find the exact name of the service you want to run.
After finding the service you want to manage, there are several common Linux process management commands you can use. Here are a few, using the sshd service as an example:
- Systemctl status sshd will show the current status of your service. You’ll get a large amount of detail in the output, as this command also shows relevant log information.
- Systemctl restart sshd restarts the service. This can be useful if the service doesn’t work as expected and requires troubleshooting.
- Systemctl stop sshd stops the service. Systemctl start sshd will start it again.
In Linux, services start different processes. If you need more information about individual processes, use the ps command . With administrator privileges, the ps aux command lists all the active processes on your system. When going through the processes, know that the most recent ones are listed last.
Look for the process identification number (PID), which is useful to stop tasks with the right Linux process management commands. To do so, use the kill command. For instance, if your sshd process has PID 811, use kill 811 to stop it.
Start specific jobs by typing a command into a Linux terminal. If the task only takes a few seconds, there’s hardly any need to perform specific process management for it. However, if you start a task and it takes several minutes to complete, it makes sense to move it into the background.
You can move any job you’ve started to the background. To do so, use the Ctrl + Z sequence to temporarily stop the task. Next, use the bg command to move the task to the background. The jobs command enables you to check if the task is still running.
It’s also possible to move tasks that are running in the background to the foreground. To do so, look up the job number of the task with the jobs command and use the fg command. For instance, fg 2 will move task 2 from the jobs list to the foreground. Once a task is in the foreground again, you can apply any of the necessary Linux process management commands.
Home » SysAdmin » Linux exec Command With Examples
The Linux exec command executes a Shell command without creating a new process. Instead, it replaces the currently open Shell operation. Depending on the command usage, exec has different behaviors and use cases.
This article demonstrates how to use the exec command in Linux.
- Access to the command line/terminal as sudo.
- Basic understanding of Linux terminal commands (use our Linux commands cheat sheet).
- A Linux text editor such as nano.
Linux exec Command Syntax
The exec command syntax is:
The command behaves differently depending on the number of arguments:
- If an argument is present, the exec command replaces the current shell with the executed program. In a Bash script, any commands after do not get executed.
- If no command argument is present, all redirections occur in the current shell.
The exec command never returns to the original process unless there’s an error or the command runs in a subshell.
Linux exec Command Options
Below is a brief explanation of all exec options:
| Option | Description |
|---|---|
| -c | Executes the command in an empty environment. |
| -l | Passes a dash ( – ) as the zeroth argument. |
| -a [name] | Passes a [name] as the zeroth argument. |
Continue reading to see how exec works through examples.
Linux exec Command Examples
The examples below demonstrate the behavior of the exec command in the terminal and through Bash scripts.
Basic Use (Process Replacement)
To see how exec works, do the following:
The output shows the currently running Bash shell and the ps command. The Bash shell has a unique PID.
2. To confirm, check the current process ID with:
The PID is the same as the output from the ps command, indicating this is the currently running Bash process.
3. Now, run exec and pass the sleep command for one hundred seconds:
The sleep command waits for 100 seconds.
4. In another terminal tab, list all currently running processes and grep the sleep command:
The PID for the process is the same as the Bash shell PID, indicating the exec command replaced the Bash shell process.
The Bash session (terminal tab) closes when the one hundred seconds are complete and the process ends.
Replace Current Shell Session
Use the exec command to replace the current shell session:
1. Check the current shell PID:
2. Use exec to switch to the Bourne Shell:
3. In another tab, check the PID for the Bourne Shell process:
Note: The \b in grep is Regex for matching word boundary, allowing an exact match of sh in the output. Learn more in our Grep Regex tutorial.
The command replaces the Bash process. Exiting the Bourne Shell exits the terminal session completely.
Program Calls With exec in Bash Scripts
To see how exec works in Bash scripts, do the following:
1. Open a text editor, such as Nano, and create a script file:
2. Paste the following code:
The script does the following:
- Line 3 creates an infinite while loop.
- Lines 5-7 print the three possible options.
- Line 8 reads the user’s input into the variable $Input .
- Line 9 starts a case statement checking the user’s input.
- Lines 10-11 execute the apt update or apt upgrade command in place of the current shell. When the update or upgrade process ends, the terminal session exits.
- Line 12 uses the break statement to exit the infinite while loop and ends the script. The session returns to the current shell as usual.
3. Save the script and close Nano.
4. Run the Bash script in the current environment to see the results:
Executing the script with the source command applies the script behavior to the current Bash shell. Use exec to run Bash scripts within other programs for a clean exit.
Logging Bash Scripts
The exec command finds use in manipulating file descriptors for error logging in Bash scripts. The default Linux file descriptors are:
- stdin (0) – Standard in
- stdout (1) – Standard out
- stderr (2) – Standard error
Use the exec command and redirect the file descriptors to a file to create logs. To see how logging works, follow the steps below:
1. Create a sample Bash script:
2. Paste the code into the file:
The script redirects all command outputs and errors to the same file (test.log).
3. Save the script and close the text editor.
5. Run the script:
The script does not output any code. Instead, all the output logs to the test.log file.
6. Use the cat command to see the test.log file contents:
The log file contains all the standard outputs and error messages. Use exec to debug scripts and log inputs, outputs, or errors depending on the situation.
Run Scripts in a Clean Environment
The -c option for the exec command creates a clean environment. To demonstrate, do the following in the terminal:
1. Start a new Bash shell session:
2. Use the printenv command to print all the environment variables in the current Bash shell:
The command prints all the environment variables for the current Bash shell session.
3. Run the same command using exec with the -c flag:
The command printenv runs in a clean environment, and no variables output to the console. Use the -c option to run scripts or commands in clean environments.
exec With find Command
The find command in Linux has the exec command as an option to execute an action on discovered content. For example, the line below executes the chmod command on the find command results:
The find command searches through the home directory (
) for the test.log file and executes the permission change.
After following the examples from this tutorial, you should know how to use the exec command effectively in Bash scripts.
One of the central responsibilities of Linux administration is the management of users. Through the use of the command line, user creation can be completed remotely or programmatically. Once you’ve created a user, you can then add them to groups or give them escalated privileges. In addition, you are able to keep an audit trail on what has been done on your server and any potential issues.
If you’ve developed software or programmed for the Web, you might be familiar with the policy of never trusting users. This same premise applies in other areas of computer usage in regards to user involvement. Only give access to those who need it and when they need it. Generous delegation of privileges could allow unspecified and unauthorized access to others’ information and core data.
Viewing existing users
One of the quickest ways to view users is to use the cat (concatenate) or more (pager) commands to view the list of users on the system. The file you will need to view is the “/etc/passwd” file. This file stores all user accounts and user login information.
Utilizing the useradd command
useradd is a low-level binary available on most distros. This command is typically less used due to it being less user-friendly and intuitive compared to the adduser command. However, there are very few differences and either can be used.
To find out more about useradd, run the man command or add –help to get a quick overview.
To add a user using useradd , type useradd and the name of the login you want to create.
In the case above, the user “testuser” will be created. By default, this command will only create the user and nothing else. If you need a home directory for this user, append the –create-home flag to create the home directory for the user.
Utilizing the adduser command
The adduser command is a perl script that will create the user similar to the useradd command. What makes it different is that it is an interactive command and will prompt you to set the password, the home directory path, etc. Take note that on some distros, such as Red Hat and CentOS, adduser is a symbolic link to useradd, and on other distro like Arch Linux, adduser comes as a package that is not installed by default.
Using this command will create a group for the user using the user’s login by default. Other defaults can typically be found in the useradd file at “/etc/default”.
In this file you can change default settings for users created with useradd such as the shell and the home directory.
Run the adduser command similar to the following:
This will then prompt you regarding the defaults you want set and ask you for the password.
Passwords and security
Adding a password for a user will require running the passwd command.
Without superuser privileges, running passwd will only change the password of the logged-in user. This command will test the password for complexity. On Ubuntu password requirements are set in the common-password file located in “/ec/pam.d.” More information regarding updating the complexity can be found in the man page for pam-auth-update.
Updating user information
Once a user is on the system, you can review the “/etc/passwd” file to see the user’s information and encrypted password. If you need to make changes to a user, you will need to utilize the usermod command.
As an example, to change the user id for the testuser4 account created above, you would run the command:
You can then review the changes in the “/etc/passwd” file.
Be careful of changing critical information such as the login name, or as in this case, the user id. Review the man page for usermod to see what you will need to do if those items are changed.
Adding users to group
There are times when you need to add users to a group so they have the necessary permission to run certain tasks.
To add a user to a group:
Note that the -a flag is necessary to “append” the group for the user. If not, you will risk removing the user from the “sudo” group if the user is supposed to have superuser permission.
Alternatively, you can use the gpasswd command to add/remove user to/from group.
To remove user from a group:
Removing users
Similar to the other user commands, deleting a user is prefixed with “user” and the action. In this case you will need to use the userdel command.
Take note that userdel will not remove a user if there are processes using that user’s account.
Viewing user logs
Depending on your distro, you will either check the auth log or the secure log located in “/var/log” to review user logins. This log file will give you logins on your system as soon as they happen. This is a critical element to monitoring events in the case of a breach and just to ensure things are working as desired.
User management is a crucial part of managing Linux servers if there is more than one person who will use your system. Using the command line will allow you to quickly administer users, as well as have a history of account creation and changes. Perhaps one of the best uses would be to automate creation with a shell script if multiple accounts are needed at once.
Either way, be sure to go through your accounts on a regular basis and remove accounts that are no longer needed. Ensure access is granted only to those who currently need access and monitor your logs frequently.
Our latest tutorials delivered straight to your inbox
Home » SysAdmin » How to Start, Stop, and Restart Services in Linux
Linux provides fine-grained control over system services through systemd, using the systemctl command. Services can be turned on, turned off, restarted, reloaded, or even enabled or disabled at boot. If you are running Debian 7, CentOS 7, or Ubuntu 15.04 (or later), your system likely uses systemd.
This guide will show you how to use basic commands to start, stop, and restart services in Linux.
- Access to a user account with sudo or root privileges
- Access to a terminal/command line
- The systemctl tool, included in Linux
Basic Syntax of systemctl Command
The basic syntax for using the systemctl command is:
Typically, you’ll need to run this as a superuser with each command starting with sudo .
How To Check If a Service is Running on Linux
To verify whether a service is active or not, run this command:
Replace apache2 with the desired service. In our case, we checked the status of Apache. The output shows that the service is active (running), as in the image below:
How to Restart a Service
To stop and restart the service in Linux, use the command:
After this point, your service should be up and running again. You can verify the state with the status command.
How to Reload a Service
To force the service to reload its configuration files, type in the following command in the terminal:
After reloading, the service is going to be up and running. Check its state with the status command to confirm.
In our example, we reloaded Apache using:
How to Start a Service
To start a service in Linux manually, type in the following in the terminal:
For instance, the command to start the Apache service is:
How to Stop a Service
To stop an active service in Linux, use the following command:
If the service you want to stop is Apache, the command is:
Check whether the service stopped running with the status command. The output should show the service is inactive (dead).
How to Enable the Service at Boot
To configure a service to start when the system boots, use the command:
To enable Apache upon booting the system, run the command:
How to Disable Service at Boot
You can prevent the service from starting at boot with the command:
Variations in Service Names
If you work within the same Linux environment, you will learn the names of the services you commonly use.
For example, if you are building a website, you will most likely use systemctl restart apache2 frequently, as you refresh configuration changes to your server.
However, when you move between different Linux variants, it is helpful to know that the same service may have different names in different distributions.
For example, in Ubuntu and other Debian based distributions, the Apache service is named apache2. In CentOS 7 and other RedHat distros, the Apache service is called httpd or httpd.service.
In most modern Linux operating systems, managing a service is quite simple using the commands presented here.
Make sure to know the name of the service for the operating system you are using, and the commands in this article should always work.
In this article, we will share a number of cool command-line programs that you can use in a Linux terminal. By the end of this article, you will learn about some free, open source, and exciting, text-based tools to help you do more with boredom on the Command line.
1. Wikit
Wikit is a command line utility to search Wikipedia in Linux. It basically displays Wikipedia summaries. Once you have it installed, simply provide the search term as an argument (for example wikit linux).
Wikipedia Command Line View
2. Googler
Googler is a full-featured Python-based command line tool for accessing Google (Web & News) and Google Site Search within the Linux terminal. It is fast and clean with custom colors and no ads, stray URLs or clutter included. It supports navigation of search result pages from omniprompt.
In addition, it supports fetching of number of results in a go, users can start at the nth result, and supports limiting of search by attributes such as duration, country/domain specific search (default: .com), language preference.
Google Search from Linux Terminal
3. Browsh
Browsh is a small, modern text based browser that play videos and render anything that a modern browser can, in TTY terminal environments.
It supports HTML5, CSS3, JS, video as well as WebGL. It is a bandwidth-saver, designed to run on a remote server and accessed via SSH/Mosh or the in-browser HTML service so as to notably reduce bandwidth.
It is practically useful when you don’t have good Internet connection.
Browsh Web Browsing
4. Lolcat
Lolcat is a command-line program to output rainbow of colors in the Linux terminal. It concatenates the output of a command in a similar way as cat command and adds rainbow coloring to the final output.
To use lolcat, simply pipe the output of any command to lolcat.
Cowsay with Lolcat
5. Boxes
Boxes is a configurable program and text filter which can draw ASCII art boxes around its input text in a Linux terminal. It comes with a number of pre-configured box designs in example config file. It comes with several command-line options and supports regular expression substitutions on input text.
You can use it to: draws ASCII art boxes and shapes, generate regional comments in source code and more.
Boxes – Draw ASCII Art in Terminal
6. Figlet and Toilet
FIGlet is a useful command-line utility for creating ASCII text banners or large letters out of ordinary text. Toilet is a sub-command under figlet for creating colorful large characters from ordinary text.
Figlet – Create ASCII Text Banners in Terminal
7. Trash-cli
Trash-cli is a program that trashes files recording the original path, deletion date, and permissions. It is an interface to the freedesktop.org trashcan.
Manage ‘Trash’ from Linux Command Line Trash-cli – A Trashcan Tool
8. No More Secrets
No More Secrets is a text-based program recreates the famous data decryption effect seen in the 1992 movie Sneakers. It provides a command-line utility called nms, that you can use in a similar way as lolcat – simply pipe the out of another command to nms, and see the magic.
No More Secrets – Recreates Data Decryption Effect
9. Chafa
Chafa is a another cool, fast and highly configurable terminal program that provides terminal graphics for the 21st century.
It works with most modern and classic terminals and terminal emulators. It converts all types of images (including animated GIFs), into ANSI/Unicode character output that can be displayed in a terminal.
Chafa supports for alpha transparency and multiple color modes (including Truecolor, 256-color, 16-color and simple FG/BG.) and color spaces, combining selectable ranges of Unicode characters to produce the desired output.
It is suitable for terminal graphics, ANSI art composition as well as even black and white print.
Chafa – Converts to ANSI Unicode Character
10. CMatrix
CMatrix is a simple command-line utility that shows a scrolling ‘Matrix‘ like screen in a Linux terminal.
It displays random text flying in and out in a terminal, in a similar way as seen in popular Sci-fi movie “The Matrix“. It can scroll lines all at the same rate or asynchronously and at a user-defined speed. One downside of Cmatrix is that it is very CPU intensive.
The Matrix in Linux Terminal
Here you have seen few cool command-line tools, but there is plenty more to explore. If you want to know more about such cool or funny Linux command-line tools, you can checkout our guides here:
That’s all! Do you spend a lot of time on the command line? What are some of the cool command-line tools or utilities you use on the terminal? Let us know via the feedback form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Introduction to Kali Linux Commands
Kali Linux is one of the popular tools designed by Linux distribution for mainly used in digital forensics for ensuring proper penetration testing. It is one of the first open-source platforms where android application penetration testing can also be possible. Backtracking mainly holding one specific mode called forensic mode; this is mainly carried over to this Kali environment by using some live boot. This article will see different kali Linux commands.
Basic Kali Linux Commands
There has a lot of kali Linux commands, especially for running or handling any kind of defined documents, create documents, maintaining varieties of directories, or writing scripts in the Linux platform. Some of the basic commands are mentioned below:
Web development, programming languages, Software testing & others
- Command for getting Date: This is one of the common commands for helping to display normal dates with time on the Linux screen. It is also possible to set some of the custom dates, which can be handled by using this specific command.
# date –set=’17 Jan 2019 12:16’
Executing the above command, always given the below result as output:
Thu Jan 17 12:18:20 EDT 2019
- Command for displaying Calendar: One of the key commands of the Kali Linux operating system is cal which actually helps for displaying the proper require calendar in the Linux terminal screen where anyone can able to identify the local date. There has a lot of additional calendar packages available in the case of the Kali Linux command, where people can able to manage the calendar in varieties way, sometimes they can able to present it vertically or some other critical features with this additional command. This additional command package call the ncal package needs to download to your local Linux machine for using those features.
- Whoami and who command: There is two very much useful and popular command in Kali Linux platform are whoami and who commands. Whoami is one of the key commands which provided an exact effective username immediately who are involved in executing this specific command. And who is the command where it will give entire logged-in user detail information?
- Pwd: PWD is actually standing for Print Working Directory. This Kali Linux command is mainly using for displaying the specific directory where the command executer is currently belonged to. Sometimes in the case of the Linux platform, user are unable to understand in which directory he is right now. Then PWD is the key command for understanding the same.
- Ls:This is also a very commonly used command in the Kali Linux platform. Every user, after applying their logic, this is one of the first commands they execute. Command Ls is actually providing the entire list of documents available in that specific directory. There have several other extended commands of Ls which are using for managing the display of those files in a proper manner. Suppose, ls –lrt, ls –al are given some additional information of those list of files on that specific directory.
- Cd: Cd command is mainly used for changing the directory in the Kali Linux platform.
- Mkdir: Mkdir is one of the key commands for the Kali Linux platform. This actually helps in creating one new directory in the Kali Linux platform.
- Cat: Cat command is commonly used for displaying the entire content of one file. It also can be used for creating or concatenate single or multiple files in the Kali Linux platform.
- Cp: This Kali Linux command is normally used for copying the image of an existing file or directory and paste the same anywhere in the Kali Linux platform with a different file name.
- Mv:Mv command is also a very frequently used command for moving the files or directory to another location with the same name and content.
Intermediate Kali Linux Commands
There are several other popular kali Linux commands which have been used by the developer who is not very basic but working with Kali Linux more; those Linux commands are very much required to execute.
Some of those kinds of requiring intermediate Linux commands are mentioned below:
- Rm: Rm command is used for mainly deleting or removing files or multiple files. If we use this rm command recursively, then it will remove the entire directory.
- Uname: This command is very much useful for displaying the entire current system information properly. It helps for displaying Linux system information in the Linux environment in a proper way for understanding the system’s current configuration.
- Uptime: The uptime command is also one of the key commands for the Kali Linux platform, which gives information about how long the system is running.
- Users: These Kali Linux commands are used for displaying the login user name who is currently logged in on the Linux system.
- Less: Less command is very much used for displaying the file without opening or using cat or vi commands. This command is basically one of the powerful extensions of the ‘more’ command in the Linux environment.
Advanced Kali Linux Commands
Still, some of the critical tasks need to be done by the Kali Linux command users frequently. Those tasks also have some advance kind of commands need to be executed, which mainly used by some of the managerial people for sorting, identifying or modifying a specific file, shell scripting writing, job scheduling etc. Those advance kind of Kali Linux commands are below:
In this guide, we will demonstrate how to kill a Linux process by its PID.
PID in Linux
The term PID is an acronym for “process identification number”. Each process is assigned a unique PID the moment they’re created on the system. The PID number 1 is assigned to systemd (init, for older systems). Essentially, systemd or init is always the first process to start on Linux and is parent to all other processes.
There are a couple of tools we can use to get the PID of a target process. The most popular (and recommended) method of getting the PID is using the ps command. It’s a built-in tool available on all Linux systems. Learn more in-depth about the ps command in Linux.
To print all the running processes with their PID, run the following ps command:
For easier navigation, pipe the output to the less command:
Notice that the PID column lists all processes sorted by PID. It’s the value that we are looking for.
Looking for a particular process with a specific name? Then the grep command is your friend. It can search for a particular pattern in the given file (STDOUT, in this case). For example, the following command will search for any running Firefox process:
If you know the name of the target process, then we can use the pidof command to directly get the PID.
Another interesting command to do the job is pgrep. It directly operates on the list of currently running processes. The pgrep command will take the process name as the parameter and print the PID of any matching entry.
Note the PID of the target process. The next section of this article will showcase terminating the process by its PID.
Killing a Process
Killing a process requires sending a terminal signal to the process. However, there isn’t a single termination signal. There are several of them, each acting slightly differently than the others. So, it’s crucial to understand them first.
Linux Kill Signals
The kill command in Linux is responsible for sending the termination signals. For a detailed explanation, check out this guide on the Linux kill command. In short, you tell the kill command what signal to send to which process (using PID).
To get the complete list of all the termination signals, run the following command:
For the most part, however, we will need only a handful of them. Here are detailed explanations of the most common termination signals you should know about.
- SIGUP (1) – The controlling terminal is hung up or the controlling process is dead. In such a situation, SIGUP will reload the configuration files and open/close log files.
- SIGKILL (9) – It’s a direct kill signal to the target process. It should be used as the last resort to terminate a process. If a process is terminated using SIGKILL, then it won’t save data or cleaning upon the termination of the process.
- SIGTERM (15) – It sends a termination signal to the target process. SIGTERM is the default signal to send. It’s also considered the safest method of terminating a process.
Killing a Process Using Kill
This is the default way of terminating a target process on Linux. The kill command follows the following command structure:
For example, to send SIGTERM to a process, the command would look like this:
Similarly, if you want to send SIGKILL, then use the following command:
Learn more about the Linux kill command with in-depth explanations and examples.
Killing Multiple Processes Using Killall
The killall command acts similar to kill. However, instead of defining a specific PID, it uses the process name and sends the specified termination signal to all processes that match the name.
The command structure of killall looks like this:
For example, the following killall command will send SIGTERM to all the running Firefox processes:
Check out this guide on the Linux killall command for detailed explanations with examples. It’s also recommended to check out the man page of killall:
Killing Multiple Processes Using pkill
Similar to the killall command, pkill can also lookup processes based on the name and send the specified termination signal. The command structure is almost similar as well;
For example, use the following pkill command to terminate the Firefox process with SIGTERM:
As always, check the man page of pkill for in-depth explanations with all the nuances:
Final Thoughts
This guide showcases various ways of killing a process by its PID. It also demonstrates alternative methods using the process name instead of PID. It’s always better to have multiple tools at your disposal. Here, we used ps and pgrep commands to find the PID and kill, pkill, and killall commands for killing processes.
In many situations, you may want to get rid of pesky background processes that are malfunctioning. Learn more about identifying background processes in Linux. Then, following the methods in this guide, you can easily get rid of unwanted ones.
Happy computing!
About the author
Sidratul Muntaha
Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.
On Linux, there are commands to view processes running on your system. A process is any ongoing event being managed by the kernel. A process is spawned when you launch an application, but there are also many other processes running in the background of your computer, including programs to keep your system time accurate, to monitor for new filesystems, to index files, and more. The utilities, such as those included in the procps-ng package, that monitor these processes tend to be intentionally generic. They look at all processes on your computer so you can filter the list based on what you need to know.
On Linux, you can view processes with the ps command. It is the simplest way to view the running processes on your system.
You can use the ps command to view running Java processes on a system also by piping output to grep .
OpenJDK, however, has its very own specific process monitor. The Java Virtual Machine Process Status (jps) tool allows you to scan for each running instance of the Java Virtual Machine (JVM) on your system.
To view a similar output as seen in the ps command, use the -v option. This is useful, partly because it requires less typing.
The default jps output provides the process identifier and the class name or Jar file name of each detected instance.
- What is enterprise Java programming?
- Red Hat build of OpenJDK
- Java cheat sheet
- Free online course: Developing cloud-native applications with microservices architectures
- Fresh Java articles
Note: The man page for jps states that it is experimental and unsupported. Still, it’s a nice-to-have option because often many processes are running on a system, and having a quick way to identify only Java is useful.
Because Java is still a popular language today, being familiar with the Java Development Kit and Runtime Environment remains important. They contain many tools applicable to the development and maintenance of Java applications.
Install Java manually on Linux
Manual installation provides the user with the highest level of control over the Java runtime environment.
1 Comment
It’s funny, we have something similar we use to monitor our java microservices, output looks like. big difference for us is the inclusion of the port that the service is listening on.
One of the biggest draws of Linux as a powerful OS ecosystem is its speed out of the box, but it’s always beneficial to further speed up your Linux PC. Below are multiple elements that factor into your system’s speed capabilities and some great ways to speed things up.
Thread Scheduling
Initially, Linux used a simple scheduling algorithm to handle tasks in a circular fashion. Since its creation, Linux has consistently improved its thread scheduling, culminating in a highly advanced and scalable design called the Completely Fair Scheduler.
CFS uses virtual run-time to decide which tasks need executing. In addition to this, a red-black, self-balancing tree of scheduled tasks is kept to manage tasks more efficiently than a run queue.
Advanced Filesystems
Linux makes use of surprisingly advanced filesystem designs relative to other OS market contenders. Ever since the introduction of the Ext filesystem’s third iteration, Ext3, Linux has benefited from journaling capabilities, effectively preventing filesystem corruption in the case of a failed file transfer or power outage.
Ext4 further extends Ext3’s functionality to accommodate much larger files and allow for unlimited subdirectories at high access speeds.
Speaking of speed, here are a few ways you can seriously boost the speed of your Linux system.
An easy starting place for boosting your computer’s performance is always at the start. There are a few key approaches to this, and they center on the following optimizations. (We’ll use Ubuntu as our example below.)
1. Speed Up Linux Boot by Reducing the Grub Time
If your Linux system is using Grub as the bootloader, you will find that it will display the GRUB bootloader for anywhere from ten to thirty seconds. Do you know that you can trim the duration of the bootloader or even skip the countdown completely?
Fire up a terminal and open the “/etc/default/grub” file in your favourite text editor
Look for the GRUB_TIMEOUT variable. Replace the value associated with this variable to something like 5 or 3. Set it to 0 to disable the countdown. (The first entry will be selected by default.)
Save ( Ctrl + O ) and close the file ( Ctrl + X ), then run
for the change to take effect,
2. Reduce the Number of Startup Applications
Each Linux distro poses slight variations to the process of managing startup applications, but the general premise is the same.
In Ubuntu, handling startup applications is as easy as opening an application named “Startup Applications” and going over its contents with a fine-tooth comb.
Just click on anything recognizable that seems unnecessary to load every time you boot up your system. Clicking “Remove” immediately removes the option you’ve selected with no confirmation message. If you’re unsure of your selection, you can simply remove the checkmark next to the option instead.
3. Check for Unnecessary System Services
Keep in mind that not all of the applications your machine runs at startup are immediately visible without running the following special command from your terminal first:
Once done, you’ll see quite a lot more in Startup Applications than you did before, including system services. You can change these as needed.
4. Change Your Desktop Environment
Another easy speed improvement you can implement comes from optimizing your desktop environment. This option carries with it a number of overt interface changes as well, so it might not be suitable if you like your current setup. If you’re up for a change and a speed increase, then this could work very well indeed.
There are a few desktop environment options available that deliberately emphasize speed above other factors.
Xfce is designed to be lightweight and speed-optimized. Multi-touch capabilities and ample customization options make this a suitable desktop environment even for aesthetic purposes.
To install this desktop environment in Ubuntu, enter the following in your terminal:
Then, log out of your user session and select the new desktop option before logging back in.
Another largely speed-focused desktop environment, LXDE or “Lightweight X11 Desktop Environment,” is designed to be modular, allowing its individual components to be added to your system instead of installing the entire thing in one go.
Installing LXDE in Ubuntu is as easy as entering the following in your terminal:
Follow the same procedure as you would for Xfce (logout and select it) to activate it.
This environment’s modular design highlights another speed-boosting option connected to your system’s UI.
5. Cut Down on Swappiness
This speed improvement tactic focuses on how Linux makes use of active memory. Typically, use of a swap partition on your hard drive is handled automatically with a rather high setting. Termed “swappiness,” this setting can range from 0 to 100 and comes preconfigured at 60.
The default of 60 is usually far more aggressive a setting than most users require, and lowering it helps your machine better utilize its own resources.
Reducing swappiness is as easy as typing the following in your terminal to access “sysctl.conf”:
Then, append the following to the bottom of the file and close it:
Reboot and enjoy the speed boost.
The tips we’ve covered here are definitely worth a try if you’re looking to speed up your Linux machine. Any of them in isolation or all of them combined can help speed up your system, saving resources for the tasks that matter most to you. Give them a try and get things done much faster.
Our latest tutorials delivered straight to your inbox
- Tweet
Popular Posts
How to Copy and Paste Text, Files and Folders in Linux Terminal
7 Useful Cron Alternatives For Linux
How to Fix Ubuntu Can’t Open the Terminal Issue
How to Change the Keyboard Layout in Linux
How to Build and Install a Custom Kernel on Ubuntu
8 of the Best Linux Distros for Windows Users
How to Add Your Own Custom Color in LibreOffice
The Beginner’s Guide to Using Cron in Linux
How to Check Sudo History in Linux
The Beginner’s Guide to Git
Affiliate Disclosure: Make Tech Easier may earn commission on products purchased through our links, which supports the work we do for our readers.