diff --git a/README.org b/README.org index 003133d..437497e 100644 --- a/README.org +++ b/README.org @@ -34,7 +34,7 @@ opportunity to learn about computers, files, directories and programs. * [[./tutorial/files_directories.org][Learning about files and directories]] * [[./tutorial/rsync.org][Using rsync to copy files]] * [[./tutorial/search_files.org][Searching for files in the system]] - * [[./tutorial/diff.org][Comparing two files or directories: 'diff']] + * [[./tutorial/diff.org][Comparing two files or directories: 'diff']] * [[./tutorial/diff_patch.org][Comparing two files and create a unified version: diff and patch]] * [[./tutorial/dd_command_flash_usb.org][Using dd command to flash usb]] * [[./tutorial/compress_pdf.org][Compress a pdf file]] @@ -42,10 +42,14 @@ opportunity to learn about computers, files, directories and programs. * [[./tutorial/pacman.org][Use package manager in Parabola GNU-linux: verify packages in cache]] * [[./tutorial/removing_packages.org][Removing packages in Parabola GNU-Linux]] +** Secure shell ssh and file transfer + + * [[./tutorial/copy_server.org][Transfering files between machines]] + ** Work with images * [[./tutorial/image_size_reduction.org][Reduce image quality and size from terminal]] - + ** Disk space utilization and manipulation * [[./tutorial/ncdu.org][Exploring disk space with 'ncdu']] diff --git a/tutorial/copy_server.org b/tutorial/copy_server.org new file mode 100644 index 0000000..c260f84 --- /dev/null +++ b/tutorial/copy_server.org @@ -0,0 +1,64 @@ +#+date: 2023-08-20 +#+options: toc:nil num:nil author:nil + +* Transfering files + +Let's say you want to transfer files, images or directories between a local +machine and a server. What could be a good option? + +There are multiple free software options to transfer file between machines: + + * [[https://wiki.archlinux.org/title/Rsync][rsync]] + * [[https://man.archlinux.org/man/sftp.1.en][sftp]] (secury file transfer protocol) + * [[https://wiki.archlinux.org/title/SCP_and_SFTP][scp]] (secure copy protocol) + +** rsync + +For example: transfering all the ~.jpg~ files in the directory to a server: + +#+begin_example sh + rsync -a -P -e "ssh -p 2222" ./*.jpg root@186.76.90.145:/root/img/ +#+end_example +** scp + +** Using ~sftp~ to copy files + +~sftp~ can be used to transfer files from a local machine to a server. The +protocol allows to access the server, visualize, manipulate and transfer +files from and to a server. You need to configure ~ssh~ access to the +server from your local machine. + +A server can be accessed from a local machine following this logic: + +#+begin_example sh + sftp -P 2222 root@186.76.90.145 +#+end_example + +The command ~sftp~ followed by the port and user@ip_address. + +After accessing the server, files can be download from the server: + +#+begin_example sh + sftp> get file_in_server +#+end_example + +You can also transfer files to the server: + +#+begin_example sh + sftp> put file_in_local_machine +#+end_example + + +To exit from ~sftp~ use: + +#+begin_example sh + sftp> put file_in_local_machine +#+end_example + +There are additional options to use ~sftp~. Check the manual to know more about: + +#+begin_example sh + info sftp +#+end_example + +** References diff --git a/tutorial/image_size_reduction.org b/tutorial/image_size_reduction.org index c54f307..0be960a 100644 --- a/tutorial/image_size_reduction.org +++ b/tutorial/image_size_reduction.org @@ -3,14 +3,32 @@ * Use imagemagick to manipulate images +[[https://imagemagick.org/][ImageMagick]] is a suite of tools used for digital image edition and manipulation. +The tools can be used in the command line (~cli~). + +There are multiple functionalities avaliable in ImageMagick. Commands like ~convert~, +~mogrify~ and ~identify~ are just some of the useful tools available. + +** Using the ~convert~ command Converting multiple ~jpg~ files into lower size images: +First, [][cd] into the directory containing all the images +#+begin_example sh + cd directory +#+end_example + +Then use ~convert~ to resize all the 'jpg' files within the directory: + #+begin_example sh convert '*.jpg' -set filename:fn '%[basename]-small' -resize 960x640 '%[filename:fn].jpg' #+end_example -convert -quality 10% +Here the '%[basename]-small' will copy original files, resize and rename including +the suffix "small" to the original name. + +Reduce quality using convert (the command is similar to the previous one, but +it uses ~-quality~ instead of ~-resize~) #+begin_example sh convert '*.jpg' -set filename:fn '%[basename]-small' -quality 50% '%[filename:fn].jpg' @@ -18,17 +36,29 @@ convert -quality 10% ** Using mogrify +~mogrofy~ can be used for similar purposes. + +Let's check som images in a directory to verify how much those images can be +modified. + +Change directory use the commands in the same place were the images are included, +e.g: + +#+begin_example sh + cd directory +#+end_example + Counting number of ~.jpg~ images in a directory: #+begin_example sh ls -1U DIR_NAME | wc -l #+end_example -Output: +Verify the output: -75 +75 -Verifying the images weight: +Verifying the images weight of all the images: #+begin_example sh du -h @@ -48,6 +78,8 @@ Output: 42M +Reduce the quality of all the images within the directory: + #+begin_example sh mogrify -quality 80% *.jpg #+end_example @@ -62,9 +94,54 @@ Output: 12M +** Remove some metada from images + +[[https://imagemagick.org/script/command-line-options.php#strip][`mogrify -strip`]]can be used to remove some metada from the images. + +First you can check the image metada using the command ~identify~ from Imagemagick. + +#+begin_example sh + identify -verbose image.jpg +#+end_example + +This command will print an output like this: + + # Filename: image.jpg + # Permissions: rw-r--r-- + # Format: JPEG (Joint Photographic Experts Group JFIF format) + # Mime type: image/jpeg + # Class: DirectClass + # Geometry: 960x640+0+0 + # Resolution: 72x72 + # Print size: 13.3333x8.88889 + # Units: PixelsPerInch + # Colorspace: sRGB + # Type: TrueColor + # Base type: Undefined + # Endianness: Undefined + # Depth: 8-bit + # Channels: 3.0 + # Channel depth: + # Red: 8-bit + # Green: 8-bit + # Blue: 8-bit + # Channel statistics: + # Pixels: 614400 + # ... + # ... + # Version: ImageMagick 7.1.1-12 Q16-HDRI x86_64 21239 https://imagemagick.org + +You can use ~mogrify~ to remove metada from one or multiple images using +something like: + +#+begin_example sh + mogrify -strip ./image.jpg # one image + mogrify -strip ./*.jpg # modifiyng all 'jpg' files in directory +#+end_example + + ** References - [[https://askubuntu.com/questions/1354205/imagemagick-convert-on-a-multiple-files][Imagemagick to convert multiple files]] - [[https://imagemagick.org/][Imagemagick web site]] - [[https://www.digitalocean.com/community/tutorials/reduce-file-size-of-images-linux][Digital ocean tutorial]] -