Browse Source

linux

master
zeus 4 years ago
parent
commit
ffafc54a9e
  1. 106
      hybrid-linux/apt.adoc
  2. 218
      hybrid-linux/basics.adoc
  3. 200
      hybrid-linux/filesystem-backup.adoc
  4. 50
      hybrid-linux/filesystem.adoc
  5. 95
      hybrid-linux/find_and_grep.adoc
  6. 34
      hybrid-linux/index.js
  7. 174
      hybrid-linux/proc.adoc

106
hybrid-linux/apt.adoc

@ -0,0 +1,106 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:no-header-footer:
:nofooter:
:last-update-label!:
:icons: font
:sectnums:
{empty} +
== 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:

218
hybrid-linux/basics.adoc

@ -121,209 +121,6 @@ NOTE: -**rw-**rw-r-- 1 zeus zeus 1517 Οκτ 23 21:55 INSTALL.md
|======================= |=======================
==== 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: :hardbreaks:
{empty} + {empty} +
@ -331,18 +128,3 @@ This command automatically removes any packages that aren’t used or associated
{empty} {empty}
:!hardbreaks: :!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
====

200
hybrid-linux/filesystem-backup.adoc

@ -0,0 +1,200 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:no-header-footer:
:nofooter:
:last-update-label!:
:icons: font
:sectnums:
{empty} +
== 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:

50
hybrid-linux/filesystem.adoc

@ -0,0 +1,50 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:no-header-footer:
:nofooter:
:last-update-label!:
:icons: font
:sectnums:
{empty} +
== 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.
|=======================
:hardbreaks:
{empty} +
{empty} +
{empty}
:!hardbreaks:

95
hybrid-linux/find_and_grep.adoc

@ -0,0 +1,95 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:no-header-footer:
:nofooter:
:last-update-label!:
:icons: font
:sectnums:
{empty} +
== 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
----
:hardbreaks:
{empty} +
{empty} +
{empty}
:!hardbreaks:

34
hybrid-linux/index.js

@ -1,4 +1,11 @@
[ [
{
"title": "An Introduction to Linux !",
"subtitle": "Absolute basics",
"type": "asciidoc",
"desc": "Absolute basics, File types, Access rights etc",
"file": "basics.adoc"
},
{ {
"title": "test asciinema", "title": "test asciinema",
"subtitle": "subtitle1", "subtitle": "subtitle1",
@ -7,11 +14,32 @@
"file": "demo.cast" "file": "demo.cast"
}, },
{ {
"title": "An Introduction to Linux !", "title": "Linux file system layout",
"subtitle": "Absolute basics", "subtitle": "Absolute basics",
"type": "asciidoc", "type": "asciidoc",
"desc": "Absolute basics, File types, Access rights etc", "desc": "Subdirectories of the root directory",
"file": "basics.adoc" "file": "filesystem.adoc"
},
{
"title": "The /proc Filesystem",
"subtitle": "Absolute basics",
"type": "asciidoc",
"desc": "The proc filesystem provides a method of communication between kernel space and user space.",
"file": "proc.adoc"
},
{
"title": "Find and grep",
"subtitle": "Absolute basics",
"type": "asciidoc",
"desc": "find and grep command",
"file": "find_and_grep.adoc"
},
{
"title": "Managing software",
"subtitle": "Absolute basics",
"type": "asciidoc",
"desc": "managing software from the command line ",
"file": "apt.adoc"
}, },
{ {
"title": "test vimeo", "title": "test vimeo",

174
hybrid-linux/proc.adoc

@ -0,0 +1,174 @@
= An Introduction to Linux !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: Linux, apt
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:no-header-footer:
:nofooter:
:last-update-label!:
:icons: font
:sectnums:
{empty} +
.procfs
****
The proc filesystem (*procfs*) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure,
*providing* a more convenient and *standardized method for dynamically accessing process* data held in the kernel than traditional tracing methods or direct access to kernel memory.
Typically
- it is mapped to a mount point named /proc at boot time.
- The proc file system acts as an interface to internal data structures in the kernel.
- It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).
****
== The /proc Filesystem
NOTE: The proc filesystem provides a method of communication between *kernel space* and *user space*. For example, the GNU version of the process reporting utility *ps* uses the proc file system to obtain its data, without using any specialized system calls.
The directory /proc contains (among other things) one subdirectory for each process running on the system, which is named after the process ID (PID).
The link ‘self’ points to the process reading the file system. Each process subdirectory has the entries listed in: ls /proc/<pid>
[source,bash]
----
cat /proc/meminfo
MemTotal: 8174328 kB
MemFree: 6186516 kB
MemAvailable: 7535332 kB
Buffers: 146740 kB
Cached: 1294156 kB
SwapCached: 0 kB
Active: 967184 kB
Inactive: 606252 kB
Active(anon): 135620 kB
Inactive(anon): 85064 kB
Active(file): 831564 kB
Inactive(file): 521188 kB
Unevictable: 3652 kB
Mlocked: 3652 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 68 kB
Writeback: 0 kB
AnonPages: 136188 kB
Mapped: 113344 kB
Shmem: 85724 kB
Slab: 340236 kB
SReclaimable: 302048 kB
SUnreclaim: 38188 kB
KernelStack: 3792 kB
PageTables: 4888 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 4087164 kB
Committed_AS: 901432 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 51200 kB
CmaTotal: 0 kB
CmaFree: 0 kB
...
----
.Main entries in /proc
[options="header,footer"]
|=======================
|File|Content
| /proc/cmdline | – Kernel command line information.
| /proc/console | – Information about current consoles including tty.
| /proc/crypto | - a list of available cryptographic modules
| /proc/devices | – Device drivers currently configured for the running kernel.
| /proc/diskstats | - giving some information (including device numbers) for each of the logical disk devices
| /proc/dma | – Info about current DMA channels.
| /proc/fb | – Framebuffer devices.
| /proc/filesystems | – Current filesystems supported by the kernel.
| /proc/interrupts, /proc/iomem, /proc/ioports and the directory /proc/irq | - giving some self-explanatory details about the devices (physical or logical) using the various system resources
| /proc/iomem | – Current system memory map for devices.
| /proc/ioports | – Registered port regions for input output communication with device.
| /proc/loadavg | – System load average.
| /proc/locks | – Files currently locked by kernel.
| /proc/meminfo | – Info about system memory (see above example).
| /proc/misc | – Miscellaneous drivers registered for miscellaneous major device.
| /proc/modules | - one of the most important files in /proc, containing a list of the kernel modules currently loaded . It gives some indication (not always entirely correct) of dependencies.
| /proc/mounts | – List of all mounts in use by system.
| /proc/mounts | - a symlink to self/mounts which contains a list of the currently mounted devices and their mount points (and which file system is in use and what mount options are in use).
| /proc/net | - a directory containing useful information about the network stack, in particular /proc/net/nf_conntrack, which lists existing network connections (particularly useful for tracking routing when iptables FORWARD is used to redirect network connections)
| /proc/partitions | – Detailed info about partitions available to the system.
| /proc/pci | – Information about every PCI device.
| /proc/stat | – Record or various statistics kept from last reboot.
| /proc/swap | – Information about swap space.
| /proc/scsi | - giving information about any devices connected via a SCSI or RAID controller
| /proc/sysvipc | - containing memory-sharing and inter-process communication (IPC) information.
| /proc/tty | - containing information about the current terminals; /proc/tty/driver looks to be[original research?] a list of the different types of tty available - each of which is a list of those of each type
| /proc/uptime | – Uptime information (in seconds).
| /proc/version | – Kernel version, gcc version, and Linux distribution installed.
|=======================
== cpu info
[source,bash]
----
cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 2000.000
cache size : 1024 KB
...
processor : 1
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 800.000
cache size : 1024 KB
----
Loading…
Cancel
Save