Open In App

Basic CentOS Linux Commands in linux

Last Updated : 26 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

CentOS is a free and open-source operating system that aims to provide a stable reliable, and community-supported platform for servers and other enterprise applications.

In this article, we will be covering CentOS Linux basics commands and functions of CentOS and also we will look into the advanced commands. These CentOS commands allow you to manage files and directories perform system tasks, and troubleshoot problems.

What is CentOS Linux?

It is a Linux distribution Operating system that aims to provide a free, enterprise-class, community-supported computing platform. It is functionally compatible with its upstream source, Red Hat Enterprise Linux (RHEL).

Why Choose CentOS Linux?

CentOS, a Community Enterprise Operating System, is a popular server choice due to its stability, reliability, and free availability. Based on Red Hat Enterprise Linux (RHEL), CentOS offers robust performance and is widely used for hosting, databases, and as a general-purpose server operating system.

CentOS is known for its long-term support, security, and compatibility with enterprise-level environments, making it a preferred choice for businesses and developers who require a stable and secure Linux distribution.

Basic CentOS Commands and Their Functions

CentOS, like any Linux distribution, comes with a powerful set of command-line tools. Understanding these commands is crucial for system administration and troubleshooting. Here are some essential CentOS commands:

Added mkdir , rmdir , touch and cat commands in one go . Please focus on ls after each command It will give you insights :

Screenshot-2023-12-12-at-82141-PM

mkdir , rmdir , touch and cat commands in one go

File archiving in CentOS :

Screenshot-2023-12-12-at-82644-PM

file archiving command this will give gfg.tar file

Upgrading Packages in centOs :

Screenshot-2023-12-12-at-83312-PM

yum check-update will update the package database to make you have latest pacakes and dependencies installed

ls: Lists directory contents. Example: ls -l lists files with detailed information.

Screenshot-2023-12-10-at-100807-AM

cd: Changes the current directory. Example: cd /home moves to the home directory.

Screenshot-2023-12-10-at-101126-AM

cd/home to home directory (Inside Home Directory)

pwd: Displays the current directory path.

Screenshot-2023-12-10-at-101357-AM

cp: Copies files and directories. Example: cp file1.txt file2.txt copies file1.txt to file2.txt.

Screenshot-2023-12-10-at-101836-AM

rm: Removes files or directories. Example: rm file.txt deletes file.txt.

Screenshot-2023-12-10-at-102009-AM

mkdir: Creates a new directory.

rmdir: Removes empty directories.

touch: Creates an empty file or updates the timestamp of an existing file.

cat: Concatenates and displays file content. (Below all commands in single terminal)

Screenshot-2023-12-10-at-102245-AM

mkdir ,rmdir , cat , touch commands in one go

These commands form the foundation of daily operations in a CentOS environment, helping users manage files, navigate directories, and perform basic system tasks.

Advanced CentOS Commands

Beyond basic file and directory management, CentOS offers a range of advanced commands for system administration and configuration. Some of these include:

  • grep: Searches text using patterns. Example: grep ‘text’ filename searches for ‘text’ in the specified file.
  • find: Searches for files in a directory hierarchy.
  • tar: Archives files. Example: tar -cvf archive.tar folder/ creates an archive of a folder.
  • chmod: Changes file access permissions.
  • chown: Changes file owner and group.
  • ps: Displays information about running processes.
  • kill: Sends a signal to a process, typically to stop the process.
  • top: Displays real-time information about running processes.
  • df: Shows disk space usage.
  • du: Estimates file space usage.
Screenshot-2023-12-10-at-102821-AM

top command output

kill , find , vim, cat, chmod command

Screenshot-2023-12-10-at-103036-AM

kill , find , vim, cat, chmod command

Practical Examples and Use Cases of CentOS Commands

Let’s explore some practical examples and use cases of CentOS commands:

  • System Update: Use sudo yum update to update all installed packages to their latest versions.
  • Network Configuration: The ifconfig or ip addr command can be used to configure or display network interface parameters.
  • File Compression: Compress files using gzip filename or create compressed archives with tar -czvf archive.tar.gz folder/.
  • User Management: Add a new user with useradd username or modify user information with usermod.
  • Monitoring Disk Usage: Use df -h to check disk space and du -sh to check the size of a directory.
  • Process Management: Identify running processes with ps aux and terminate a process using kill -9 PID.
Screenshot-2023-12-10-at-103602-AM

top,du ,ifconfig,useradd ,tar

Screenshot-2023-12-10-at-103749-AM

ifconfig(For network config changes)

These examples illustrate how CentOS commands are applied in real-world scenarios, from system maintenance to resource monitoring and user management.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads