Skip to content

techjwalker/reference-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 

Repository files navigation

Issues Pull Requests Contributors Contribs Welcome

TastyNode.com

Reference Sheet

A List of Common Commands, Procedures, and Information.

A personal reference sheet (easy copy/paste) and script repository for everything from typical fresh-install commands to complete configurations. Mostly setup for my own use, but feel free to add a pull request if there's anything that should be added or changed.

If you are new to Linux, and are using this reference sheet to help you learn and try new things, try using one of these to test with:

Getting Started

Issues

Found an issue with a command, script, or even just some spelling, and aren't able to correct it and submit a pull request yourself?

Log it as an issue, and someone will eventually fix it (likely me).

Something you want to see added, but have no clue how to add it because GitHub is like some advanced nanobiotechnology to you?

Log it as an issue, and someone smarter than you will either add it or tell you they don't care because you're an unsupported lifeform and they haven't updated to the latest version of empathy yet.

Contributions

Know how to work GitHub like your neighbor works your significant other while you're away at work? Great!

If it's minor, add it right in to the file and submit a pull request on the revision.

Big addition, or change? Fork the whole darn thing and make your changes from the comfort of your own repository before submitting a pull request. Or just keep it to yourself and steal the whole reference sheet, because your parents never loved you as a child, and it's the only way you can feel satisfied anymore.

Common Commands

This set of common commands are used more frequently, especially when working with a newly installed system. For specific use-case commands, check the corresponding section. If a command is missing here, and seems like it would be beneficial to add, create a pull request to add the changes.

CentOS

Update, upgrade, clean:

yum update -y && yum upgrade -y && yum autoremove -y && yum clean all

Install Epel, update, upgrade, clean:

yum install -y epel-release && yum update -y && yum upgrade -y && yum autoremove -y && yum clean all

Basic tools install:

yum install -y wget nano htop bzip2 zip unzip screen

Extra tools install:

yum install -y atop nload smartmontools java

Upgrade from minimal install:

yum groupinstall "Base"

List jails (Fail2Ban):

fail2ban-client status

List banned IPs in single jail (Fail2Ban):

fail2ban-client status JAIL

List all banned IPs (Fail2Ban):

fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) system("fail2ban-client status " a[i])}' | grep "Status\|IP list"

Unban IP (Fail2Ban):

fail2ban-client set JAIL unbanip IP

Ubuntu

Update, upgrade, clean:

apt-get update -y && apt-get upgrade -y && apt-get --purge autoremove -y && apt-get clean

Basic tools install:

apt-get install -y wget nano htop bzip2 zip unzip screen

Extra tools install:

apt-get install -y atop nload smartmontools java

List jails (Fail2Ban):

fail2ban-client status

List banned IPs in single jail (Fail2Ban):

fail2ban-client status JAIL

List all banned IPs (Fail2Ban):

fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) system("fail2ban-client status " a[i])}' | grep "Status\|IP list"

Simple How-To's

Information on the basics.

This is the stuff you'll want to commit to memory.

Much of the information listed here is restricted to just the "need-to-know" stuff, rather than having too much information all at once, to help avoid confusion and to make it easier to pick up for beginners.

If there's anything not listed in this section, try a quick Google search for more info.

Navigation

Check what's in your current directory:

ls

Find the directory you're already in:

pwd

Navigate to a different directory:

cd folder

Navigate to previous directory:

cd -

Navigate up a directory:

cd ../

Navigate to home directory:

cd ~

File Manipulation

Create a new directory:

mkdir folder

Delete a single file:

rm file

Delete a directory and all contents:

rm -r folder

Delete everything in the current directory without confirmation:

rm -fr *

Move/Rename a file:

mv file newfile

Move/Rename a directory:

mv folder newfolder

Copy a file:

cp file newfile

Copy a directory:

cp -R folder newfolder

Screens (Multiple Sessions)

Check existing screens:

screen -ls

Start new screen session with name:

screen -S name

Attach to an already running session (if there are multiple screens with the same name, use the output from screen -ls to copy the full screen ID):

screen -x name

Detach from current session:

Key Combination: CTRL-a d

Force the attached session to close completely:

Key Combination: CTRL-a
Type :quit then hit Enter

NOTE: Closing a screen session does not guarantee that you will close whatever is running within that session.

Use-Case How-To's

Information on what to do, and what kind of commands to run, in order to accomplish different things in certain scenarios.

Keep in mind there are typically many different ways to do things, and often better than what's suggested here. If you personally know a better solution, mention it in an issue or add it yourself with a pull request.

Kill a Frozen Process

So something went south, a process caught fire, and now you have 80% memory usage on a process you can't close out of anymore.

Don't worry, here's how you use the fire extinguisher:

First, find the PID of the process. Easiest way is to check top.

top

Not sure which one is the right one? Grab the PID of whichever process seems most likely the one you want, then use this:

ls -l /proc/PID/cwd

Replacing PID with the PID you copied from top, of course.

This should tell you which folder that process is running from, which should (hopefully) help you verify whether it's the process you need to force close.

Then run this command to kill that process:

kill -9 PID