BLOG
15 November 2021

Linux Commands

TTTThis

In Terminal:

2025

To invert the colors of all photos in folder (install imagemagick first)

find . -maxdepth 1 -type f -name "*.jpg" -exec mogrify -negate {} \;

To boost volume of all audio files in current folder (I think 3X) (install ffmpeg first I think)

for file in *.mp3 *.wav *.WAV *.ogg *.flac *.m4a; do
    ffmpeg -i "$file" -filter:a "volume=3.0" -c:v copy -c:a libmp3lame -q:a 2 "louder_${file}"

done

REGULAR COMMANDS

usr does not mean user, it means universal system repository (or something).


INTERESTING COMMANDS


GET INFORMATION ABOUT COMPUTER, COMMANDS


USEFUL COMMANDS

DISABLE TOUCH SCREEN


YouTube-dl (outdated)

* download mp3 (using youtube-dl): 

youtube-dl -x --audio-format mp3 http:address

* download playlist as mp3s: 

youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist https:address



---

**LINUX FOR ETHICAL HACKERS (YouTube course)**

**chmod +rwx**

or just 

**chmod +x**

or 

**chmod 777 hello.txt**

**adduser john**

**cat /etc/passwd**

(you will see john at bottom)

**cat /etc/shadow**

(you can only see hashing format - a tool like hashcat can break that down and crack passwords) 

...

(su is switch user)

**su john**

**passwd root** (to change root's password, but this does not work. Neither does)

**sudo passwd root**

(because john is not in the sudoers file)

...

**userdel john**

(deletes john)

networking terms - brush up for pentesting. You'll have to navigate around networks.

**ifconfig** (shows different interface types and IP address associated with them)

**iwconfig** (only usually see if using a laptop)

**ping** (icmp traffic)

**arp -a** (show you IP address it talks to and mac address tied to it)

**netstat -ano** (you can see what's talking) (what that machine is associated with and if it's talking on a port)

**route** (print your routing table) (tells you where your traffic exits, essentially)

102:00

---

bulk renaming with Thunar.

Use ‘Numbering’ and do ‘Text - Number’ and add your text there too.

---

**Make a txt file: https://www.youtube.com/watch?v=T20jXu7rDCA**

**Nano way:**

* cd to whatvr dir
* touch filename.txt
* (now, ls -l will show you have that file but no size)
* (can see contents of file with ‘cat filename.txt’)
* (nano by itself opens the text editor n you can tipe)
* (ctrl-shft-V does paste)
* Ctrl-O saves the file

* cd to directory
* ls to check it
* cat > filename.txt [enter]
* type text and then [CTRL-D to save]
* ls to check it's there
* cat filename.txt to read it

**OR**

* touch filename.txt [enter]
* ls to see it

**WAV to MP3**

* batch convert all the files in a folder from wav to mp3 using ffmpeg
* for i in Silver0709.wav; do ffmpeg -i "$i" "${i%.*}.mp3"; done

**Get Mono sound out of speakers**

* pacmd list-sinks | grep name:
* then
* pacmd load-module module-remap-sink sink_name=mono master=NAME_OF_AUDIO_SINK_GIVEN_BY_PREVIOUS_COMMAND_BUT_WITHOUT_ARROW_BRACKETS channels=2 channel_map=mono,mono
* Then if you click on your sound icon, you should have an option for ‘Remapped Built-in etc’ 

**Convert a bunch of images into a video using ffmpeg, MP4**

* ffmpeg -loop 1 -i easywords1.jpg -i easywords1.wav -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" \-c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p \-t 1480 out-image.mp4
* ffmpeg -loop 1 -i easywords2.png -i easywords2.wav -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2" \-c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p \-t 1840 easywords2.mp4

**Convert MP3 to WAV**

* install mpg321 (not 123 which is a slightly worse program because not on public licence)
* put the to-be-created wav title first
* mpg321 -w newFile.wav “old file.mp3"
* mpg321 -w ZOOM0061.WAV ZOOM0061.mp3

**Clean metadata**

* exiftool (jexiftool has an appimage https://github.com/hvdwolf/jExifToolGUI/releases
* exifcleaner
* to clean metadata

**ffmpeg**

* because it does a better job of combining audio with a single image than Kdenlive (which makes big files) (it has no GUI though, so use HandBrake) (I didn't find it to be very much better on initial tests)
* Handbrake
* add-apt-repository sudo apt-get update
* sudo apt-get install handbrakeppa:stebbins/handbrake-git-snapshots

**Chmod execute scripts**

* change mod it with (you have to be in the directory) (otherwise it will look for a system path):
* chmod +x myscript.sh
* to execute it then, do
* ./myscript.sh

**PDF TO TEXT**

qpdf orig.pdf --pages . 420-511 -- just-the-chapters.pdf && convert -density 288 just-the-chapters.pdf output-%02d.jpg && convert output*.jpg -level 25% final-%02d.jpg && convert final*.jpg vr.pdf && ocrmypdf -l spa vr.pdf bookonech11-12.pdf && pdftotext -layout bookonech11-12.pdf bookonech11-12.txt && rm output* && rm final* && rm vr.pdf && rm just-the-chapters.pdf

**Batch crop images (imagemagick)**

mogrify*.png  -crop  1x1-100-100@ *.jpg

https://deparkes.co.uk/2015/04/30/batch-crop-images-with-imagemagick/

**Do**

* mogrify -crop 300x300+150+150 -path ./cropped *.png
* An example line which is just to illustrate:
* convert -crop x_sizexy_size+x_offset+y_offset inputfile outputfile

convert *.png -crop 350x300+150+200 *.jpg

---

*Modify metadata for 'date modified' (on Linux it seems that there's no ability to modify creation date, even with filesystems that allow it ie exfat etc)**

* go to folder and put all the files you want to modify, and open a Terminal there
* touch *
#Blog
NewerCAD on linux: Blender OlderParrot OS