0% found this document useful (0 votes)
3 views5 pages

CentOS Commands

This document is a comprehensive guide for system and network administrators on CentOS commands, organized from basic to advanced levels. It includes detailed descriptions, syntax, and examples for various command categories such as file management, user management, process management, network administration, disk management, package management, firewall management, and service management. The guide serves as a valuable resource for efficiently managing Linux systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

CentOS Commands

This document is a comprehensive guide for system and network administrators on CentOS commands, organized from basic to advanced levels. It includes detailed descriptions, syntax, and examples for various command categories such as file management, user management, process management, network administration, disk management, package management, firewall management, and service management. The guide serves as a valuable resource for efficiently managing Linux systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CentOS Commands Notes for System and Network Administrators

This document provides a detailed and comprehensive guide to Linux commands for CentOS,
organized from basic to advanced, tailored for system administrators and network administrators.
Each command includes its description, syntax, and examples.

1. Basic Commands

File and Directory Management

Command Description Syntax Example

ls Lists files and directories ls [options] [path] ls -l /var/log

cd Changes the current directory cd [directory] cd /etc

pwd Prints the current working pwd pwd


directory

mkdir Creates a new directory mkdir mkdir /backup


[directory_name]

rmdir Removes empty directories rmdir rmdir /backup


[directory_name]

rm Removes files or directories rm [options] [file/dir] rm -rf /tmp/testdir

cp Copies files or directories cp [source] cp /etc/fstab


[destination] /backup/fstab.bak

mv Moves or renames files or mv [source] mv /tmp/test.txt


directories [destination] /home/user/test.txt

find Searches for files in a find [path] [options] find /var -name '*.log'
directory hierarchy

touch Creates an empty file or touch [file] touch /tmp/newfile


updates its timestamp

stat Displays detailed information stat [file] stat /etc/passwd


about a file

cat Displays file content cat [file] cat /etc/hosts

less Displays file content one page less [file] less /var/log/messages
at a time

head Displays the first few lines of a head [options] [file] head -n 10
file /var/log/messages

tail Displays the last few lines of a tail [options] [file] tail -f /var/log/messages
file

2. User Management
Command Description Syntax Example

whoami Displays the current logged-in whoami whoami


user

id Displays user ID and group id [username] id root


information

adduser Adds a new user adduser [username] adduser admin

passwd Changes the user password passwd [username] passwd admin

usermod Modifies user account settings usermod [options] usermod -aG wheel
[username] admin

userdel Deletes a user userdel [username] userdel testuser

groups Displays groups a user belongs groups [username] groups admin


to

su Switches to another user su [username] su root

sudo Executes commands with root sudo [command] sudo yum update
privileges

3. File Permissions and Ownership

Command Description Syntax Example

chmod Changes file permissions chmod [permissions] chmod 755 script.sh


[file]

chown Changes ownership of a file or chown [user:group] chown admin:admin


directory [file] file.txt

chgrp Changes group ownership of a file chgrp [group] [file] chgrp developers
or directory file.txt

umask Sets default permissions for new umask [permissions] umask 022
files

4. Process Management

Command Description Syntax Example

ps Displays active processes ps [options] ps aux

top Shows dynamic real-time processes top top

htop Interactive process viewer (install htop htop


required)

kill Terminates a process by PID kill [PID] kill 1234


killall Terminates processes by name killall [process_name] killall httpd

nice Sets process priority nice [priority] nice -n 10


[command] ./long_task.sh

renice Changes priority of a running renice [priority] [PID] renice 15 1234


process

bg Resumes a suspended job in the bg [job_id] bg 1


background

fg Brings a background job to the fg [job_id] fg 1


foreground

5. Network Administration

Command Description Syntax Example

ip Displays and configures IP ip [options] ip addr show


addresses and routes

ifconfig Legacy network configuration ifconfig ifconfig eth0


tool [interface]

ping Tests connectivity to a host ping [options] ping google.com


[hostname]

traceroute Displays route packets take to traceroute traceroute google.com


a host [hostname]

netstat Displays network connections netstat [options] netstat -tuln

ss Displays network connections ss [options] ss -tuln


(recommended)

curl Transfers data from or to a curl [options] curl https://example.com


server [URL]

wget Downloads files from the wget [options] wget


internet [URL] https://example.com/file.tar.gz

nmcli Configures NetworkManager nmcli [options] nmcli device status

6. Disk Management

Command Description Syntax Example

df Displays disk usage df [options] df -h

du Displays directory or file size du [options] [path] du -sh /var/log

mount Mounts a filesystem mount [options] mount /dev/sda1


[device] /mnt
umount Unmounts a filesystem umount [mount_point] umount /mnt

lsblk Lists block devices lsblk lsblk

blkid Displays information about block blkid [device] blkid /dev/sda1


devices

parted Manages disk partitions parted [device] parted /dev/sda

fdisk Interactive disk partitioning tool fdisk [device] fdisk /dev/sda

7. Package Management

Command Description Syntax Example

yum Installs, updates, and removes yum [options] yum install httpd
packages [package]

dnf Modern replacement for yum dnf [options] dnf install nginx
[package]

rpm Manages RPM packages rpm [options] rpm -ivh


[package] package.rpm

8. Firewall Management

Command Description Syntax Example

firewall-cmd Configures firewalld firewall-cmd [options] firewall-cmd --add-


(used for dynamic port=8080/tcp --permanent
firewall
management)

iptables Legacy firewall iptables [options] iptables -L


configuration tool

nft Manages rules using nft [options] nft list ruleset


nftables (modern
replacement for
iptables)

ufw Simple firewall ufw [options] ufw allow 22


management tool
(must be installed)

firewall-cmd Reloads firewalld to firewall-cmd --reload firewall-cmd --reload


--reload apply changes

firewall-cmd Lists all active firewall firewall-cmd --list-all firewall-cmd --list-all


--list-all rules
firewall-cmd Adds a service to the firewall-cmd --add- firewall-cmd --add-
--add- firewall (e.g., http, service=http --permanent service=http --permanent &&
service https) firewall-cmd --reload

iptables- Saves the current iptables-save > iptables-save >


save iptables configuration /etc/sysconfig/iptables /etc/sysconfig/iptables
to a file

iptables- Restores iptables iptables-restore < iptables-restore <


restore configuration from a /etc/sysconfig/iptables /etc/sysconfig/iptables
file

9. Service Management

Command Description Syntax Example

systemctl Controls the systemd services systemctl [options] systemctl start


and units [service] httpd

systemctl start Starts a specified service systemctl start systemctl start


[service] nginx

systemctl stop Stops a specified service systemctl stop systemctl stop


[service] nginx

systemctl Restarts a specified service systemctl restart systemctl restart


restart [service] sshd

systemctl reload Reloads the configuration of a systemctl reload systemctl reload


service [service] httpd

systemctl status Displays the status of a service systemctl status systemctl status
[service] mariadb

systemctl Enables a service to start at boot systemctl enable systemctl enable


enable [service] firewalld

systemctl Disables a service from starting systemctl disable systemctl disable


disable at boot [service] firewalld

systemctl is- Checks if a service is active systemctl is-active systemctl is-active


active [service] httpd

systemctl is- Checks if a service is enabled at systemctl is-enabled systemctl is-


enabled boot [service] enabled sshd

journalctl Views logs managed by systemd journalctl [options] journalctl -u nginx

chkconfig Legacy tool for managing chkconfig [options] chkconfig --list


services at run levels [service]

service Legacy command to manage service [service] service httpd


system services [action] restart

You might also like