Skip to content

Instantly share code, notes, and snippets.

@afro-coder
Last active June 2, 2022 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afro-coder/1feefb669322757a08ebb23d6fa5a650 to your computer and use it in GitHub Desktop.
Save afro-coder/1feefb669322757a08ebb23d6fa5a650 to your computer and use it in GitHub Desktop.
Linux commands

Linux System Admin Primer

Challenge

https://github.com/livialima/linuxupskillchallenge

Linux Guide

https://tldp.org/LDP/intro-linux/html/index.html

Basic Commands

◦ ps ◦ df ◦ du ◦ vim ◦ top ◦ less ◦ more ◦ zless ◦ grep

Check if SSH is enabled

systemctl status sshd

Check for a Port that is listening on the server

ss -patun | grep 2222

Firewall management

Install a package

yum install -y firewalld

List Firewall ports

firewall-cmd  --list-all

Add predefined services

firewall-cmd --permanent --add-service=httpd

List predefined services

firewall-cmd --get-services

Add a service to the firewall

firewall-cmd --permanent --add-service=http
firewall-cmd --reload

Open a port in linux, replace tcp with udp for UDP ports

firewall-cmd --add-port=portnumber/tcp --permanent
firewall-cmd --reload

Selinux (Advanced) Turn it off for now

setenforce 0

Read about SELinux first https://wiki.gentoo.org/wiki/SELinux/Tutorials https://wiki.gentoo.org/wiki/Category:SELinux https://wiki.gentoo.org/wiki/SELinux/Tutorials/How_SELinux_controls_file_and_directory_accesses

Package Management

Install a package or multiple

yum install -y vim tmux

To view files owned by package

repoquery -l httpd

Get installed packages with the name httpd

yum list installed | grep httpd

Process Management

Grep Httpd pid

pgrep httpd

Grep process list

ps aux | grep httpd

Filter per process

ps -ylC httpd

File Processing

• vim → press i to go to insert mode, vimtutor will help you learn basic vim • wc → Word Count for lines → wc -l #https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/text-information-tools.html • shell redirection, >, >>, 2>1 # https://tldp.org/LDP/abs/html/io-redirection.html

Basic file commands https://tldp.org/LDP/abs/html/basic.html • less => View files in a pager mode -> Ability to view and search text • cat → Spit all the lines to the terminal • zless → compressed files • zgrep → grep through compressed files • grep → grep through files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment