A.84 - Terminal Ninja Article End

A.84.a1 - Terminal Ninja

When you work with Linux, you spend most of your time in the terminal. Of course, you can also operate everything with the mouse via a graphical user interface, but that is usually considerably slower. Whether you use commands for the file system, work with the Vim editor or programme shell scripts for recurring tasks. Most tasks have already been solved by other people. Sometimes I need some commands only once or twice in my life and then never again. Nevertheless, I write them down here because I don't know if I will need them again in the future. I also post my own scripts here that I make available to the public, because especially when processing images, you can save hours with a one-liner script. 17,230,420 pictures all have to be cropped to the same size? You start the script in the terminal and then go and get a cup of tea. In the meantime, the computer calculates the task. The task of a good computer scientist is to find solutions for strenuous tasks so that he or she can work on the exciting problems.

A.84.a2 - Misc

echo '<ul>'; for f in {1..2}; do echo '<li></li>'; done; echo '</ul>' Create regular HTML Lists.
gcc main.c -o main Compile C Program [hdepI].
sed -i -e 's/word1/word2/g' file.txt Change all $word1 in a file to $word2 [eNpQS].
grep -rnw word Search word in files [72bbs].
la -A Show hidden .dot files like .profile or .bash.rc in terminal [354861].
ps -e kill (process number) Show your processes and kill a specific process [781087].
sed -e 's/<[^>]*>//g' file.html Strip HTML tags. [268152]
cp file.txt documents/ Copy the .txt file to the documents folder. [741678]
cp file.txt file.bac.txt Duplicate a file. [^]
cp -a myFolder myMedia/ Copy the folder to another directory. [^]
mv file.txt documents/ Move the .txt file. [^]
mv file.txt Rename a file. [^]
mv myFolder/ mySpecialFolder Rename a folder. [^]
touch 'new file' Create a new file. [^]
du -sh myFolder/ Show file/directory size. [^]
stat file.txt Show file/directiry info. [^]
xdg-open file.txt Open a file with the default program. [^]
zip -r myFolder Zip a archive. [^]
unzip myArchive. zip Unzip a archive. [^]
zipinfo Peak in a zip archive. [^]
rm file.txt Remove a file. [^]
rm -r myFolder Reove a folder complete. [^]
ly myFolder List directiory contents. [^]
find myFolder -mtime +5 Find all files modified more than five days ago. [^]
cal Display a text calendar. [^]
call 23 2020 Display selected month and year wtih a text calendar. [^]
date Show the date. [^]
df -h Show disk size. [^]
top Check computer performance. [^]
echo "set enable-bracketed-paste off" >> ~/.inputrc Disable bash highlight on ctrl+r search or paste. [531444]

[oqUC8] George Ornbo, 16.11.2019, "Linux and Unix wget command tutorial with examples",, Retrieved 16.11.2020/17:08
[39m4S] Magesh Maruthamuthu, 06.01.2020, "6 Commands to Find the IP Address of a Domain in the Linux Terminal",, Retrieved 16.11.2020/17:13
[hdepI] Ismail Baydan, 27.05.2017, "Compile C Hello World Program",, Retrieved 16.11.2020/17:29
[eNpQS] J. Random hacker, Free Software Foundation, Inc., version 4.8, "sed, a stream editor",, Retrieved 16.11.2020/17:39
[72bbs] Nathan, 06.06.2013, "How do I find all files containing specific text on Linux?",, Retrieved 15.12.2020/14:15
[354861] Richard M. Stallman, David MacKenzie, 2020 Free Software Foundation, man ls, March 2020, GNU coreutils 8.32, "-A, --almost-all do not list implied . and ..", Retrieved 02.03.2021/15:20
[781087] Humphrey, "5 quick ways to kill a process in Linux",, Retrieved: Sat Mar 13 05:07:07 2021
[268152] Olaf Dietsche, 09.11.2013, "Strip HTML tags",, Retrieved: Wed Apr 7 22:57:51 2021
[741678] you-dont-need, 14.11.2020, "You-Dont-Need-GUI",, Retrieved: Fri Apr 9 11:08:52 2021
[531444] garyshood, "Disable Bash Highlight on Ctrl+R Search or Paste",, Retrieved: Sat Apr 10 02:52:15 2021
A.74.2 A.84.2

A.84.a3 - Images

for f in *.JPG; do mv -- "$f" "${f%.JPG}.jpg"; done Change Extension from multiple Files.
for f in *.jpg; do convert $f -resize 550x310 "$f"; done Convert all Pictures to 550x310.
for f in *.jpg; do convert $f -colorspace Gray "$f"; done Convert all Pictures to Gray.
for f in *.jpg; do exiftool -all= "$f"; rm *.jpg_original; done Remove EXIF data on multiple Photos and delete all original Files.
ls -v | cat -n | while read n f; do mv -n "$f" "p115_0$n.jpg"; done Numbering and renaming of File names. p78 is an Example.
for f in *.jpg; do convert $f label:$f' 2021 Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)' -append "$f"; done Set a license label (bottom) for all .jpg pictures in the folder [ss83bx][nwsngd].
for f in {1..54}; do echo '<img src="img/p23_0'$f'.jpg">'; done Create (X) times a numbered HTML part. p23 is an Example.
display file.png Diyplay image file from terminal. [768377]

