Skip to content

Linux command line for beginners (Part 2)

Introduction (repeated from Part 1)

If you are new to Linux, you have to know that a lot of configuration can and should be done through a terminal. On most modern Linux distributions like Ubuntu, Mint or Debian you can avoid to use any command line program at all, but more often than not you will find solutions on the Internet that should what to type into the console to fix a problem.

Here are a few commands you should learn to get comfortable with the terminal without breaking things or damaging your computer.

This guide is separated into 3 parts for easier reading.

Part 1: Files and directories

Part 2: System information

Part 3: Network

So, fire up your terminal (start with a mouse click or press Ctrl-Alt-T to open a terminal window) and just follow this guide.

2. System information

2.1. Show processes: ps

Simply enter

ps

to show the processes currently running. You will get an output like this:

user@linux $ ps
 PID TTY TIME CMD
 18301 pts/1 0:00 bash
 18901 pts/1 0:00 ps

The most important information here is PID and CMD. CMD is the name of the process, PID is the Process ID, which is needed to uniquely identify any process. You will also need this PID for other commands later.

This is only a snapshot of the running processes, so if you need live updates, check out the next command.

 

2.2. Display top CPU processes: top

top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes.

[from: linux.about.com]

This is one of the most useful tools in Linux, because it is interactive. You can type

h

to display a help screen with a brief summary of commands.

 

2.3 Close a process: kill

After you gathered the PID of the process you want to close, you can enter

kill 76821

or whatever your PID is. This will close the process.

Info: Technically, you are sending a ‘kill signal’ to the process. There are also other signals, but you usually will not need those.

Pro tip: Use

pkill -x process1

to kill a process by name (here: ‘process1’). Do not forget the parameter -x, or every process containing the name will be closed.

Published inTechnology

Be First to Comment

Leave a Reply

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