Linux Commands: Difference between revisions

No edit summary
No edit summary
 
(48 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Delete all docker images
== Flatpak & Applications ==


<code>docker rmi -f $(docker images -a -q)</code>
=== Give dolphin emulator flatpak full filesystem access like the non-flatpak version would have ===
sudo flatpak override --filesystem=host org.DolphinEmu.dolphin-emu
You may also want to use FlatSeal for this
 
== File Operations ==
 
=== Copy every iso in the current folder into nintendon't format ===
for i in *; do mkdir "$(echo $i | sed 's/.iso//')"; mv "$i" "$(echo $i | sed 's/.iso//')"/game.iso; done
 
=== Copy while preserving permissions [Use archive mode, resolve symlinks, and skip files that are newer on the destination] ===
rsync -auL source-file destination-file
 
=== Copy with progress bar ===
rsync --progress source_file destination_file
 
=== Move all files that aren't folders into a folder ===
mv -- *(.) other_directory/
 
=== Create a file and set its permissions ===
install -m 755 /dev/null filename.txt
 
 
== System Monitoring & Logs ==
 
=== View systemd service logs in real time [system service] ===
sudo journalctl -u notification-parse.service -f
 
=== View systemd service logs in real time [user service] ===
journalctl --user -u notification-parse.service -f
 
=== Print kernel version and CPU architecture ===
uname -a
 
 
== Networking & Security ==
 
=== Nmap ping scan an entire subnet very quickly ===
sudo nmap -T5 -sn 192.168.0.0/24
 
=== Get a list of all files with setuid / SUID permissions ===
find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;
 
 
== Docker ==
 
=== Delete all docker images ===
docker rmi -f $(docker images -a -q)
 
 
== Clipboard Utilities ==
 
=== Get/Set data from clipboard: ===
getclip () {
        xclip -selection c -o
}
setclip () {
        xclip -selection c
}
 
 
== Media & Encoding ==
 
=== Record audio files ===
[[Record Audio Files in the Command Line]]
 
=== Create an SSL Key and Cert pair ===
openssl req -new -x509 -nodes -out server.crt -keyout server.key
 
=== Cut a video or audio file into a clip based on seconds ===
[[FFmpeg Cut a video to a clip by seconds]]
 
=== Download any yt-dlp supported video, convert it to an mp3, then automatically number it based on the order they were downloaded in the playlist ===
yt-dlp --extract-audio --audio-format mp3 --output "%(autonumber)s - %(title)s.%(ext)s" {PUT LINK TO PLAYLIST OR VIDEO HERE}
 
=== Convert a folder of mp3s into DVD-compatible mpeg2 files (.dvd) while embedding a looping video on them for compatibility, reducing bit rate as low as it can go. ===
for i in *.mp3; do; ffmpeg -stream_loop -1 -i asteracube.webm -i "$i" -shortest -r 24 -loop 1 -codec:v mpeg2video -b:v 400k -codec:a ac3 -b:a 448 -vf scale=352:240 dvd/"${i%.*}.dvd"; done
 
 
== Disk & System Management ==
 
=== Add kernel boot parameters on truenas scale. This command adds "nomodeset" to the kernel parameters. It is auto-applied on reboot. ===
midclt call system.advanced.update '{"kernel_extra_options": "nomodeset"}'
 
=== Expand a partition to fit the whole disk without rebooting [In this case the disk is <code>/dev/nvme0n1</code> and the partition is <code>2</code>] ===
sudo growpart /dev/nvme0n1 2
sudo resize2fs /dev/nvme0n1p2
 
=== Convert an existing linux install to ageless linux ===
curl -fsSL https://agelesslinux.org/become-ageless.sh | sudo bash -s -- --accept --flagrant
 
=== Remount a filesystem as read-write in the current directory ===
sudo mount -o remount,rw /dev/sdX1 .
 
 
== Additional Resources ==
 
https://github.com/sujayadkesar/Linux-Privilege-Escalation#9-capabilities
 
[https://youtu.be/aqp5ahzeOqA Youtube.com: Common Linux Privilege Escalation: Using Kernel Exploits]
 
[https://arachnoid.com/SecureShell/index.html Arachnoid.com: How to use SSH]
 
https://github.com/OpenRC/openrc/blob/master/service-script-guide.md
 
https://www.truenas.com/community/threads/kernel-boot-parameter-how-to-add-to-tn-scale.110109/
 
https://agelesslinux.org/

Latest revision as of 03:59, 7 April 2026

Flatpak & Applications[edit]

Give dolphin emulator flatpak full filesystem access like the non-flatpak version would have[edit]

sudo flatpak override --filesystem=host org.DolphinEmu.dolphin-emu

You may also want to use FlatSeal for this

File Operations[edit]

Copy every iso in the current folder into nintendon't format[edit]

for i in *; do mkdir "$(echo $i | sed 's/.iso//')"; mv "$i" "$(echo $i | sed 's/.iso//')"/game.iso; done

Copy while preserving permissions [Use archive mode, resolve symlinks, and skip files that are newer on the destination][edit]

rsync -auL source-file destination-file

Copy with progress bar[edit]

rsync --progress source_file destination_file

Move all files that aren't folders into a folder[edit]

mv -- *(.) other_directory/

Create a file and set its permissions[edit]

install -m 755 /dev/null filename.txt


System Monitoring & Logs[edit]

View systemd service logs in real time [system service][edit]

sudo journalctl -u notification-parse.service -f

View systemd service logs in real time [user service][edit]

journalctl --user -u notification-parse.service -f

Print kernel version and CPU architecture[edit]

uname -a


Networking & Security[edit]

Nmap ping scan an entire subnet very quickly[edit]

sudo nmap -T5 -sn 192.168.0.0/24

Get a list of all files with setuid / SUID permissions[edit]

find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;


Docker[edit]

Delete all docker images[edit]

docker rmi -f $(docker images -a -q)


Clipboard Utilities[edit]

Get/Set data from clipboard:[edit]

getclip () {
       xclip -selection c -o
}
setclip () {
       xclip -selection c
}


Media & Encoding[edit]

Record audio files[edit]

Record Audio Files in the Command Line

Create an SSL Key and Cert pair[edit]

openssl req -new -x509 -nodes -out server.crt -keyout server.key

Cut a video or audio file into a clip based on seconds[edit]

FFmpeg Cut a video to a clip by seconds

Download any yt-dlp supported video, convert it to an mp3, then automatically number it based on the order they were downloaded in the playlist[edit]

yt-dlp --extract-audio --audio-format mp3 --output "%(autonumber)s - %(title)s.%(ext)s" {PUT LINK TO PLAYLIST OR VIDEO HERE}

Convert a folder of mp3s into DVD-compatible mpeg2 files (.dvd) while embedding a looping video on them for compatibility, reducing bit rate as low as it can go.[edit]

for i in *.mp3; do; ffmpeg -stream_loop -1 -i asteracube.webm -i "$i" -shortest -r 24 -loop 1 -codec:v mpeg2video -b:v 400k -codec:a ac3 -b:a 448 -vf scale=352:240 dvd/"${i%.*}.dvd"; done


Disk & System Management[edit]

Add kernel boot parameters on truenas scale. This command adds "nomodeset" to the kernel parameters. It is auto-applied on reboot.[edit]

midclt call system.advanced.update '{"kernel_extra_options": "nomodeset"}'

Expand a partition to fit the whole disk without rebooting [In this case the disk is /dev/nvme0n1 and the partition is 2][edit]

sudo growpart /dev/nvme0n1 2
sudo resize2fs /dev/nvme0n1p2

Convert an existing linux install to ageless linux[edit]

curl -fsSL https://agelesslinux.org/become-ageless.sh | sudo bash -s -- --accept --flagrant

Remount a filesystem as read-write in the current directory[edit]

sudo mount -o remount,rw /dev/sdX1 .


Additional Resources[edit]

https://github.com/sujayadkesar/Linux-Privilege-Escalation#9-capabilities

Youtube.com: Common Linux Privilege Escalation: Using Kernel Exploits

Arachnoid.com: How to use SSH

https://github.com/OpenRC/openrc/blob/master/service-script-guide.md

https://www.truenas.com/community/threads/kernel-boot-parameter-how-to-add-to-tn-scale.110109/

https://agelesslinux.org/