Search The Hostwinds Guides Knowledge Base

Common Commands (CentOS 7)

Share This Article

Common commands for CentOS 7 specific Operating Systems are below

 

Basic Configuration

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Query or System Locale
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
localectl
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Display the Current Time and Date
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
date
timedatectl
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Sync Date and Time
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
timedatectl
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure SSH
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/ssh/ssh_config
/etc/ssh/sshd_config
[/column]
[/row]

 

Jobs and Services

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
List all Services
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl -at service
ls /etc/systemd/system/*.service
ls /usr/lib/systemd/system/*.service
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
List Services that are Running
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl -t service –state=active
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Start and Stop services. Replace <service> with the name of the service
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl start <service>
systemctl stop <service>
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Enable and Disable Services. Replace <service> with the name of the service
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl enable <service>
systemctl disable <service>
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Check Service Status. Replace <service> with the service name
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl status <service>
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
See if a Service is Enabled. Replace <service> with the service name
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
systemctl is-enabled <service>
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Logs
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/rsyslog.conf
/etc/rsyslog.d/*.conf
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Logs
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/var/log
journalctl
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Find Files
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
find
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Create Archive
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
tar
cpio
[/column]
[/row]

 

Kernel, Boot, Hardware

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Single user Rescue Mode
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
append rd.break or init=/bin/bash to kernel cmdline
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Power Off System
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
poweroff
systemctl poweroff
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Halt System
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
halt
systemctl halt
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Reboot System
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
reboot
systemctl reboot
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure GRUB
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/default/grub
grub2-mkconfig
grub-set-default
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Kernel Parameters
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
sysctl -a
cat /proc/cmdline
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Load Kernel Module
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
modprobe
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Kernel Version
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
rpm -q kernel
uname -r
[/column]
[/row]

 

Software Management

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Install Software
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
yum install
yum group install
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Software Info
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
yum info
yum group info
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Update Software
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
yum update
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Upgrade Software
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
yum upgrade
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Software Repositories
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/yum.repos.d/*.repo
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Find Package Owning File
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
rpm -qf filename
yum provides filename-glob
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Software Version
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
rpm -q packagename
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Installed Software
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
rpm -qa
yum list installed
[/column]
[/row]

 

User Management

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Create User
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
useradd
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Delete User
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
userdel
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View or Change User Details
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
usermod
/etc/passwd
vipw
id
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Create User Group
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
groupadd
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Delete User Group
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
groupdel
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Group Details
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
groupmod
/etc/group
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change User Password
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
passwd
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change User Permissions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
usermod
visudo
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Group Permissions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
groupmod
visudo
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Password Policy
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
chage
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View User Sessions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
w
[/column]
[/row]

 

File Systems, Volumes and Disks

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Create / Modify Disk Permissions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
fdisk
gdisk
parted
ssm create
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Format Disk Partitions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
mkswap
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Defragment Disk Space
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
fsck
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Mount Storage
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
mount
/etc/fstab
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Mount and Activate Swap
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/fstab
swapon -a
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Free Disk Space
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
df
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Check or Repair File System
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
fsck
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change File Permissions
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
chmod
chown
chgrp
umask
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change File Attributes
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
chattr
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Access Control List
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
setfacl
[/column]
[/row]

 

Networking

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Name Resolution
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/hosts
/etc/resolv.conf
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Hostname
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
hostnamectl
/etc/hostname
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Network Interface Information
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
ip addr
teamdctl
bridge
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Routes
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
ip route
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Routes
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
ip route add
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Firewall
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
firewall-cmd
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Ports / Sockets
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
ss
lsof
[/column]
[/row]

 

Security and Identity

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Configure Security System
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
/etc/selinux/config
chcon
restorecon
semanage
setsebool
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
LDAP, SSSD
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
authconfig
authconfig-tui
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Network Users
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
getent
[/column]
[/row]

 

Resource Management

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Process Priority
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
nice
renice
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Change Process Run Location
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
taskset
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
Kill a Process
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
kill
pkill
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View System Usage
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
top
ps
ss
vmstat
[/column]
[/row]

 

[row]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
View Disk Usage
[/column]
[column lg=”6″ md=”12″ sm=”12″ xs=”12″ ]
df
[/column]
[/row]

 

Related Articles