From 57984ab217d20c4faadda2e2bdb0b9b9787f2068 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 18 Jul 2022 09:23:28 -0300 Subject: [PATCH] Adding files - arranging repo --- README.org | 33 +-- .../bash_tutorial.org | 34 --- tutorial/.#bash_tutorial.org | 1 - tutorial/add_user.org | 4 +- tutorial/bash_tutorial.org | 206 ------------------ tutorial/changeowner.org | 48 ++++ tutorial/convertppt2pdf.org | 19 +- tutorial/croc.org | 1 + tutorial/dd_command_flash_usb.org | 2 +- tutorial/describe_hardware.org | 2 + tutorial/dictionaries_translat.org | 2 + tutorial/display_files.org | 2 + tutorial/fancyfile.org | 1 + tutorial/files_directories.org | 1 + tutorial/gawk.org | 4 +- tutorial/listing_process.org | 2 + tutorial/manuals.org | 2 + tutorial/move_files.org | 4 +- tutorial/pandoc.org | 18 ++ tutorial/poppler.org | 28 +++ tutorial/redirect_output.org | 1 + tutorial/rmlint.org | 2 + tutorial/run_rscript.org | 4 +- tutorial/search_files.org | 2 + tutorial/sed_subsitute.org | 2 + tutorial/streaming_terminal.org | 2 + tutorial/variables.org | 2 + 27 files changed, 165 insertions(+), 264 deletions(-) rename tutorial/#bash_tutorial.org# => doc/bash_tutorial.org (71%) delete mode 120000 tutorial/.#bash_tutorial.org delete mode 100644 tutorial/bash_tutorial.org create mode 100644 tutorial/changeowner.org create mode 100644 tutorial/fancyfile.org create mode 100644 tutorial/pandoc.org create mode 100644 tutorial/poppler.org diff --git a/README.org b/README.org index 7f9254e..f0de200 100644 --- a/README.org +++ b/README.org @@ -1,24 +1,31 @@ * Bash tutorial - Tutorial with some basic commands, tips and options to use bash +Tutorial with some basic commands, tips and options to use bash. +[[https://www.gnu.org/software/bash/][Bash]] (Bourne Again Shell) is a shell commonly used on GNU-Linux systems for +multiple purposes. Knowing about bash is an enjoyable experience and a great +opportunity to learn about computers, files, directories and programs. * [[./tutorial/add_user.org][How to add users]] - * [[./tutorial/convertppt2pdf.org][Convert office files to pdf]] + * [[./tutorial/changeowner.org][Changing file permissions: 'chmod']] + * [[./tutorial/convertppt2pdf.org][How can I convert office files to pdf]] + * [[./tutorial/croc.org][Using 'croc' to tranfer files between machines]] * [[./tutorial/dd_command_flash_usb.org][Using dd command to flash usb]] * [[./tutorial/describe_hardware.org][Describing hardware]] * [[./tutorial/dictionaries_translat.org][Using dictionaries and translation tools]] - * [[./tutorial/gawk.org][GNU awk program]] + * [[./tutorial/display_files.org][Display files: 'less', 'head' and 'tail' commands]] + * [[./tutorial/files_directories.org][Learning about files and directories]] + * [[./tutorial/gawk.org][GNU-awk program: a nice tool!]] + * [[./tutorial/listing_process.org][Listing process]] * [[./tutorial/manuals.org][Reading the fabulous manuals!]] - * [[./tutorial/rmlint.org][Using 'rmlint' for cleaning your HD]] + * [[./tutorial/move_files.org][Move or rename files]] + * [[./tutorial/poppler.org][Convert markup text to multiple formats using 'pandoc']] + * [[./tutorial/poppler.org][Convert pdf to text or html using 'poppler']] + * [[./tutorial/redirect_output.org][What exactly are input, output and standard error?]] + * [[./tutorial/rmlint.org][Using 'rmlint' to clean your hard disk]] * [[./tutorial/run_bash_script.org][How to run bash scripts]] * [[./tutorial/run_rscript.org][How to run R-scripts]] - * [[./tutorial/streaming_terminal.org][Streaming from terminal!]] - * [[./tutorial/variables.org][Knowing about variables]] - * [[./tutorial/redirect_output.org][Input output and standard error]] - * [[./tutorial/files_directories.org][Exploring about files and directories]] - * [[./tutorial/sed_subsitute.org][Using 'sed' to subsitute text]] - * [[./tutorial/croc.org][Using 'croc' to tranfer files between machines]] - * [[./tutorial/move_files.org][Move or rename files]] * [[./tutorial/search_files.org][Searching files in the system]] - * [[./tutorial/listing_process.org][Listing process]] - * [[./tutorial/display_files.org][Display files: 'less', 'head' and 'tail' commands]] + * [[./tutorial/sed_subsitute.org][Using 'sed' editor to substitute text]] + * [[./tutorial/streaming_terminal.org][A really nice feature: streaming from terminal!]] + * [[./tutorial/variables.org][Knowing about variables]] + diff --git a/tutorial/#bash_tutorial.org# b/doc/bash_tutorial.org similarity index 71% rename from tutorial/#bash_tutorial.org# rename to doc/bash_tutorial.org index ba9e3bb..41b6b1c 100644 --- a/tutorial/#bash_tutorial.org# +++ b/doc/bash_tutorial.org @@ -26,40 +26,6 @@ The file can be found in the user home: -** Convert pdf to text or html using poppler - -Use poppler and redirect the text to a org file. -~pdftotext~ converts a pdf to "txt" if no other format is -specified - -: pdftotext foo.pdf foo - -: pacman -S poppler -: pdftotext foo.pdf ->> foo.org # first option -: pdftotext foo.pdf foo.org # second option - -Convert pdf to html - -: pfdftohtml foo.pdf foo.html - -** Convert files using pandoc - -Use pandoc with "-s" flag to produce a standalone document and "-o" to -redirect output to a file. - -In the example a file "foo" is converted from ~odt~ to ~org~ - -: pandoc -s -o foo.org foo.odt - -** Convert files to pdf using libreoffice - -Convert odt file "tcl_online3.odt" to pdf - -: libreoffice --headless --convert-to pdf tcl_online3.odt - - - - ** Backup a file Using "cp" diff --git a/tutorial/.#bash_tutorial.org b/tutorial/.#bash_tutorial.org deleted file mode 120000 index 4c86bb8..0000000 --- a/tutorial/.#bash_tutorial.org +++ /dev/null @@ -1 +0,0 @@ -compartido@compartido.3161:1656845041 \ No newline at end of file diff --git a/tutorial/add_user.org b/tutorial/add_user.org index 6e85e58..db745aa 100644 --- a/tutorial/add_user.org +++ b/tutorial/add_user.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Adding a new user Check users that are logged @@ -9,7 +11,7 @@ users #+RESULTS: : myuser -New user called "test" +Creating a new user called "test" #+begin_example bash sudo useradd -p -m test diff --git a/tutorial/bash_tutorial.org b/tutorial/bash_tutorial.org deleted file mode 100644 index 5c2960b..0000000 --- a/tutorial/bash_tutorial.org +++ /dev/null @@ -1,206 +0,0 @@ -#+TITLE: bash commands -#+DATE: 2021-08-30 -#+STARTUP: indent -#+OPTIONS: num:nil - -* DONE work in bash tutorial - :LOGBOOK: - CLOCK: [2021-09-08 mié 18:52]--[2021-09-08 mié 19:22] => 0:30 - CLOCK: [2021-09-04 sáb 16:04]--[2021-09-04 sáb 16:34] => 0:30 - CLOCK: [2021-09-04 sáb 15:19]--[2021-09-04 sáb 15:49] => 0:30 - :END: - - - -* Execute stuffs - - -* Show command history - -: history - -The file can be found in the user home: - -: /home/user/.bash_history - - - - -** Convert pdf to text or html using poppler - -Use poppler and redirect the text to a org file. -~pdftotext~ converts a pdf to "txt" if no other format is -specified - -: pdftotext foo.pdf foo - -: pacman -S poppler -: pdftotext foo.pdf ->> foo.org # first option -: pdftotext foo.pdf foo.org # second option - -Convert pdf to html - -: pfdftohtml foo.pdf foo.html - -** Convert files using pandoc - -Use pandoc with "-s" flag to produce a standalone document and "-o" to -redirect output to a file. - -In the example a file "foo" is converted from ~odt~ to ~org~ - -: pandoc -s -o foo.org foo.odt - -** Convert files to pdf using libreoffice - -Convert odt file "tcl_online3.odt" to pdf - -: libreoffice --headless --convert-to pdf tcl_online3.odt - - - -** Display files - -Show content of a file. Concatenates and writes file. -Using "tac" reverses the result of "cat" command - -: cat file.txt - -Using head, tail and less to show parts of files - -Showing the first two entries - -#+begin_src bash - head -n 2 /etc/hosts -#+end_src - - #+RESULTS: - | 127.0.0.1 | localhost | - | 127.0.1.1 | myuser | - - Showing the last two entries - - #+begin_src bash - tail -n 2 /etc/hosts - #+end_src - - #+RESULTS: - | ff02::1 | ip6-allnodes | - | ff02::2 | ip6-allrouters | - - - #+begin_src bash - less /etc/hosts - #+end_src - - #+RESULTS: - | 127.0.0.1 | localhost | | | - | 127.0.1.1 | myuser | | | - | ::1 | localhost | ip6-localhost | ip6-loopback | - | ff02::1 | ip6-allnodes | | | - | ff02::2 | ip6-allrouters | | | - - -Show content of a zip file using less and pipe "|" - -#+begin_src bash -unzip -l tntvillage_484094.zip | less -#+end_src - -** Backup a file - - Using "cp" - - : cp bbdb{,.bak} - - : bbdb.bak - - Backups with tar (tape archiver) - - Back up of "home" - - * c = create file - * v = verbose - * f = write to a file/device - * z = compress the file (gzip) "tar.bz" - * j = compress the file (bzip2) - - : tar -czvf /tmp/home.tar.gz /home - -** Simple code to encrypt - - Encrypt: - - : gpg -c X - : gpg X - - Use the code to remove the original file: - - : shred --remove X - - -** Download files - -This code download the file and the argument ~-O~ is to rename the file - -#+begin_example -wget https://filetodownload.org -O new_file -#+end_example - -* Devices - -- mount /what /where - - what = device name - - where = directory - - /mnt = devices that mount occasionally - - /media = devices that mount frequently - -: run/$USER/media/$LABEL - -* List process - -Use ~ps~, ~top~ or ~htop~ to list process: - - * ~ps~ reports a snapshot of the current process - -: ps aux | less - - * ~top~ display dynamic real-time view of linux process - -: top - - * ~htop~ displays an interactive process viewer - -: htop - -To kill a process use: - -: kill [PID] - -or - -: pkill [PID] - -PID = process identificator - -* Evaluate time to load - -In emacs: - -: time emacs --eval '(save-buffers-kill-terminal)' - -* Cool commands - -: cal # calendar -: clear # clear output -: uname # display system information (-r, -p, -a) -: wc # wordcount (file name) -: date # check the date - - -* References: - - * [[https://wiki-dev.bash-hackers.org/][The bash hackers wiki]] - * [[https://link.springer.com/content/pdf/bfm%3A978-1-4302-6829-1%2F1.pdf?error=cookies_not_supported&code=2e41714e-ca8f-4796-a077-3243c836ec90][Beginning the linux command line]] - * [[https://pandoc.org/][Pandoc manual]] - * [[https://stackoverflow.com/][stackoverflow]] diff --git a/tutorial/changeowner.org b/tutorial/changeowner.org new file mode 100644 index 0000000..0f03217 --- /dev/null +++ b/tutorial/changeowner.org @@ -0,0 +1,48 @@ +#+options: toc:nil num:nil author:nil + +* Changing permissions for files and directories + +There are three types of permissions for files and directories in the system: + +1. Read ('r') +2. Write ('w') +3. Execute ('x') + +The permissions can be differente for users: owner - group - others + +** Creating a file and checking permissions + +Here we create a file with the sentence "this is a fancy file". The sentence is +redirected to the name "fancyfile.org" and a new file is created! + +#+begin_src bash +echo "this is a fancy file" > fancyfile.org +#+end_src + +#+RESULTS: + +In the ouptut of ~ls~ command, there letters showing each permission for each user: owner, group, others, respectively. + +#+begin_src bash + ls -la fancyfile.org +#+end_src + +#+RESULTS: +: -rw-r--r-- 1 compartido compartido 21 jul 18 06:06 fancyfile.org + +** Settings permissions for the file + +#+begin_src bash + chmod o=r,g=rw,o=r fancyfile.org +#+end_src + +#+RESULTS: + +Then it changed! + +#+begin_src bash + ls -la fancyfile.org +#+end_src + +#+RESULTS: +: -rw-rw-r-- 1 compartido compartido 21 jul 18 06:06 fancyfile.org diff --git a/tutorial/convertppt2pdf.org b/tutorial/convertppt2pdf.org index acf2df5..a112baf 100644 --- a/tutorial/convertppt2pdf.org +++ b/tutorial/convertppt2pdf.org @@ -1,16 +1,27 @@ +#+options: toc:nil num:nil author:nil + * How to convert office documents to text -You may use libreoffice from terminal to tranform the file in pdf: +** From office document to pdf and then to plain text + +You may use libreoffice from terminal to transform the file in pdf: #+begin_example sh libreoffice --headless --convert-to pdf Presentation.pptx #+end_example - -Then you can use 'pdftotext' command to transform the pdf file to any plain text -format: +Then from a pdf you can use 'pdftotext' command to transform the pdf file to any +plain text format: #+begin_example sh pdftotext Presentation.pdf Presentation.txt #+end_example + +** One more example: convert odf files to pdf using libreoffice + +Convert odt file "tcl_online3.odt" to pdf + +#+begin_src bash + libreoffice --headless --convert-to pdf tcl_online3.odt +#+end_src diff --git a/tutorial/croc.org b/tutorial/croc.org index 77526d9..130d2d1 100644 --- a/tutorial/croc.org +++ b/tutorial/croc.org @@ -1,3 +1,4 @@ +#+options: toc:nil num:nil author:nil * Send files to another machine with "croc" diff --git a/tutorial/dd_command_flash_usb.org b/tutorial/dd_command_flash_usb.org index 90cef74..acdc153 100644 --- a/tutorial/dd_command_flash_usb.org +++ b/tutorial/dd_command_flash_usb.org @@ -1,3 +1,4 @@ +#+options: toc:nil num:nil author:nil ** Flashing USB with "dd" @@ -20,4 +21,3 @@ An example with parabola: The ISO image is copied to "sdb1" (USB volume) -More files with examples of use of "dd" [../bash/dd_command.org][here]] and [[~/Documentos/GNU/bash/dd_command_wiki.org][here]] diff --git a/tutorial/describe_hardware.org b/tutorial/describe_hardware.org index 3ec35e5..8cfac37 100644 --- a/tutorial/describe_hardware.org +++ b/tutorial/describe_hardware.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Describe hardware Here using piping to show only the first four lines in the output diff --git a/tutorial/dictionaries_translat.org b/tutorial/dictionaries_translat.org index 20841e3..6e76411 100644 --- a/tutorial/dictionaries_translat.org +++ b/tutorial/dictionaries_translat.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Translators and dictionaries ** Apertium translator diff --git a/tutorial/display_files.org b/tutorial/display_files.org index 403138f..644f8c7 100644 --- a/tutorial/display_files.org +++ b/tutorial/display_files.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Display files Show content of a file. Concatenates and writes file. diff --git a/tutorial/fancyfile.org b/tutorial/fancyfile.org new file mode 100644 index 0000000..5f3e9be --- /dev/null +++ b/tutorial/fancyfile.org @@ -0,0 +1 @@ +this is a fancy file diff --git a/tutorial/files_directories.org b/tutorial/files_directories.org index 886bf6b..e24bc69 100644 --- a/tutorial/files_directories.org +++ b/tutorial/files_directories.org @@ -1,3 +1,4 @@ +#+options: toc:nil num:nil author:nil * Files and directories diff --git a/tutorial/gawk.org b/tutorial/gawk.org index 4efc0c5..8eb86bb 100644 --- a/tutorial/gawk.org +++ b/tutorial/gawk.org @@ -1,10 +1,10 @@ #+TITLE: Using gawk in command-line #+DATE: 2022-03-15 -#+OPTIONS: num:nil toc:nil -#+AUTHOR: Jose +#+OPTIONS: num:nil toc:nil author:nil #+PROPERTY: header-args:bash :exports both :session *bsh* :tangle yes #+PROPERTY: header-args:bash+ :cmdline :results output + * gawk stands for GNU-awk ~awk~ is a data driven program that search text in files using a pattern. After finding the pattern diff --git a/tutorial/listing_process.org b/tutorial/listing_process.org index 843e830..4735d4b 100644 --- a/tutorial/listing_process.org +++ b/tutorial/listing_process.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * List process Use ~ps~, ~top~ or ~htop~ to list process: diff --git a/tutorial/manuals.org b/tutorial/manuals.org index 5cebb23..cd43a3e 100644 --- a/tutorial/manuals.org +++ b/tutorial/manuals.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Manuals To explore the manuals use the command ~man~ or ~info~ followed by the name of the function or program diff --git a/tutorial/move_files.org b/tutorial/move_files.org index 12e56d6..0ad9ba6 100644 --- a/tutorial/move_files.org +++ b/tutorial/move_files.org @@ -1,4 +1,6 @@ -* Move or rename +#+options: toc:nil num:nil author:nil + +* Move or rename files Use "~mv~ source destination" command diff --git a/tutorial/pandoc.org b/tutorial/pandoc.org new file mode 100644 index 0000000..597fc4e --- /dev/null +++ b/tutorial/pandoc.org @@ -0,0 +1,18 @@ +#+options: toc:nil num:nil author:nil + +* Convert files using pandoc + +Use pandoc with "-s" flag to produce a standalone document and "-o" to redirect +output to a file. + +In the example a file "foo" is converted from ~odt~ to ~org~ + +#+begin_src bash + pandoc -s -o foo.org foo.odt +#+end_src + +Check the manual for more information: + +#+begin_example bash + man pandoc +#+end_src diff --git a/tutorial/poppler.org b/tutorial/poppler.org new file mode 100644 index 0000000..cb9b844 --- /dev/null +++ b/tutorial/poppler.org @@ -0,0 +1,28 @@ +#+options: toc:nil num:nil author:nil + +* Convert pdf to text or html using poppler + +Use poppler and redirect the text to a org file. ~pdftotext~ converts a pdf to +"txt" if no other format is specified + +#+begin_src bash + pdftotext foo.pdf foo +#+end_src + +Install poppler in Parabola GNU-Linux + +#+begin_src bash + pacman -S poppler +#+end_src + +#+begin_src bash + pdftotext foo.pdf ->> foo.org # first option + pdftotext foo.pdf foo.org # second option +#+end_src + +Convert pdf to html + +#+begin_src bash + pfdftohtml foo.pdf foo.html +#+end_src + diff --git a/tutorial/redirect_output.org b/tutorial/redirect_output.org index 390edb3..512dfb2 100644 --- a/tutorial/redirect_output.org +++ b/tutorial/redirect_output.org @@ -1,3 +1,4 @@ +#+options: toc:nil num:nil author:nil * Redirect input, output and standard error diff --git a/tutorial/rmlint.org b/tutorial/rmlint.org index c9d6dde..45fb08c 100644 --- a/tutorial/rmlint.org +++ b/tutorial/rmlint.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Use rmlint to search for duplicated or empty files ** Install in Parabola GNU-linux diff --git a/tutorial/run_rscript.org b/tutorial/run_rscript.org index 0f3c47e..efc6064 100644 --- a/tutorial/run_rscript.org +++ b/tutorial/run_rscript.org @@ -1,8 +1,10 @@ +#+options: toc:nil num:nil author:nil + * Run R scripts Write the script and save it. Then go to the directory where the script was saved and run this code from terminal #+begin_src bash -Rscript script.R + Rscript script.R #+end_src diff --git a/tutorial/search_files.org b/tutorial/search_files.org index dc3eb49..f6cd109 100644 --- a/tutorial/search_files.org +++ b/tutorial/search_files.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Searching ** Search for files diff --git a/tutorial/sed_subsitute.org b/tutorial/sed_subsitute.org index 6ffabee..50dca8d 100644 --- a/tutorial/sed_subsitute.org +++ b/tutorial/sed_subsitute.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Using 'sed' to substitute text "~sed~" is a stream editor for filtering and transforming text"... diff --git a/tutorial/streaming_terminal.org b/tutorial/streaming_terminal.org index 59f2e3c..8a13b34 100644 --- a/tutorial/streaming_terminal.org +++ b/tutorial/streaming_terminal.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Streaming from terminal To watch a stream use video player such as 'mpv' or 'vlc' that supports streaming diff --git a/tutorial/variables.org b/tutorial/variables.org index 2b44cd6..6182567 100644 --- a/tutorial/variables.org +++ b/tutorial/variables.org @@ -1,3 +1,5 @@ +#+options: toc:nil num:nil author:nil + * Variables and how to add a directory to $PATH System variables are stored in users environment