Skip to content

Instantly share code, notes, and snippets.

@atb00ker
Last active April 6, 2024 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atb00ker/758829981b229e19f2c1c17820a82baa to your computer and use it in GitHub Desktop.
Save atb00ker/758829981b229e19f2c1c17820a82baa to your computer and use it in GitHub Desktop.
linux commands and information i find useful.
permissions : information about getting file permissions
flaskdrive : flashdrive commands
pipeline : redirecting stdout and stderr
wget : wget to save a site offline
openssl : openssl options
certificates : types of certs and their purpose
commands : general useful commands
convert : Convert files between different formats (mostly using ffmpeg)
ssh : Useful SSH configurations
torrent : Torrent client
audio : Audio configuration help
bootmenu : How to open bootmenu for different manufacturers
# Record Audio (10 seconds)
arecord -f cd -d 10 test-mic.wav
# Play audio
aplay test-mic.wav
| Manufacturer | Key |
|:------------:|:----------------:|
| Acer | F12, F9, F2, Esc |
| Apple | Option |
| Asus | Esc |
| Dell | F12 |
| HP | F9 |
| Huawei | F12 |
| Intel | F10 |
| Lenovo | F12 |
| MSI | F11 |
| Samsung | Esc, F12, F2 |
| Sony | F11, Esc, F10 |
| Toshiba | F12 |
| others… | F12, Esc |
Filename || Needed By || Purpose || Secret
===============++============================++================================++===========
ca.crt || Server + Clients || Root CA certificate || NO
ca.key || Key Signing Machine only || Root CA key || YES
dh.pem || Server only || Diffie Hellman parameters || NO
server.crt || Server only || Server Certificate || NO
server.key || Server only || Server Key || YES
client.crt || Client only || Client Certificate || NO
client.key || Client only || Client Key || YES
xinput --list --short
xinput --list-props <device>
xinput set-prop <device> <property> <value>
xinput set-prop 'PIXA3854:00 093A:0274 Touchpad' 'libinput Tapping Enabled' 1
xrandr -q # Show all display options
xrandr -s 1366x768 -r 40 # Set display refresh rate
#!/bin/bash
convert_heic() {
for i in *.{HEIC,heic}; do
if [ -f $i ]; then
accessDate=$(date -r "$i" -u +"%Y%m%d%H%M.%S");
convert "$i" "${i%.*}".jpeg
touch -a -m -t "$accessDate" "${i%.*}".jpeg
# rm "$i"
fi
done;
}
convert_mov() {
for i in *.{MOV,mov}; do
if [ -f $i ]; then
accessDate=$(date -r "$i" -u +"%Y%m%d%H%M.%S");
ffmpeg -i $i -q:v 0 "${i%.*}".mp4
touch -a -m -t "$accessDate" "${i%.*}".mp4
# rm "$i"
fi
done;
}
convert_mts() {
for i in *.{MTS,mts}; do
if [ -f $i ]; then
accessDate=$(date -r "$i" -u +"%Y%m%d%H%M.%S");
ffmpeg -i $i -c copy "${i%.*}".mp4
touch -a -m -t "$accessDate" "${i%.*}".mp4
# rm "$i"
fi
done;
}
convert_3gp() {
for i in *.{3gp,3GP}; do
if [ -f $i ]; then
accessDate=$(date -r "$i" -u +"%Y%m%d%H%M.%S");
# ffmpeg -i $i -c:v copy -c:a copy "${i%.*}".mp4 # Lossless
ffmpeg -i $i -qscale 0 "${i%.*}".mp4 # Re-encoding
touch -a -m -t "$accessDate" "${i%.*}".mp4
# rm "$i"
fi
done;
}
find_nonstandard() {
find . -type f \
! -name '*.jpeg' \
! -name "*.png" \
! -name "*.jpg" \
! -name "*.MP4" \
! -name "*.mp4" \
! -name "*.JPG" \
! -name "*.zip" \
! -name "*.db*" \
! -name "*.log*" \
! -name "*.lst*" \
! -name "*.gif"
# Convert and keep formats
# ! -name "*.MPO" \
# ! -name "*.CR2" \
# ! -name "*.DNG"
}
merge_videos() {
final_file = 'file.mp4'
ffmpeg -f concat -safe 0 -i /home/atb00ker/Documents/merge.txt -c copy $final_file
touch -a -m -t 202403272228.40 $final_file
}
# bash /home/atb00ker/Documents/develop/convert.sh
# convert_heic
# convert_mov
# convert_mts
# convert_3gp
find_nonstandard
# LuksFormat
sudo cryptsetup --key-size 512 --hash sha512 -v luksFormat /dev/<drive> --verify-passphrase
sudo cryptsetup config /dev/<drive> --label <LABEL>
# LuksOpen
sudo cryptsetup luksOpen /dev/<drive> <LABEL>
# LuksFormat (w/ header)
sudo cryptsetup --key-size 512 --hash sha512 -v luksFormat /dev/<drive> --verify-passphrase --header ~/<header-name>
sudo cryptsetup config /dev/<drive> --label <LABEL>
# LuksOpen (w/ header)
sudo cryptsetup luksOpen /dev/<drive> <LABEL> --header ~/<header-name>
# Mount & Format
sudo mkfs.ext4 /dev/mapper/<drive>
sudo mkdir -p /media/<drive>
sudo mount /dev/mapper/<drive> /media/<drive>
sudo chown -R <user>:<user> /media/<drive>
# LuksClose & umount
sudo umount /dev/mapper/<drive>
sudo cryptsetup luksClose /dev/mapper/<drive>
sudo rm -rf /media/<drive>
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests \
--no-conflicts --no-breaks --no-replaces --no-enhances \
--no-pre-depends network-manager | grep "^\w")
sudo fdisk -l
sudo umount /dev/sdb1
sudo wipefs --all /dev/sdb1
sudo cfdisk /dev/sdb1
sudo dd bs=4M if=/path/to/iso of=/dev/sdb status=progress && sync
# Running unetbootin
sudo QT_X11_NO_MITSHM=1 unetbootin
# Recover Corrupt GPT
sudo gdisk /dev/sdb
OpenSSL 1.1.1d 10 Sep 2019
Encrypt Large Files: openssl enc -aes-256-cbc -salt -pbkdf2 -in file.txt -out file.txt.enc
Options Description
openssl OpenSSL command line tool
enc Encoding with Ciphers
-aes-256-cbc The encryption cipher to be used
-salt Adds strength to the encryption
-in Specifies the input file
-out Specifies the output file.
Decrypt Large Files: openssl enc -aes-256-cbc -d -pbkdf2 -in file.txt.enc -out file.txt
Options Description:
-d Decrypts data
-in Specifies the data to decrypt
-out Specifies the file to put the decrypted data in
0 – no permission
1 – execute
2 – write
3 – write and execute
4 – read
5 – read and execute
6 – read and write
7 – read, write, and execute
owner group other
read (r) 4 4 4
write (w) 2 2 2
execute (x) 1 1 1
----------- ----- ----- -----
total value 7 7 7
stat FILE_NAME
stat -c %a FILE_NAME
|| visible in terminal || visible in file || existing
Syntax || StdOut | StdErr || StdOut | StdErr || file
==========++==========+==========++==========+==========++===========
> || no | yes || yes | no || overwrite
>> || no | yes || yes | no || append
|| | || | ||
2> || yes | no || no | yes || overwrite
2>> || yes | no || no | yes || append
|| | || | ||
&> || no | no || yes | yes || overwrite
&>> || no | no || yes | yes || append
|| | || | ||
| tee || yes | yes || yes | no || overwrite
| tee -a || yes | yes || yes | no || append
|| | || | ||
n.e. (*) || yes | yes || no | yes || overwrite
n.e. (*) || yes | yes || no | yes || append
|| | || | ||
|& tee || yes | yes || yes | yes || overwrite
|& tee -a || yes | yes || yes | yes || append
# Exit automatically on network interruptions. In your .ssh/config, add:
ServerAliveInterval 5
ServerAliveCountMax 1
docker run -d \
--name=rutorrent \
-e PUID=1000 \
-e PGID=1000 \
-p 8090:80 \
-p 5000:5000 \
-p 51413:51413 \
-p 6881:6881/udp \
-v /<path>/config:/config \
-v /<path>/downloads:/downloads \
ghcr.io/linuxserver/rutorrent
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--domains example.com \
--no-parent \
example.com/section/topic/
Ctrl + a - go to the start of the command line
Ctrl + e - go to the end of the command line
Ctrl + k - delete from cursor to the end of the command line
Ctrl + u - delete from cursor to the start of the command line
Ctrl + w - delete from cursor to start of word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment