decorative image for blog showing centos cheat sheet
October 29, 2020

CentOS Commands Cheat Sheet

Operating Systems
Development

If you're just getting started with CentOS, learning the commands and tools is a big help in increasing your productivity. In this blog, we go over some of the most useful CentOS commands and tools as chosen by our enterprise architects, then provide a list of common commands.

Back to top

Most Useful CentOS Commands and Tools

There are lots of commands when it comes to CentOS and any tool that saves time and provides utility is a welcome addition to any person’s tool kit.

We asked several of our enterprise architects on the team what their favorite tools and commands were and here are some of the results:

1. top

The command top displays a list of processes or threads currently being used by the system kernel. This is useful for telling if something is holding up your systems resources. Summary is the first portion you’ll see followed by the fields and columns header and then the task area. You would use this to determine if a process is hung or hogging all the resources of your system prior to simply killing a pid at random.

2. nmap

Have you ever wondered from a networking perspective, what ports were open on various nodes of your network? Nmap allows you to quickly scan networks for open ports, application version information, running services, what operating system and version, what type of packet filters and firewalls are in use, and plenty of other useful and sensitive information. By listing information such as what ports are open, you can then seal the gaps in your security plan by closing those ports if possible. Nmap is a robust tool and the man pages are a highly recommended read to understand all the options and features available.

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

Have you ever wondered the easiest way to find all the files associated with a particular package? These two commands will show all the files and their location of the package named. Rpm is for RHEL/CentOS and dpkg is for Debian based systems.

4. sosreport

One of the commands we frequently have our customers run during break/fix issues is sosreport. It creates an archive of config and diagnostic data from the system to be used for debugging and troubleshooting later. Can be used with xsos, a tool used to read the reports generated by sosreport.  

5. lsmod

This command arranges and formats the output of modules in /proc/modules and any kernel modules that are currently loaded.

6.tcpdump

An incredibly useful tool that allows you to examine the content of packets on a network interface matching a Boolean expression. This includes such information as handshakes between two devices, logins to sites, server traffic, UDP traffic, requests to printers, but more importantly it can detect traffic going to sketchy destinations or from unknown sources. Has a GUI version known as Wireshark.

 

See the Top CentOS Alternatives

Decision Maker's Guide to Enterprise Linux — Tile Image

With CentOS 7 left as the only community-supported CentOS version, many teams are looking for their next Enterprise Linux distribution. In our 2022 Decision Maker's Guide to Enterprise Linux, our experts look at the top distributions available today, and which ones will provide the most stable and dependable experience going forward.

Grab Your Free Copy

Back to top

Commonly-Used CentOS Commands

While our list above is useful, there are many more commonly-used CentOS commands for Linux that you should keep close by. Here are some that make working from the command line a lot easier.

 
Directory Movement

CentOS Command

Description

ls

lists the contents of the directory

cp

copies a file

mv

moves a directory

cd ..

moves up one directory

cd ~

moves to home directory

ll

lists the contents of the directory length-wise

pwd

present working directory

find

search given directory for namestring and display it

 
User Management

CentOS Command

Description

alias

creates an alias

passwrd

updates user authentication

useradd

adds a new user

sudo

admin privileges

who

shows currently logged on users

groupadd

create new group

uname

print system info

 
File Management

CentOS Command

Description

chmod

change permissions of a file

chown

change the ownership of a file

diff

compare the ownership of a file

diff

compare two files against each other

du

displays disk usage of a directory

rm

removes files/directories

 
System Management

CentOS Command

Description

apropos

search set of database files and display result as standard output

bcwipe

repeatedly overwrite special patterns onto to-be-destroyed files

chkconfig

update and query run level info for system services

dstat

displays real-time system stats

fdisk

disk partioning utility

mount

mounts a filesystem

grep

search named input files for lines containing match to given pattern, then print

hostname

configure networking interface

ifdown

manually take down an interface

iftop

shows bandwidth usage of interface

ifup

brings interface back up

kill

terminate a running process

ps

list of currently running processes and their process IDs

man

manual page for particular command/tool

systemcl

may be used to introspect and control the state of the "systemd" system and service manager

tail

used to output last part of a file, useful on log files

Back to top

Download Our CentOS Commands Cheat Sheet

Want a one-page PDF version of the shortcuts above? Click the link below to download the cheat sheet!

Download Cheat Sheet

Back to top

Final Thoughts

In conclusion, CentOS is filled with tons of tools and utilities, the aforementioned are just among some of the many available. www.man7.org has manual pages for these, and many more commands and all the usable options that go along with them.

Need Support for Your CentOS Project?

OpenLogic offers groundbreaking CentOS support and services, including long-term support for CentOS 6 and CentOS 8. 

With OpenLogic's CentOS Linux support, you'll get:

  • 50% cost-savings.
  • Long-term support for EOL CentOS.
  • Backporting.
  • Guaranteed SLAs.
  • Architectural minimization.
  • Multi-platform support.
  • CentOS distributions.
  • Expert guidance.

Talk to an expert today to learn how we can help you with CentOS.

Talk to a CentOS ExpertGet a Free Consultation

 

Additional Resources

Back to top