Show Menu
Cheatography

Red Hat Cheat Sheet by

Services

systemctl list-u­nit­-files -at service
Lists enable­d/d­isabled service unit files.
systemctl list-units -at service
Lists enable­d/d­isabled running services.
systemctl list-units -t service --state running
Shows active running services.
-t
Shows enabled service unit files.
-a
Shows both enabled and disabled service unit files.
systemctl mask [service name]
Prevents service from starting.

Cron

/var/s­poo­l/c­ron­/[user]
User cron jobs.
/etc/c­ron.d
System cron jobs.
[minute 0-59] [hour] [day of the month] [month of the year] [day of the week] [path of script]
Cron job time format.
cronta­b-g­ene­rat­or.org
Crontab generator.
0 1 *
Runs job everyday at 1 a.m.
0 1 * [user]
Format for system wide cron jobs.
/etc/a­t.allow
Allow access to the AT services.
/etc/c­ron.allow
Allow access to cron services.
/etc/a­t.deny
/etc/c­ron.deny
An empty deny file means nobody is denied.
An empty allow file means nobody is allowed.
If both are missing nobody is allowed.
Root always has access.

RPM

rpm -qa
Queries all installed packages.
rpm -qa | sort
rpm -qi [package]
Shows inform­ation about the package.
rpm -qa Group=­"­System Enviro­nme­nt/­She­lls­"
rpm --qa -last
Shows packages install sorted by date
rpm -ql yum
Queries for list of file paths.
rpm -qc yum
rpm -qf [path to file]
Query file.
rpm -qdf [path to file]
Shows all docume­ntation for specified comman­d/file.
rpm -q --provide
rpm -q --requires [file]
rpm -q --chan­gelog [file]
Shows changes to package.

SELinux

Enforcing mode
Security policy is enforced.
Permissive mode
Security policy is observed and warnings are printed but policy is not enforced.
Disabled
Mandatory access control if turned off.
sestatus
Shows SELinux status.
set setenforce <mo­de>
Tempor­arily changes SELinux mode.
vi /selin­ux/­config
SELinux config file.
 

Networking

nmtui
graphical network editor

Logs

less -N /etc/r­sys­log.conf
View rsyslog config­uration file with line numbering turned on.
cat /var/l­og/­mes­sages
Lists messages log.
grep -v 'systemd:' /var/l­og/­mes­sages
Lists everything that does not include systemd.
tail -f /var/l­og/­mes­sages
Follows log file.
/var/l­og/­secure
Private authen­tic­ation messages (logins)
/etc/c­ron.daily
Logrotate cron job.
/etc/l­ogr­ota­te.conf
Logrotate config­uration file.
logger "­mes­sag­e"
Writes message to messages log file.

yum

yum --show­dup­licates -list [pacakge name]
Shows versions of a package.
yum list installed
Lists all packages installed.
Bold
Update available in reposi­tory.
Bold and underline
Current kernel
Red
Package doesn't exist in reposi­tory.
Yellow
Newer package then in reposi­tory.
yum list updates
Lists updates for packages installed.
yum list available
yum info [package name]
Shows package info.
yum deplist [package name]
Shows depend­encies for package.
yum search [package name]
Searches for package name.
yum reinstall [package name]
Reinst­alled package.
yum reinstall --skip­-broken [package name]
yum remove [package name]
Removes package.
yum autoremove [package name]
Removes packages including depend­encies.
yum packag­e-c­leanup
Shows unused packages.
yum install yum-utils
yum check-­update
Checks for updates.
yum list obsoletes
yum install yum-pl­ugi­n-v­ers­ionlock
yum versio­nlock [package name]
Prevents package from updating.
yum versio­nlock
Lists version locked packages.
yum versio­nlock delete [output from yum versio­nlock]
Removes version lock from package.
yum update --security
Only updates security packages.
yum update­-mi­nimal --security
Install strictly security updates. Doesn't include bug fixes.
yum install yum-plugin changelog
View package change logs.
yum changelog updates
Gets all change logs for packages with updates.
yum changelog [package name]
View change log for specific package.
yum list installed kernel-*
Lists currently installed kernel.
ls -l /boot
Kernel directory.
uname -r
Shows running kernel.
yum list available kernel
Lists available kernel.
yum -y update kernel
Updates kernel.
yum remove kernel
grub2-­set­-de­fault [kernel number]
Changes kernel.
ls /lib/m­odu­les­/$(­uname -r)/kernel
Lists kernel module directory.
lsmod
Lists modules.
 

Time

timeda­tectl
Lists local time for current timezone.
timeda­tectl list-t­ime­zones | grep America
Filters timezones via grep.
timeda­tectl set-ti­mezone [timezone]
Sets timezone.
timeda­tectl set-time 24:00:00
Manually sets time.
timeda­tectl set-time 2018-12-30
Manually sets date.
timeda­tectl set-ntp true
Enables NTP.
systemctl restart system­d-t­ime­dated
Restarts NTP service.
yum install ntp
Installs NTP client.
/etc/n­tp.conf
NTP config file.
ntpdate -q <server addres­s>
Checks NTP server address.
ntpdate <server addres­s>
Sets NTP server.
systemctl enable ntpdate
Enables NTP synchr­oni­zation.

Journal

journalctl
Lists all journal entries.
journalctl /sbin/­crond
Specifies journal.
journalctl -f
Tails journal.
mkdir /var/l­og/­journal
Directory for persistent journals.

File Access Control

ls -l [file name]
Lists group owners.
The user-owner is the third column from the left. THe group-­owner is the fourth column.
Read (r)
4
Write (w)
2
Execute (x)
1
-rw-rw-r--
--user­own­er-­gro­upo­wne­r-other
chmod u=rwx,­g=rx,o= <fi­le>
Symbolic permission format.
chmod u+rwx <fi­le>
Adds permis­sions format.
chmod o-x <fi­le>
Remove permis­sions format.
chmod a-x <fi­le>
Removes execute from all positions.
-R
Recurs­ively adds permis­sions.
umask
View umask.
umask -S
View umask in symbolic notation.
775
Default directory permis­sions.
rwxrwxrwx
755
rwx-r-xr-x
664
Default file permis­sions. (umask 002)
rw-rw-r--
umask 022
Changes umask.
umask 002
rw-rw-r--
Direct­ories- rwx-r-­xr-x, Files- rwxr--r--
vi ~/bashrc
User umask startup file
add new umask to end of file.
vi /etc/p­rof­ile.d/­unm­ash.sh
System wide unmask.
if [ "­$UI­D" -ge 1000] ;then
getfacl <fi­le>
lists ACLs on file.
-t
setfacl -m user:<­use­r>:­<pe­rmi­ssi­ons> aclfile
Sets ACLs on file.
setfacl -m user:r­oot:rwx /home/­fil­e.txt
setfacl -m group:­<gr­oup­>:<­per­mis­sio­n> <fi­le>
setfacl -x group:root <fi­le/­dir>
 
-x remove specific ACL, -k removes all default ACLs, -b removes all ACLs
       
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet