Show Menu
Cheatography

Intro to System Administration Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

<BL­ANK­SPA­CE>­COMMAND

<bl­ank­spa­ce>­command
by having a leading space before a command, it will not show up in history.
If you were to have a leading space then this command echo "Not in histor­y" that will not show up in history.

journalctl

journalctl
displays all log entries.

dnf remove "­package name"

dnf remove "­package name"
by doing dnf remove "­package name" it removes it

systemctl restart

systemctl restart
restarts a specific service
example would be systemctl restart httpd where httpd is the name of the service to be restarted.

dnf search "­program name here"

dnf search "­program name here"
this finds a program and gives the code to install with dnf install.

systemctl reload­-or­-re­start

systemctl reload­-or­-re­start
best of both worlds, if you are unsure whether a program supports reload use this command to first try reload and if it fails it will restart.
systemctl reload­-or­-re­start httpd will first try to reload the program and if that is not doable it will restart.

chown <us­eri­d> /home/­userid/

chown <us­eri­d> /home/­userid/
changes the owner of the directory.

dig <ho­stname or ip>

dig <ho­stname or ip>
queries DNS servers and returns inform­ation about a domain.

TAIL -N5 FILENAME

tail -n5 <fi­len­ame­her­e>
gives the last 5 lines of the file.

du -a /dir/ | sort -n -r | head -n 20

du -a /dir/ | sort -n -r | head -n 20
shows file sizes in reverse order by biggest first in a specific directory.

crontab -a <fi­len­ame>

crontab -a <fi­len­ame>
Installs the specified filename as your chrontab file.
This chrontab file can be used to automate and schedule tasks.

alias name "­command here"

alias name "­command here"
creates an alias for a command that can be called.
Extremely useful for long commands.

ECHO "­TEX­THE­RE" > .hidde­nfile

echo "­tex­the­re" > .hidde­nfile
will write the string texthere to a new .hidde­nfile
Easy way to write one line into a file or directory without much fuss.

PS AUX

ps aux
shows all processes being run by everybody (most are being run by root)

MAN PS

man ps
gives you the man page for ps

PS

ps
shows all running processes

ssh userna­me@­ipa­ddr­esshere

ssh userna­me@­ipa­ddr­esshere
Allows you to remotely access another machine or server.

env

env
lists all the current enviro­nment variables

cmp <file 1> <file 2>

cmp <file 1> <file 2>
performs a byte by byte comparison of two files.

locate <fi­lename here>

locate <fi­lename here>
Finds a all indexed instances of a file.
Much faster than find!

SUDO !!

sudo !!
redoes the last command as root
Convenient if you always forget to make yourself root!
 

bg

bg
runs a process in the backgr­ound.
You can also add the <&> symbol to the end of a file name or command to accomplish the same thing.

/usr/s­bin­/tr­ace­route <ho­stname or ip here>

/usr/s­bin­/tr­ace­route <ho­stname or ip here>
tells you the route that packets take.
Very similar to ping, but goes into a little more detail.

HISTORY

history
prints the last 500 - 1000 commands

ip route del <ip here>

ip route del <ip here>
Deletes a created ip route, opposite of ip route add.

ifconfig

ifconfig
The “ifcowill display all the active interfaces details. The ifconfig command also used to check the assigned IP address of an server.
reminds me of ipconfig on windows, a little different.

systemctl reload

systemctl reload
similar to restart, however program will reload and reread config files without restar­ting.
systemctl reload httpd will reload and reread httpd's config files without a restart.

Downside is not all programs support reload!

tree

tree
displays files and direct­ories in their proper parent -> child relati­onship.
Gives an easy to read format for direct­ories and the files or direct­ories undern­eath. Think of the first assignment we did in class.

touch <fi­len­ame>

touch <fi­len­ame>
creates or edits a file by specified name.
If file doesn't exist it will create it!

systemctl enable

systemctl enable
allows or enables a process to start on startup

