Skip to content

Core utils

Core Linux Utils

filesystem tools

exa

A replacement for ls with sane defaults and some nice extras (like tree integration) written in the modern rust-lang

Add the following to your ~/.bash_aliases file:

alias l="exa -l --extended --time-style long-iso"
Install

download and unzip exa-linux-x86_64-0.9.0.zip then move the binary to ~/.local/bin/

fd

A replacement for find with sane defaults written in the modern rust-lang

Install

find latest .deb file in sharkdp/fd/releases

Currently:

wget https://github.com/sharkdp/fd/releases/download/v7.3.0/fd_7.3.0_amd64.deb
sudo dpkg -i fd_7.3.0_amd64.deb
Cheatsheet

Regex

fd '^x.*rc$'

Specify Root Dir

$ fd passwd /etc
/etc/default/passwd
/etc/pam.d/passwd
/etc/passwd

Search by file extension

$ fd -e md
CONTRIBUTING.md
README.md

Include Hidden files

$ fd -H pre-commit
.git/hooks/pre-commit.sample

Include Auto Ignored Files

$ fd num_cpu
$ fd -I num_cpu
target/debug/deps/libnum_cpus-f5ce7ef99006aa05.rlib

Running commands The -X command preforms rm on all .DS_Store files

$ fd -H '^\.DS_Store$' -tf -X rm

Passing -i (interactive) enables a prompt between exec command -X execution (i.e. confirm deletion)

Command-line options
USAGE:
    fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

FLAGS:
    -H, --hidden            Search hidden files and directories
    -I, --no-ignore         Do not respect .(git|fd)ignore files
        --no-ignore-vcs     Do not respect .gitignore files
    -s, --case-sensitive    Case-sensitive search (default: smart case)
    -i, --ignore-case       Case-insensitive search (default: smart case)
    -F, --fixed-strings     Treat the pattern as a literal string
    -a, --absolute-path     Show absolute instead of relative paths
    -L, --follow            Follow symbolic links
    -p, --full-path         Search full path (default: file-/dirname only)
    -0, --print0            Separate results by the null character
    -h, --help              Prints help information
    -V, --version           Prints version information

OPTIONS:
    -d, --max-depth <depth>            Set maximum search depth (default: none)
    -t, --type <filetype>...           Filter by type: file (f), directory (d), symlink (l),
                                       executable (x), empty (e)
    -e, --extension <ext>...           Filter by file extension
    -x, --exec <cmd>                   Execute a command for each search result
    -X, --exec-batch <cmd>             Execute a command with all search results at once
    -E, --exclude <pattern>...         Exclude entries that match the given glob pattern
    -c, --color <when>                 When to use colors: never, *auto*, always
    -S, --size <size>...               Limit results based on the size of files.
        --changed-within <date|dur>    Filter by file modification time (newer than)
        --changed-before <date|dur>    Filter by file modification time (older than)

ARGS:
    <pattern>    the search pattern, a regular expression (optional)
    <path>...    the root directory for the filesystem search (optional)

find

Find files by name

find . -print | grep -i foo

Search for a filename using regex

find ./ -type f -regex '.+[Cc]ordova.+' -not -path '*/\.*'

Find files with matching text

find ./ -type f -print -exec grep -n -i "stringYouWannaFind" {} \;

find ./ -type f -print0 | xargs -0 grep -l "Oh Hai"

grep -r --include "*.txt" stringYouWannaFind .

Search for iso files, ignoring folders dot folders (i.e. .git, .svn, .ect)

find . -type f -not -path '*/\.*' -name *.iso

ripgrep

Installation cargo install ripgrep

archive formats

Tar

Create archive: tar -pczf name_of_your_archive.tar.gz /path/to/directory

Backup Dropbox: tar -czf "dropbox-backup-$(date +%Y-%m-%d).tar.gz" --exclude ".*" ~/Dropbox

Encrypt directory

Open Encrypted Directory: openssl enc -aes-256-cbc -d -in ~/vault.tar.gz.dat | tar xz; thunar ~/vault

Lock Encrypted Directory: tar cz vault/ | openssl enc -aes-256-cbc -out ~/vault.tar.gz.dat; rm -r ~/vault

GPG / PGP

gpg --output fname.org.gpg --symmetric fname.org

See also: encryption.md

rar

Create rar archive split across multiple files

rar a -v50000 -m0 file.rar thing_to_archive

   -m<0..5>
          Set compression level (0-store...3-default...5-best). By default rar uses -m3 method (Normal compression).

   -v<size>[k|b|f]
          Create volumes with size=<size>*1000 [*1024, *1].

networking tools

  • ping: are these computers even connected?
  • dig / nslookup: does that domain exist?
  • netstat / ss: am I using + + port?
  • ifconfig: what’s my IP address?
  • tcpdump: what packets are being sent on port 80?
  • wireshark: look at those packets in a GUI
  • ngrep: grep for your network
  • traceroute / mtr: what servers are on the way to that server
  • nc: Make TCP connections manually
  • nftables / iptables: set up firewalls and NAT
  • iw: set up wifi from the command line
  • ethtool: understand your ethernet connection
  • ip: configures interfaces routes
  • tc: slow down the internet for your brother’s MAC address
  • arp: see your ARP table

CURL

curl -H "Content-Type: application/json" \
     -X POST \
     -d '{"username":"xyz","password":"xyz"}' \
     http://localhost:3000/api/login

curl -d "@data.json" -X POST http://localhost:3000/data

SSH

Local port listens to

> ssh -L <port>:localhost:<port> <user>@<domain>
> local_program --port=<port>

Toxiproxy

A framework for simulating network conditions

https://github.com/Shopify/toxiproxy

Croc

Easily and securely send things from one computer to another

https://github.com/schollz/croc