CentOS command Cheat Sheet

In this blog, we will go through a comprehensive list of CentOS commands that everyone should know when using the system.

Updated: 14 Apr, 23 by Susith Nonis 7 Min

List of content you will read in this article:

If you're new to CentOS, mastering the commands and tools will go a long way toward enhancing your productivity. The blog is a compilation of nearly every important CentOS command that you need to work smoothly. But before jumping on that, let's brush up with the basics. 

Community Enterprise Operating System or CentOS is a free and open-source commercial operating system compatible with Red Hat Enterprise Linux (RHEL). Gregory Kurtzer founded centOS, and CentOS developers use the RHEL source code to create a product that is quite similar to RHEL.

CentOS is a development platform that is one of the best and most influential Linux distributions available. It's a community-driven free software project that aims to create a stable foundation for open source communities. It's versatile, as well as safe and durable. It also includes multiple corporate-level security updates, making it a fantastic solution for any application. Have a look at the benefits of using CentOS:

  • It virtualises using a Kernel-based Virtual Machine and gives maximum availability and performance.
  • CentOS has a committed developer community that keeps it up to date and guarantees compatibility with both new and old applications.
  • CentOS releases are revised on average every six months, and each release has a ten-year support period.
  • Red Hat's security team is adept at detecting threats and maintaining a high level of security. The Security-Enhanced Linux kernel addition is also included with CentOS.

Help Commands 

whatis

It is used to find concise descriptions of system commands by searching the Whatis database for entire words.

which

Displays full path to shell commands 

whereis

Search and discover command's binary, source, and man pages

apropos

Look for help and man pages containing specific phrases and instructions by searching a database of short descriptions.

man

Lists Manual pages for the respective command

File Operations

cat

Concatenate files or print a file on the monitor.

touch

Make a new file and modify the timestamps.

cp

Copy files or directories.

mv

Moves files or directories.

rm

Removes directories or files in a recursive manner 

ln

It is used for creating a symbolic or hard link for a file.

less

Viewing a single file on a single page, along with the ability to go backwards.

head

Printing the first ten lines of a file.

tail

Printing the last ten lines of a file.

wc

Counts the total number of words or characters there are in a file.

stat

Shows the status of a file or a file system.

cut

Remove parts of input lines.

paste

Combine multiple lines of text in a single file.

Process Management 

ps

Provide an update on existing procedures.

pstree

Displays a tree of processes.

top

Demonstrate real-time procedures.

kill

PID is used to terminate a process.

killall

Stop a process permanently via name

pkill

Looking up for processes or signals based on the same and other attributes.

pgrep

Look for information on the process.

ctrl+z

Stop the task instead of keeping it on halt permanently.

&

The addition of this after a command puts the process in the background.

jobs

Displays all the jobs running in process

Partitions and Disk Management 

df

Report on the amount of disc space used by the file system.

mount

Mount a file system or see what's mounted.

unmount

Unmounts a file system 

fuser

Identifies processes via files or sockets.

isof

Displays a list of the system's open files

Accounts and Security Admini­str­ation

groupadd

Used for creating new groups 

groupdel

Used for creating groups 

groupmod

Manipulating the description of a particular group

useradd

Creating new users 

userdel

Deleting new users 

usermod

Modifying a user’s account 

passwd

Updating a user’s password 

vipw

Editing the password or shadow password of a group 

vigr

Editing groups or shadow groups 

chage

Modifying password policies

Networking 

ifconfig

Set up the network interface.

route

Shows and manipulates IP routing table

ip

Replaces ifconfig, arp, and route by displaying and manipulating routing, devices, policies, and tunnels.

ifup

It brings up the network interfaces

ifdown

It brings the network interfaces down

ping

Sends ICMP ECHO_R­EQUEST to network hosts

Directory Operations 

clear

Removes all the contents from your screen 

pwd

Displays running directory on the screen 

cd

Modifies directories 

ls

Lists down all the content of a directory 

mkdir

Creates a new directory

rmdir

Deletes null directories

top

This command provides a list of processes or threads that the system kernel is currently using. This is important for determining if something is clogging up your system's resources. The first section you'll notice is a summary, followed by the fields and columns heading, and finally, the task area. You'd use this to see if a process is hung or using up all of your system's resources before keeping it on halt. 

Nmap

Nmap allows you to swiftly scan networks for open ports, application version information, and a variety of other important and sensitive data. You can close any gaps in your security plan by listing information such as what ports are open. Nmap is a powerful tool, and reading the man pages is a must to comprehend all of the choices and capabilities available fully.

rpm -ql <packagename> or dpkg -L <packagename>

These two commands are used to quickly locate all of the files connected with a specific package. It will display all of the files as well as the package name's location. Rpm is for RHEL/CentOS systems, while dpkg is for Debian systems.

sosreport

Sosreport is one of the scripts that our customers regularly use during break/fix issues. It creates a backup of the system's configuration and diagnostic data, which can be utilised for further debugging and troubleshooting. It's compatible with xsos, a software that reads the reports created by sosreport.

lsmod

This command organises and arranges the output of modules in /proc/modules as well as any presently loaded kernel modules.

Finally, CentOS comes with a plethora of other tools and utilities, and the ones mentioned earlier cover pretty much all the crucial and frequently-used ones. 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.