Adding files - arranging repo

This commit is contained in:
Jose 2022-07-18 09:23:28 -03:00
parent 7e4c82d12a
commit 57984ab217
27 changed files with 165 additions and 264 deletions

View File

@ -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]]

View File

@ -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"

View File

@ -1 +0,0 @@
compartido@compartido.3161:1656845041

View File

@ -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

View File

@ -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]]

48
tutorial/changeowner.org Normal file
View File

@ -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

View File

@ -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

View File

@ -1,3 +1,4 @@
#+options: toc:nil num:nil author:nil
* Send files to another machine with "croc"

View File

@ -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]]

View File

@ -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

View File

@ -1,3 +1,5 @@
#+options: toc:nil num:nil author:nil
* Translators and dictionaries
** Apertium translator

View File

@ -1,3 +1,5 @@
#+options: toc:nil num:nil author:nil
* Display files
Show content of a file. Concatenates and writes file.

1
tutorial/fancyfile.org Normal file
View File

@ -0,0 +1 @@
this is a fancy file

View File

@ -1,3 +1,4 @@
#+options: toc:nil num:nil author:nil
* Files and directories

View File

@ -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

View File

@ -1,3 +1,5 @@
#+options: toc:nil num:nil author:nil
* List process
Use ~ps~, ~top~ or ~htop~ to list process:

View File

@ -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

View File

@ -1,4 +1,6 @@
* Move or rename
#+options: toc:nil num:nil author:nil
* Move or rename files
Use "~mv~ source destination" command

18
tutorial/pandoc.org Normal file
View File

@ -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

28
tutorial/poppler.org Normal file
View File

@ -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

View File

@ -1,3 +1,4 @@
#+options: toc:nil num:nil author:nil
* Redirect input, output and standard error

View File

@ -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

View File

@ -1,3 +1,5 @@
#+options: toc:nil num:nil author:nil
* Run R scripts
Write the script and save it. Then go to the directory where the script

View File

@ -1,3 +1,5 @@
#+options: toc:nil num:nil author:nil
* Searching
** Search for files

View File

@ -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"...

View File

@ -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

View File

@ -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