Command line

Command line interface

Command function
pkill avrdude stop Arduino IDE trying to upload
zip -r filename.zip directory use the -r flag when zipping a directory
zip filename.zip filename.dfx zip a file. First name the zip file to be created, them the file to be zipped.
ls -lh * Show file size in directory (-l) in human readable form (h) all of them (*)
du -sh print file size
dpkg -L “packagename” where is package installed
ls -la list + hidden files
mv change directory mv foo dir1
pwd Print Working Directory. (Where you are). Trick: copy output of pwd and paste in browser
cp copy cp foo.txt bar.txt
cp foo.txt Foo/Bar/ (copy file to directory. Slash not before but after)
cp foo.txt bar.txt foo/ (copy 2 files to directory foo)
cp *.txt foo/ (copy all txt files to dir foo)
cp -R directory/ foo (copy directory to foo)
rm remove file
rm -R remove dir + contents
cd change directory
cd enter back to primary folder
cd .. up one folder
clear empty terminal
~ represents /home/user/
dpkg -l freecad* checking which packages are installed on your system ii & un
CTRL-R With arrow up you call up previous command. With CTRL-R you can search recent commands. Use Tab to select the command. Thanks Henk :)

nano

command function
ALT + M Enable mouse support (mostly to move the cursor. Enabling disables scroll function
ALT+SHIFT+4 softwrap text in nano
copy/paste
ctrl-6 set mark move arrows to select text
alt-shift-6 copy
ctrl-u paste
ctrl-k cut
ctrl-u paste
Copy paste between different files Working in foo & copy from bar
nano -F foo
CTRL-R open new file ~/Doc/Fab/bar.md
CTRL-6
ESC-6
CTRL-X closes file2
CTRL-U paste
CTRL-O write out
or vice versa: working in foo copying too bar
nano -F foo
ctrl-6 set mark
Esc-6 copy
CTRL-R open new file ~/Doc/Fab/bar.md
CTL-U paste
CTL-O write out
CTRL-X close file2

MkDocs

command function
mkdocs serve returns IP-address to run site locally
mkdocs serve –no-livereload When error loading page this might help.

Markdown

command function
Hit enter twice before summing up and it becomes more spacious No enter is condense summing up.
[Downloadable FCStd](../files/week03/celestial/celestial.FCStd) Adding source files
![](https://youtu.be/zNzZ1PfUDNk) embedding Youtube video
<iframe width="560" height="315" src="https://www.youtube.com/embed/lVKbF8khsrI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> embedding Youtube video: clicking embed in Youtube and copying the HTML text works better than the markdown code.
![](https://vimeo.com/142172484) embedding Vimeo video
![](https://player.vimeo.com/video/142172484) embedding Vimeo video
![](https://youtu.be/zNzZ1PfUDNk){width="90%"} adjusting size of embedded video
![](https://youtu.be/zNzZ1PfUDNk){width="560" height="315"} adjusting size of embedded video
two spaces line break
two enters new paragraph (empty line)
code inline code gets backspaces
```console / "code / ``` renders code in separate block (/ is line break)
```"programlanguage" / "code" / ``` renders the code in that language (html, python, etc)
<del>text</del> strike through
link word
link without word wrap in angle brackets
`< angle brackets are invisible by default. Wrap in back ticks
**x** bold
*X* italics
: indent
> citation stripe
:> indent + citation stripe
![](../images/dir/imagefile.jpg) insert image (note: 1 or 2 dots in string)
<img src="./images/home/file-name.png"> HTML image add. Seems to work better
Above line + 2 spaces, next line *Image caption* Image caption below image
![image alt >](/image-right.jpg) image align right
![image alt <](/image-left.jpg) image align left
![image alt ><](/center-image.jpg) image align center

HTML

Example image:

<img src="./images/home/image-name.jpg" alt="alternate text" style="padding: 0px 10px; float:right">

It has padding, an alt text and align-right.
padding configuration: 0px 10px 20px 10px = top, right, bottom, left.

Caption. Note: does not work with align-right

<figure>
    <img src='./images/home/waag.jpg' alt='waag' />
    <figcaption>Caption goes here</figcaption>
</figure>
command function
<div style="text-align: right"> your text here </div> text align
<br> next line

Git

$ git status
$ git add <file>
$ git status
$ git commit -m "addyourcomment"
$ git status
$ git push
$ git status
command function
git add . add all the files at once
git diff see what changes you made to the file.
git diff –cached see what changes you are about to commit (after git add)
git commit -a This skips the add step. All modified files will be added
git log view project history. NOTE: CTRl-C does not work to get you out of the log. Hitting Q does.
git log -p shows complete diffs as well
gitk open GUI
Git pipeline fails after push Go to Gitlab > CI / CD > pipelines. Click the ‘redo’ arrow at the right of the pipeline.

ImageMagick

command function
list formats:
import -window root /path/file.png import entire screen
import /path/file.jpg define which part to import
convert -list format
convert input.jpg output.png convert JPG to PNG
mogrify -format png *.jpg convert all JPGs to PNGs:
convert -density 1000 -units PixelsPerInch input.svg output.png convert SVG to PNG at 1000 DPI
convert input.jpg -quality 50% -resize 1000 output.jpg compress JPG to quality 50% width 1000
mogrify -quality 50% -resize 1000 *.jpg compress all JPGs to quality 50% width 1000:
Rotate? Gimp it! MkDocs rotates pics to landscape. Open in Gimp & it will ask to rotate. Rotate + save
PDF rightclick open with Imagemagick Export PDF as individual jpg
convert NAME.pdf NAME.jpg converts .pdf to .jpg. But for this to work you need to make changes in the policy file: set <policy domain="coder" rights="none" pattern="PDF" /> to <policy domain="coder" rights="read|write" pattern="PDF" />. Find the policy.xml file in /etc/ImageMagick-6/policy.xml

Video tools
Ffmpeg commands https://www.labnol.org/internet/useful-ffmpeg-commands/28490/.
Compression with ffmpeg: https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg
Open Shot fast keys https://cdn.openshot.org/static/files/user-guide/main_window.html) (scroll down quite a bit

Adding video

<figure class="video_container">
  <video width="640" height="360" controls="true" allowfullscreen="true" poster="/images/week14/esp-mesh/esp-mesh-eeschema.jpg">
    <source src="/placeholder.mp4" type="video/mp4">
  </video>
</figure>

(Source)

Ffmpeg

command function
ffmpeg -i input-file.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output-file.webm convert to .webm

Compression commands: This one worked the best: it uses the newer video format h265 instead of h264 and compressed three times better than the command below it using h264 (on the video I tested). On this StakingExchange it is explained in the comments. It also explains how to reduce the video even more twiddling with the -crf flag. Increasing the CRF number reduces the file size.
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

This ffmpeg compression commmand is listed on the FabAcademy site together with other ffmpeg tips.

ffmpeg -i input.mp4 -vcodec libx264 -crf 25 -preset medium -vf scale=-2:1080 -acodec libmp3lame -q:a 4 -ar 48000 -ac 2 output.mp4 | compress video

ncdu

command function
ncdu analuzes harddisk returns largest files on top.
arrows up down navigate files
i see details of selected items
right arrow enter look inside folder
ncdu directory/ displays size of directory
sudo ncdu -x / analyze entire root system