Skip to content

Instantly share code, notes, and snippets.

@afro-coder
Last active June 2, 2022 09:54
Show Gist options
  • 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 Guide

https://github.com/livialima/linuxupskillchallenge

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

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

Package Management

Install a package or multiple

yum install -y vim tmux

To view files owned by package

repoquery -l httpd

Get installed packages

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 • shell redirection, >, >>, 2>1, • 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

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