Last active
July 28, 2024 16:33
-
-
Save atb00ker/758829981b229e19f2c1c17820a82baa to your computer and use it in GitHub Desktop.
linux commands and information i find useful.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
ram : Get ram usage per process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Record Audio (10 seconds) | |
arecord -f cd -d 10 test-mic.wav | |
# Play audio | |
aplay test-mic.wav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|| 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exit automatically on network interruptions. In your .ssh/config, add: | |
ServerAliveInterval 5 | |
ServerAliveCountMax 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget \ | |
--recursive \ | |
--no-clobber \ | |
--page-requisites \ | |
--html-extension \ | |
--convert-links \ | |
--domains example.com \ | |
--no-parent \ | |
example.com/section/topic/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get RAM usage per process | |
systemctl list-units --type=service --state=running | | |
awk '{print $1}' | | |
grep .service | | |
xargs -I {} sh -c ' | |
echo -n "{}: "; | |
systemctl show -p MainPID --value {} | | |
xargs -I % ps -o rss= -p % 2>/dev/null | | |
awk "{print \$1/1024\" MB\"}" | |
' | | |
sort -k2 -rn | | |
tee >(awk '{sum += $2} END {printf "Total RAM: %.2f MB\n", sum}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment