Browse Source

ls doc

master
zeus 4 years ago
parent
commit
84f19e49ff
  1. 20
      index-lab.adoc
  2. 72
      index-lab.adoc.html
  3. 2341
      index-lab.adoc.pdf
  4. 345
      labs/ls/ex-1_ls.adoc
  5. 1139
      labs/ls/ex-1_ls.adoc.html
  6. 9258
      labs/ls/ex-1_ls.adoc.pdf
  7. 8
      labs/ls/index.html

20
index-lab.adoc

@ -53,6 +53,26 @@ Containers are isolated from one another and bundle their own software, librarie
:!hardbreaks: :!hardbreaks:
== LINUX
=== http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/ex-1_ls.adoc.html[An Introduction to Linux^]
TIP: Absolute basics
:hardbreaks:
{empty} +
{empty} +
{empty}
:!hardbreaks:
== Internet of things (IoT) == Internet of things (IoT)

72
index-lab.adoc.html

@ -454,23 +454,28 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<li><a href="#_install_docker">1.1. Install docker</a></li> <li><a href="#_install_docker">1.1. Install docker</a></li>
</ul> </ul>
</li> </li>
<li><a href="#_internet_of_things_iot">2. Internet of things (IoT)</a> <li><a href="#_linux">2. LINUX</a>
<ul class="sectlevel2"> <ul class="sectlevel2">
<li><a href="#_intro_iot">2.1. Intro IoT</a></li> <li><a href="#_an_introduction_to_linux">2.1. An Introduction to Linux</a></li>
</ul> </ul>
</li> </li>
<li><a href="#_security">3. Security</a> <li><a href="#_internet_of_things_iot">3. Internet of things (IoT)</a>
<ul class="sectlevel2"> <ul class="sectlevel2">
<li><a href="#_scan_and_network_statistics">3.1. Scan and network statistics</a></li> <li><a href="#_intro_iot">3.1. Intro IoT</a></li>
<li><a href="#_network_analysis">3.2. Network analysis</a></li> </ul>
<li><a href="#_network_filter">3.3. Network Filter</a> </li>
<li><a href="#_security">4. Security</a>
<ul class="sectlevel2">
<li><a href="#_scan_and_network_statistics">4.1. Scan and network statistics</a></li>
<li><a href="#_network_analysis">4.2. Network analysis</a></li>
<li><a href="#_network_filter">4.3. Network Filter</a>
<ul class="sectlevel3"> <ul class="sectlevel3">
<li><a href="#_traversing_of_tables_and_chains">3.3.1. Traversing of tables and chains</a></li> <li><a href="#_traversing_of_tables_and_chains">4.3.1. Traversing of tables and chains</a></li>
</ul> </ul>
</li> </li>
<li><a href="#_iptables_with_shorewall_three_interface_firewall">3.4. Iptables with shorewall! - Three-Interface Firewall</a></li> <li><a href="#_iptables_with_shorewall_three_interface_firewall">4.4. Iptables with shorewall! - Three-Interface Firewall</a></li>
<li><a href="#_virtual_private_network_vpn">3.5. virtual private network (VPN)</a></li> <li><a href="#_virtual_private_network_vpn">4.5. virtual private network (VPN)</a></li>
<li><a href="#_ssh_tunneling">3.6. SSH Tunneling</a></li> <li><a href="#_ssh_tunneling">4.6. SSH Tunneling</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -530,10 +535,35 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
</div> </div>
</div> </div>
<div class="sect1"> <div class="sect1">
<h2 id="_internet_of_things_iot">2. Internet of things (IoT)</h2> <h2 id="_linux">2. LINUX</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_an_introduction_to_linux">2.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/ex-1_ls.adoc.html" target="_blank" rel="noopener">An Introduction to Linux</a></h3>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
Absolute basics
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p><br>
<br>
</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_internet_of_things_iot">3. Internet of things (IoT)</h2>
<div class="sectionbody"> <div class="sectionbody">
<div class="sect2"> <div class="sect2">
<h3 id="_intro_iot">2.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/IoT/Intro-IoT.adoc.html" target="_blank" rel="noopener">Intro IoT</a></h3> <h3 id="_intro_iot">3.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/IoT/Intro-IoT.adoc.html" target="_blank" rel="noopener">Intro IoT</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -555,7 +585,7 @@ How It Works, Apps, Swarm: The Five Principles of Swarm Intelligence
</div> </div>
</div> </div>
<div class="sect1"> <div class="sect1">
<h2 id="_security">3. Security</h2> <h2 id="_security">4. Security</h2>
<div class="sectionbody"> <div class="sectionbody">
<div class="exampleblock"> <div class="exampleblock">
<div class="content"> <div class="content">
@ -587,7 +617,7 @@ How It Works, Apps, Swarm: The Five Principles of Swarm Intelligence
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_scan_and_network_statistics">3.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-1_iptables.adoc.html" target="_blank" rel="noopener">Scan and network statistics</a></h3> <h3 id="_scan_and_network_statistics">4.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-1_iptables.adoc.html" target="_blank" rel="noopener">Scan and network statistics</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -602,7 +632,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_network_analysis">3.2. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-2_iptables.adoc.html" target="_blank" rel="noopener">Network analysis</a></h3> <h3 id="_network_analysis">4.2. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-2_iptables.adoc.html" target="_blank" rel="noopener">Network analysis</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -617,7 +647,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_network_filter">3.3. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-3_iptables.adoc.html" target="_blank" rel="noopener">Network Filter</a></h3> <h3 id="_network_filter">4.3. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-3_iptables.adoc.html" target="_blank" rel="noopener">Network Filter</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -636,7 +666,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</table> </table>
</div> </div>
<div class="sect3"> <div class="sect3">
<h4 id="_traversing_of_tables_and_chains">3.3.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-3a_iptables-flow-chart.adoc.html" target="_blank" rel="noopener">Traversing of tables and chains</a></h4> <h4 id="_traversing_of_tables_and_chains">4.3.1. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-3a_iptables-flow-chart.adoc.html" target="_blank" rel="noopener">Traversing of tables and chains</a></h4>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -657,7 +687,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_iptables_with_shorewall_three_interface_firewall">3.4. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-4_iptables.adoc.html" target="_blank" rel="noopener">Iptables with shorewall! - Three-Interface Firewall</a></h3> <h3 id="_iptables_with_shorewall_three_interface_firewall">4.4. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-4_iptables.adoc.html" target="_blank" rel="noopener">Iptables with shorewall! - Three-Interface Firewall</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -674,7 +704,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_virtual_private_network_vpn">3.5. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-5_iptables.adoc.html" target="_blank" rel="noopener">virtual private network (VPN)</a></h3> <h3 id="_virtual_private_network_vpn">4.5. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-5_iptables.adoc.html" target="_blank" rel="noopener">virtual private network (VPN)</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -691,7 +721,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
</div> </div>
<div class="sect2"> <div class="sect2">
<h3 id="_ssh_tunneling">3.6. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-6_iptables.adoc.html" target="_blank" rel="noopener">SSH Tunneling</a></h3> <h3 id="_ssh_tunneling">4.6. <a href="http://docs.swarmlab.io/SwarmLab-HowTos/labs/sec/ex-6_iptables.adoc.html" target="_blank" rel="noopener">SSH Tunneling</a></h3>
<div class="admonitionblock tip"> <div class="admonitionblock tip">
<table> <table>
<tr> <tr>
@ -712,7 +742,7 @@ This tutorial demonstrates some common <strong>nmap</strong> port scanning scena
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2020-10-13 14:24:16 UTC Last updated 2020-10-13 20:50:28 UTC
</div> </div>
</div> </div>
</body> </body>

2341
index-lab.adoc.pdf

File diff suppressed because it is too large

345
labs/ls/ex-1_ls.adoc

@ -0,0 +1,345 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Πίνακας περιεχομένων
:toclevels: 4
:source-highlighter: highlight
:icons: font
:sectnums:
{empty} +
.NOTE
[NOTE]
====
Assuming you're already logged in
====
== Absolute basics
.Absolute basics
[options="header,footer"]
|=======================
|Command| Meaning
|ls| Displays a list of files in the current working directory.
|cd directory| change directories
|passwd |change the password for the current user
|file filename| display file type of file with name filename
|cat textfile| throws content of textfile on the screen
|pwd| display present working directory
|exit or logout| leave this session
|man command| read man pages on command
|=======================
=== Key combinations
.Key combinations
[options="header,footer"]
|=======================
|Key or key combination| Function
|Ctrl+C| End a running program and return the prompt
|Ctrl+Z| Suspend a program
|ArrowUp and ArrowDown| Browse history. Go to the line that you want to repeat, edit details if necessary, and press Enter to save time.
|Tab| Command or filename completion; when multiple choices are possible, the system will either signal with an audio or visual bell, or, if too many choices are possible, ask you if you want to see them all.
|Tab Tab| Shows file or command completion possibilities.
|Shift+PageUp and Shift+PageDown| Browse terminal buffer (to see text that has "scrolled off" the screen).
|=======================
=== ls -l
[source,bash]
----
# ls -al
drwxrwxr-x 4 zeus zeus 4096 Οκτ 23 21:55 .
drwxrwxr-x 9 zeus zeus 4096 Οκτ 15 14:28 ..
drwxrwxr-x 8 zeus zeus 4096 Οκτ 23 21:55 .git
drwxrwxr-x 4 zeus zeus 4096 Οκτ 14 20:24 install
crw------- 1 root root 5, 1 Οκτ 23 21:22 console
lrwxrwxrwx 1 root root 11 Οκτ 23 21:21 core -> /proc/kcore
drwxr-xr-x 4 root root 100 Οκτ 23 21:22 cpu
crw------- 1 root root 10, 59 Οκτ 23 21:21 cpu_dma_latency
crw------- 1 root root 10, 203 Οκτ 23 21:21 cuse
-rw-rw-r-- 1 zeus zeus 1517 Οκτ 23 21:55 INSTALL.md
-rw-rw-r-- 1 zeus zeus 33883 Οκτ 15 14:28 LICENSE
-rw-rw-r-- 1 zeus zeus 691 Οκτ 17 11:13 README.md
----
==== File types
This table gives an overview of the characters determining the file type:
NOTE: **d**rwxrwxr-x 4 zeus zeus 4096 Οκτ 14 20:24 install
.File types in a long list
[options="header,footer"]
|=======================
|Symbol| Meaning
|-| Regular file
|d| Directory
|l| Link
|c| Special file
|s| Socket
|p| Named pipe
|b| Block device
|=======================
NOTE: -**rw-**rw-r-- 1 zeus zeus 1517 Οκτ 23 21:55 INSTALL.md
==== Access rights
.Access rights
[options="header,footer"]
|=======================
|Code| Meaning
|0 or -|The access right that is supposed to be on this place is not granted.
|4 or r|read access is granted to the user category defined in this place
|2 or w|write permission is granted to the user category defined in this place
|1 or x|execute permission is granted to the user category defined in this place
|=======================
==== User group codes
.User group codes
[options="header,footer"]
|=======================
|Code| Meaning|
|u| user permissions|-**rw-**rw-r--
|g| group permissions|-rw-**rw-**r--
|o| permissions for others|-rw-rw-**rw-**
|=======================
==== Exercises
[source,bash]
----
touch example
chmod 400 example
ls -l example
chmod 500 example
ls -l example
chmod 600 example
ls -l example
chmod 644 example
ls -l example
chmod 660 example
ls -l example
chmod 700 example
ls -l example
chmod 755 example
ls -l example
chmod 775 example
ls -l example
ls -l example
chmod 777 example
ls -l example
----
== Linux file system layout
.Subdirectories of the root directory
[options="header,footer"]
|=======================
|Directory| Content
|/bin| Common programs, shared by the system, the system administrator and the users.
|/boot| The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.
|/dev| Contains references to all the CPU peripheral hardware, which are represented as files with special properties.
|/etc| Most important system configuration files are in /etc
|/home| Home directories of the common users.
|/lib| Library files, includes files for all kinds of programs needed by the system and the users.
|/mnt| Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.
|/opt| Typically contains extra and third party software.
|/proc| A virtual file system containing information about system resources.
|/root| The administrative user's home directory. Mind the difference between /, the root directory and /root, the home directory of the root user.
|/sbin| Programs for use by the system and the system administrator.
|/tmp| Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!
|/usr| Programs, libraries, documentation etc. for all user-related programs.
|/var| Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.
|=======================
== Find and grep
=== find
The find tool, known from UNIX, is very powerful. This command not only allows you to search file names, it can also accept file size, date of last change and other file properties as criteria for a search.
The most common use is for finding file names:
NOTE: find <path> -name <searchstring>
This can be interpreted as "Look in all files and subdirectories contained in a given path, and print the names of the files containing the search string in their name" **(not in their content).**
[source,bash]
----
find /etc -name "*.conf"
----
=== grep
grep is used for filtering input lines and returning certain patterns to the output.
NOTE: grep "string" path/to/file
[source,bash]
----
grep "root" /etc/passwd
----
=== find and grep command together
find /etc -name "*.conf" -exec grep -Hns "conf" {} \;
.Explanation
[source,bash]
----
-H, --with-filename
Print the filename for each match
-n, --line-number
Prefix each line of output with the 1-based line number within its input file
-s, --no-messages
Suppress error messages about nonexistent or unreadable files.
----
NOTE: This can be interpreted as +
- "Look for *.conf files and subdirectories contained in /etc, and **if true** exec **grep -Hns conf** in the given file"
TIP: Very powerful in bash scripts
create a file test.sh
.bash script
[source,bash]
----
#!/bin/bash
STRING=$(find /etc -name "*.conf" -exec grep -Hns "conf" {} \;)
echo $STRING
----
exec it
.bash script
[source,bash]
----
chmod 700 test.sh
./test.sh
----
== Managing software
=== APT
WHAT IS APT?
A packaging system simply provides programs and applications for installation.
APT(Advanced Package Tool) is a command line tool that is the most efficient and preferred way of managing software from the command line for Debian and Debian based Linux distributions like Ubuntu . It manages dependencies effectively, maintains large configuration files and properly handles upgrades and downgrades to ensure system stability.
==== Updating Package Database
Before commencing any operations with apt, we need to ensure that our local copy of the database is up-to-date.
Without this the system won’t know if there are newer packages available or not.
[source,bash]
----
apt-get update
----
==== Upgrading Package Database
Once your package database has been updated, you can now upgrade the packages with updates installed on you machine. This will update any applications, and the Ubuntu core system to the latest versions available.
[source,bash]
----
sudo apt-get upgrade
----
==== SEARCH FOR PACKAGES WITH APT
To search for a package you can use the following command:
[source,bash]
----
apt search apache2
----
==== INSTALLING NEW PACKAGES
If you are find the name of the package you want to install, you can install it by running this command:
[source,bash]
----
apt install apache2 vlc
----
==== REMOVING INSTALLED PACKAGES
To uninstall a package from your system, you can use the following command:
[source,bash]
----
apt remove vlc
----
NOTE: This command removes the package but keeps the configuration files. So in case you reinstall the same package, your configuration remains the same. If you want to remove both the package and its associated configuration files, you can run this command:
[source,bash]
----
apt purge vlc
----
==== clean up any unused libraries and packages
[source,bash]
----
apt autoremove
----
This command automatically removes any packages that aren’t used or associated with any installed program. It’s a great way to clean up any unused libraries and packages you don’t need.
:hardbreaks:
{empty} +
{empty} +
{empty}
:!hardbreaks:
'''
.Reminder
[NOTE]
====
:hardbreaks:
Caminante, no hay camino,
se hace camino al andar.
Wanderer, there is no path,
the path is made by walking.
*Antonio Machado* Campos de Castilla
====

1139
labs/ls/ex-1_ls.adoc.html

File diff suppressed because it is too large

9258
labs/ls/ex-1_ls.adoc.pdf

File diff suppressed because it is too large

8
labs/ls/index.html

@ -0,0 +1,8 @@
<html>
<body>
<script type="text/javascript">
// Javascript URL redirection
window.location.replace("http://docs.swarmlab.io/SwarmLab-HowTos/index-lab.adoc.html");
</script>
</body>
</html>
Loading…
Cancel
Save