[ss83bx] Anthony Thyssen, 26.10.2011, "ImageMagick v6 Examples - Text to Image Handling",, Retrieved 24.11.2020/20:12
[nwsngd] Creative Commons, 2020, "Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)",, Retrieved 24.11.2020/20:20
[768377] Magesh Maruthamuthu, 26.03.2021, "How to view images from Linux terminal",, Retrieved: Fri Apr 9 20:06:52 2021

A.84.a4 - Cargo Commands

cargo init Create a new Cargo package in an existing directory [ddxps5].
cargo build Compile the current package [zo9q7e].
cargo run Run the current package [uwnzht].
cargo update Update dependencies as recorded in the local lock file [mranxc].
cargo clean Remove generated artifacts [z6lsud].
cargo verify-project Check correctness of crate manifest [zqzdsa].
cargo install Build and install a Rust binary [oor5mw].

[ddxps5] The Cargo Book, 2020, "cargo-init",, Retrieved 09.12.2020/07:12
[zo9q7e] The Cargo Book, 2020, "cargo-build",, Retrieved 09.12.2020/07:14
[uwnzht] The Cargo Book, 2020, "cargo-run",, Retrieved 09.12.2020/07:16
[mranxc] The Cargo Book, 2020, "cargo-update",, Retrieved 09.12.2020/07:18
[z6lsud] The Cargo Book, 2020, "cargo-clean",, Retrieved 09.12.2020/07:20
[zqzdsa] The Cargo Book, 2020, "cargo-clean",, Retrieved 09.12.2020/07:21
[oor5mw]The Cargo Book, 2020, "cargo-clean",, Retrieved 09.12.2020/07:23

A.84.a5 - Arch Linux

sudo pacman -R software Removing a Package from your System.
sudo pacman -Rcns softwarename Removing a Package with all Dependencies from your System.
sudo pacman -S softwarename Install a Package on your System.
sudo pacman -Syu Synchronising package Databases.
sudo pacman -Syy Synchronising package Databases.
sudo pacman -Scc Remove all Files from Cache and remove all unused Repositores.
sudo pacman -Suu Starting a full System Ugrade [tzo1mz].
sudo pacman -Rns Remove a Software completely [X3ofb].
sudo pacman -S foosoft Install a Software Package[445256].

[tzo1mz] slon, 17.01.2010, "Cleaning-optimazin arch-linux",, Retrieved 09.12.2020/07:07
[X3ofb] gapo, 04.05.2010, "How to completely uninstall an app?",, Retrieved 10.11.2020/22:30
[445256] Sidratul Muntaha, 2018, "How to Use Pacman on Arch Linux",, Retrieved 01.03.2021/17:18

A.84.a6 - Burn a OS ISO to a USB

sudo fdisk -l See what device name your OS given to the USB-Stick.
sudo mkfs.vfat -I /dev/sdb Format the USB-Stick in FAT32.
sudo dd bs=4M if=/path/to/distro.iso of=/dev/sdb status=progress oflag=sync Burn the ISO to your USB-Stick.

A.84.a7 - Game Developer

convert test.tga -crop 256x256 +repage result.tga Create the Half Life 1 Splash Screen.
cabextract .cab File extraction [79LQV].

[79LQV] John Sonmez, 18.01.2016, "Extract exe & cab files on Linux",, Retrieved 16.11.2020/17:19

A.84.a8 - Music and Video

ffmpeg -i file.mkv file.mp4 Convert .mkv video file to .mpf video file.
ffmpeg -f gif -i human.gif human.mp4 Convert .gif to .mp4 [hntGr].
ffmpeg -i test.mp3 -codec:a libvorbis -qscale:a 8 test.ogg Convert .mp3 file to .ogg. [24139r]
ffmpeg -i file.webm -c:v copy file.mp4 Convert .webm to .mp4. [136541]

[hntGr] stinkypyper, 12.06.2012, "How to do I convert an animated gif to an mp4 or mv4 on the command line?",, Retrieved 16.11.2020/17:23
[24139r] Howard Pritchett, 2006-2020, "Using ffmpeg to manipulate audio and video files - BASIC AUFDIO TRANSCODING",, Retrieved 24.11.2020/19:58
[136541] Remus Negrota, 03.10.2017, "Converting WebM to MP4 Using FFmpeg",, Retrieved: Fri Apr 9 15:54:51 2021

A.84.a9 - Vim

vim ~/.vimrc Open the vimrc file for global changes. [573637]
:set number Set line numbers. [987819]
:w! Forced safe. [357597]
$ Jump to the end of the line and with 0 to the bginning. [188683]
:colorsheme slate Change the editor colour scheme. [244323]
:23,42d Delete lines between line 23 and line 42. [637303]

[573637] Alvin Alexander, 19.03.2018, "How to set and use a vim color scheme",, Retrieved: Fri Apr 2 09:27:57 2021
[987819] Linuxize, 02.10.2020, "How to Show Line Numbers in Vim / Vi",, Retrieved: Fri Apr 2 09:31:59 2021
[357597] andrybak, 02.04.2019, "Hit the Esc key to enter "Normal mode"....",, Retrieved: Fri Apr 2 09:36:16 2021
[188683] Bram Moolenaar, 22.03.2021, "VIM REFERENCE MANUAL",, Retrieved: Fri Apr 2 09:40:28 2021
[244323] phoenixnap, 09.03.2021, "How to Change and Use Vim Color Schemes",, Retrieved: Fri Apr 2 11:40:21 2021
[637303] phoenicnap, 22.04.2021, "How to Delete Line in Vim on Linux",, Retrieved: Fri Apr 9 17:00:59 2021