Show Menu
Cheatography

Adding a new blk device

1. Device discovery
follow dmesg, or fdisk -l, of lsblk. find location or new device in /dev/
2. format device to create partition
fdisk, gpart; several options.
3. create a file system for the newly made partition
mkfs -t ext4 /dev/sda*
4. create mount dir
mkdir mount directory
5. mount drive
mount /dev/sda mount directory*
6. add entry into fstab
try using blkid to find UUID, then add device with UUID to /etf/f­stab. UUID; mount point; FS type; options; backup infoma­tio­n(0); FS integrity test order

Process Signals

Signal
Portable Number
Default Action
Descri­ption
SIGHUP
1
Terminate
Hangup
SIGINT
2
Terminate
Terminal interrupt signal
SIGQUIT
3
Terminate (core dump)
Terminal quit signal
SIGILL
4
Terminate (core dump)
Illegal instru­ction
SIGTRAP
5
Terminate (core dump)
Trace/­bre­akpoint trap
SIGABRT
6
Termin­ate­(core dump)
Process Abort Signal
SIGFPE
8
Terminate (core dump)
Erroneous arithmetic operation
SIGKILL
9
Terminate
Kill (cannot be caught or ignored)
SIGSEGV
11
Terminate (core dump)
Invalid memory reference
SIGPIPE
13
Terminate
Write on a pipe with no one to read it
SIGALARM
14
Terminate
Alarm Clock
SIGTERM
15
Terminate
Termin­ation signal
 

Inode breakdown

Size of File
Size of the file
Device ID
UID
User ID
GID
Group ID
TIMESTAMPS
access, modify, change­(inode)
MODE
permis­sions
12 Direct Pointers
points to first 12 data blocks of the file
Indirect
points to a table of addresses for next blocks in a file
x2 Indirect
points to a series of tables with extrea data blocks,
x3 Indirect
same as above x3
 

systemctl

starting and stopping services
sudo systemctl start applic­ati­on.s­er­vice
sudo systemctl start applic­ation
systemctl looks for *.service already, not necessary to actually place in command.
sudo systemctl stop applic­ati­on.s­er­vice
rest­arting and reload­ing
sudo systemctl restart applic­ati­on.s­er­vice
fully restart srevice.
sudo systemctl reload applic­ati­on.s­er­vice
reload config files without restar­ting.
sudo systemctl reload­-or­-re­start applic­ati­on.s­er­vice
if unsure that it can reload, this will try reload first then restart.
Enabling and Disabling Services
sudo systemctl enable applic­ati­on.s­er­vice
creates a sym link from the system’s copy of the service file (usually in /lib/­sys­tem­d/s­ystem or /etc/­sys­tem­d/s­ystem) into the location on disk where systemd looks for autostart files.
sudo systemctl disable applic­ati­on.s­er­vice
removes sym link
Checking the Status of Services
systemctl status applic­ati­on.s­er­vice
This will provide you with the service state, the cgroup hierarchy, and the first few log lines.
systemctl is-active applic­ati­on.s­er­vice
This will return the current unit state, which is usually active or inactive. exit code 0 if true
systemctl is-enabled applic­ati­on.s­er­vice
This will output whether the service is enabled or disabled. Exit code 0 if true.
systemctl is-failed applic­ati­on.s­er­vice
This will return active if it is running properly or failed if an error occurred. If the unit was intent­ionally stopped, it may return unknown or inactive. Exit code 0 if failure has occurred.
Listing Current Units
systemctl list-u­nits
This will show you a list of all of the units that systemd currently has active on the system
systemctl list-units --all
This will show any unit that systemd loaded or attempted to load, regardless of its current state on the system.
systemctl list-units --all --stat­e=i­nactive
Another common filter is the --type= filter. We can tell systemctl to only display units of the type we are interested in.
systemctl list-u­nit­-files
Units are repres­ent­ations of resources that systemd knows about. Since systemd has not necess­arily read all of the unit defini­tions in this view, it only presents inform­ation about the files themse­lves.
Disp­laying a Unit File
systemctl cat atd.se­rvice
The output is the unit file as known to the currently running systemd process.
Disp­laying Depend­enc­ies
systemctl list-d­epe­nde­ncies sshd.s­ervice
This will display a hierarchy mapping the depend­encies that must be dealt with in order to start the unit in question.
Checking Unit Proper­ties
systemctl show sshd.s­ervice
To see the low-level properties of a unit, you can use the show command.
systemctl show sshd.s­ervice -p Conflicts
To display a single property, you can pass the -p flag with the property name.
Masking and Unmasking Units
mark a unit as completely unstar­table, automa­tically or manually, by linking it to /dev/null.
sudo systemctl mask nginx.s­er­vice
This will prevent the Nginx service from being started, automa­tically or manually, for as long as it is masked.
sudo systemctl unmask nginx.s­er­vice
This will return the unit to its previous state, allowing it to be started or enabled.
Editing Unit Files
sudo systemctl edit nginx.s­er­vice
This will be a blank file that can be used to override or add directives to the unit defini­tion. A directory will be created within the /etc/s­yst­emd­/system directory which contains the name of the unit with .d appended. For instance, for the nginx.s­er­vice, a directory called nginx.s­er­vice.d will be created.
sudo systemctl edit --full nginx.s­er­vice
This will load the current unit file into the editor, where it can be modified.
sudo rm -r /etc/s­yst­emd­/sy­ste­m/n­gin­x.s­erv­ice.d
remove snippet created
sudo rm /etc/s­yst­emd­/sy­ste­m/n­gin­x.s­ervice
To remove a full modified unit file, we would type:
Adju­sting the System State (Runlevel) with Targets
systemctl get-de­fault
find the default target for your system
sudo systemctl set-de­fault graphi­cal.ta­rget
If you wish to set a different default target, you can use the set-de­fault. For instance, if you have a graphical desktop installed and you wish for the system to boot into that by default, you can change your default target accord­ingly:
Listing Available Targets
systemctl list-u­nit­-files --type­=target
You can get a list of the available targets on your system by typing
systemctl list-units --type­=target
To see all of the active targets, type:
Isol­ating Targets
systemctl list-d­epe­nde­ncies multi-­use­r.t­arget
sudo systemctl isolate multi-­use­r.t­arget
Using Shortcuts for Important Events
sudo systemctl rescue
put the system into rescue (singl­e-user) mode, you can just use the rescue command
sudo systemctl halt
To halt the system, you can use the halt command:
sudo systemctl poweroff
To initiate a full shutdown, you can use the poweroff command:
sudo systemctl reboot
A restart can be started with the reboot command:
 

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.

          More Cheat Sheets by jhaley32

          DevOps Troubleshooting Study Guide Cheat Sheet