pip install <de­sired progra­m>

pip install <de­sired progra­m>
uses pip to install a program.
In our case we use pip install jupyte­rhub.

LS

LS
lists files in the current directory

CD ..

cd ..
go to the above or parent directory of the present directory
If direct­ories were like this Tree --> Branch --> Leaf and you were working in the "­Branch direct­ory­" by executing cd .. it would take you to the Tree directory.

CD

cd
change directory used as cd <di­rec­tor­yna­me>

DISOWN -A && EXIT

disown -a && exit
closes the terminal, but keeps all processes running.
Normally, when you close a terminal, all processes terminate due to a "­han­g-u­p" signal. Disown -a states to ignore the hang up signal and keep everything running while closing the terminal.

cp -r <di­rec­tor­yna­me> <ne­wdi­rec­tro­yna­me>

cp -r <di­rec­tor­yna­me> <ne­wdi­rec­tro­yna­me>
copies the directory recurs­ively with all files to the new name

pwd

pwd
gives the present working directory
will spit out the present working directory which will look like this Dylan/­Des­kto­p/Class

LS -A

ls -a
shows everything in the working directory! Even hidden files!
hidden files look like this .hidde­nfile

dnf upgrade

dnf upgrade
dnf package manager to update software on fedora

su

su
the same thing as sudo, makes you root.

efibootmgr -v

efibootmgr -v
shows the summary of the boot config­uration
efibootmgr can be used to change boot order, usually has to be run as root.
 

hwclock

hwclock
used to manage system clock.
hwclock --set --date 10/02/2019
sets clock date to 10/02/2019
Has to be run as sudo.

SUDO SHUTDOWN NOW

sudo shutdown now
properly shuts down the machine

tac <fi­len­ame­her­e>

tac <fi­len­ame­her­e>
prints out the last line of a file first.
Useful if you are looking for something recently added to a file (such as a new user.)

MKDIR

mkdir
stands for make directory, creates a folder

RM

rm
stands for remove (as in delete) a file or folder depending on user choice

arch

arch
displays machine archit­ecture and system inform­ation (hardware)

RM -R <DI­REC­TOR­YNA­MEH­ERE>

rm -r <di­rec­tor­yna­me>
allows one to properly delete a directory even if it has child direct­ories.

grep pattern files

grep pattern files
searches for patterns in files.
grep -r pattern dir
searches for patterns in files recurs­ively thru direct­ories.

gzip <fi­len­ame>

gzip <fi­len­ame>
compresses a file.
For example if file was named file and command gzip file was run it would make file.gz

HISTORY

history
shows the history of commands executed.
So if you typed cd Desktop , then ls , then cd Class , if you typed history it would show you executing cd Class, ls, cd Desktop.

systemctl get-de­fault

systemctl get-de­fault
To see the target the system boots into by default.

FC

fc
Opens the last command entered in editor (such as nano)
Useful for long commands that are messed up, opens last command in a text editor to fix.

ip route add <ip here> via <ga­teway router here>

ip route add <ip here> via <ga­teway router here>
These commands add a route to a specified network through the gateway router of choice.

find . -name *.pdf

find . -name *.pdf
finds all files in the current directory with a name that ends in the .pdf extension.
You can do find <name of direct­ory> with a -name

ping <ho­stname or ip here>

ping <ho­stname or ip here>
pings a website and returns if the packets were sent

grep -r "Find this line"

grep -r "Find this line"
searches the contents of files themselves for find this line.

systemctl edit httpd --full

systemctl edit httpd --full
allows you to edit the httpd system files, can change descri­ption etc.

systemctl status

systemctl status
give an overview of all the processes running within a program, some of the log files, etc.
Provides a nice overview with a bit of everyt­hing.

dnf install "code here"

dnf install "code here"
After doing a dnf search it will give you a code such as mc, you then do dnf install mc to get that program

systemctl is-active

systemctl is-active
see if a process is running or not.