8000 GitHub - Kanat121/command-line-magic: Simple cheatsheet to some linux commands
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Kanat121/command-line-magic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Introduction

Let's face it, we are mere mortals that keep forgetting everytime we learn something new. So that's why I created this simple cheatsheet. Every time I forget something important, I want to refer back in one single place instead of scouring the Internet for the same answer that I did before. Hope this will help.

System magic

Show C: disk usage

df -h | awk '/^C:\\/ {print $3 "/" $2}'

Show formatted disk usage for ext4/xfs filesystems

df -h -t ext4 -t xfs | awk '{print $1, $3 "/" $2}' | column -t

Show memory used/total

free -h | awk '/^Mem:/ {print $3 "/" $2}'

Show top 10 largest files (descending order, starting from the current folder, recursively)

find . -printf '%s %p\n'| sort -nr | head -10

Show top 10 largest folders

du -hsx * | sort -rh | head -10

Show IP and broadcast address

ip a show scope global dynamic | awk '$1 == "inet" {print $2, $4}'

Show most memory intensive process

ps axch -o cmd:15,%mem --sort=-%mem

Show most CPU intensive process

ps axch -o cmd:15,%cpu --sort=-%cpu

Show explicit installed packages

apt-mark showmanual

Show current PATH environment variable

echo $PATH | tr : \\n

Sed magic

Remove all double quotes on each line

sed 's/"//g'

Remove everything before the first space

sed 's/[^ ]* //'

Remove last comma on each line

sed 's/,$//'

Remove bracket and everything between a pair of bracket

sed -e 's/\[[^][]*\]//g'

Replace all commas with spaces

sed 's/,/ /g'

Awk magic

Print all column

awk '{print $0}'

Print all line except first

awk '(NR>1)'

Remove empty lines from list result

awk 'NF'

Remove all leading, trailing whitespaces and tabs from each line

awk '{$1=$1};1

Grep specific line numbers

awk 'NR==2{ print; }'

Grep magic

Extract everything inside brackets

grep -oP '\[\K[^\]]+'

Find only first occurence in a file

grep -m1 'searchstring' file_name

Curl magic

Show my external IP address

curl -4 https://icanhazip.com

Systemctl magic

Show all installed services

systemctl list-unit-files --state=enabled --no-pager

FFmpeg magic

Adding audio to a video without re-encoding

ffmpeg -i video_name.mp4 -i audio_name.m4a -c copy -map 0:v -map 1:a output_name.mp4

Youtube-dl magic

Extract audio track from Youtube video and store as mp3

youtube-dl --extract-audio --audio-format mp3 https://ytvideolink

Nmap magic

Scan all of target port using default script, version detection and output the result normally

nmap -sC -sV -p- -oN output-name ip-address

Enumerate specific port using http-enum script

nmap --script=http-enum -p80 ip-address

Gobuster magic

Search name of the hidden directory on the web server with wordlist.

gobuster dir -u http://ip-address -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt

Enum4linux magic

Enumerate machine list, group and user list with share list

enum4linux -M -G -S ip-address

Smbclient magic

Mount and connect to the sharename (Anonymous).

smbclient //ip-address/Anonymous

Hydra magic

Bruteforce SSH password with wordlist from known SSH username

hydra -l ssh-username -P /usr/share/wordlists/rockyou.txt ssh://ip-address

About

Simple cheatsheet to some linux commands

Resources

Stars

Watchers

Releases

No releases published

Packages

No packages published
0