Miscellaneous Tips
Table of Contents
- Screenshots
- JSON
- Youtube
- Uncompress Examples
- Compress Examples
- Using
pv
to get progress of file operations - Using
rsync
to copy and get a progress bar - Using
iperf3
to measure speed between hosts - Using
sshfs
to mount a remote folder - Use
gerbera
as a Upnp server - Use
ssh
to forward a port from remote to local - View the exit code in bash from the previous command
- Reference a secret stored in
pass
in a bash script - One line command webserver
Screenshots
scrot
is a decent tool for taking screenshots of you entire desktop or just a particular window
JSON
- Use python package
demjson3
to get the jsonlint command. - This package is in the apt repo or can be installed via pip
pip install demjson3
Youtube
Channel RSS feed
Getting Channel Id
- Go to the channel homepage and right click and view source
- Search the source for
itemprop="channelId" content="
- Inside the content block you will see the channel id
Youtube RSS Template
https://youtube.com/feeds/videos.xml?channel_id=<CHANNEL_ID>
Uncompress Examples
tar.gz
tar -zxvf <SOME_FILE>.tar.gz>
tar.xz
tar -xvf <SOME_FILE>.tar.xz
Compress Examples
tar.gz
- If you want to compress
somdir
into.tar.gz
tar -cvf somedir.tar somedir
this will produce the tarball- To make it a gz file run
gzip somedir.tar
- This will compress and tarball into
somedir.tar.gz
Compress using multiple cores
tar -c -I 'xz -9 -T0' -f <SOME_ARCHIVE>.tar.xz <FILES or DIRECTORIES>
xz -9
means use max compressionxz -T0
means number of threads = to number of CPUS
Create a WIM file to de-deduplicate repeated files
7z a -twim <SOME_ARCHIVE>.wim <FILES or DIRECTORIES>
Using pv
to get progress of file operations
Most examples from here.
pv
copy directory
tar c Notebooks/ | pv | tar x -C Documents/
This will copy the Notebooks folder to Documents/Notebooks with a progress bar
Using rsync
to copy and get a progress bar
rsync -ah --progress <SOURCE> <DEST>
Using iperf3
to measure speed between hosts
Using sshfs
to mount a remote folder
- ArchWiki docs on
sshfs
- Use this program to mount a remote locally
- You do not need to be root to use this
- Example
sshfs me@remote:/home/me/videos videos
- To unmount
fusermount3 -u videos
Use gerbera
as a Upnp server
- On iOS VLC is a good client app
- The current version of VLC (tvOS) is not working properly for UPnP servers on TVOS
- Infuse is a good option for tvOS
Use ssh
to forward a port from remote to local
ssh -L 9090:127.0.0.1:8384 user@othercomputer.example.com
add -N
if you don't want to open a terminal session
View the exit code in bash from the previous command
- You can see the exit code from the previous command with
echo $?
Reference a secret stored in pass
in a bash script
- Sometimes you need to write a script that references an encrypted secret in your password manager
- Use this template to reference a pass file
gpg2 -q --for-your-eyes-only --no-tty -d $PASS_REPO/<SOME_SECRET>.gpg
One line command webserver
- Python ships with a built in webserver you can run
- If you run
python -m http.server
it will serve the current working directory - The command should tell you the port