Skip to content

Simple tcp chat. Source. More info.

### Server
ncat -v -l --ssl --chat -p 8888
### Client
ncat 127.0.0.1 8888 --ssl
echo <message> > /dev/tcp/<ip_address>/<port> ## Bash only. If not using ssl.

Simple HTTP server with python

Python 2

python -m SimpleHTTPServer 8000

Python 3

pyhton -m http.server 8000

With other programming languages https://gist.github.com/willurd/5720255

Record screen

Get available audio devices name with aplay -l and aplay -L.

### Only video - 1080p - 60fps - x264
ffmpeg -f x11grab -s 1920x1080 -i :0.0 -c:v libx264 -r 60 file.mp4

### Audio and video - 1080p - 60fps - x264 - flac from pulse
ffmpeg -f x11grab -s 1920x1080 -i :0.0 -f alsa -i pulse -qp 0 -c:v libx264 -r 60 -c:a flac file.mp4

### Current resolution
xdpyinfo | grep dimensions | awk '{print $2;}'

Find funny file names

find . -regex '.*[^-_./0-9a-zA-Z\ \(\),.*'

Don't know how to do []

Share a Wifi network with a QR code

Source

Format

WIFI:S:{SSID name of your network};T:{security type - WPA or WEP};P:{the network password};;

Example

qrencode -o - -t utf8 'WIFI:S:MySweetSSID;T:WPA;P:mysecretpassword;;'

Pipes

Unnamed pipe

ls -l | grep file

Named pipe

mkfifo pipe
ls -l > pipe ## The terminal "freezes"
grep file pipe ## Must be executed in another terminal

Control jobs

  1. Start a program
  2. Ctrl + z to stop the process.
  3. jobs to list al the running jobs.
  4. bg to bring the proccess to the front.
  5. fg to keep executing the process in the background of the terminal.
  6. disown for when you want to exit the terminal and do not want the process to finish.

Bash

# .inputrc

$if Bash
    Space: magic-space
$endif
set completion-ignore-case on

"\e[A": history-search-backward
"\e[B": history-search-forward

Default apps xdg

Get the "type" of file.

xdg-mime query filetype myfile.mp4

Get the default app for said file type.

xdg-mime query default video/x-msvideo

Set the default app for said file type.

xdg-mime default mpv.desktop video/x-msvideo

List of all MIME types in https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.21.html, or in the code https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in.


Short ones

  • dd if=/dev/zero of=/dev/null waste cycles.