new visual style in linux primer
This commit is contained in:
parent
36e29c08df
commit
7335d94ad9
184
docs/linux.md
184
docs/linux.md
|
@ -1,6 +1,8 @@
|
||||||
# Linux Primer
|
# Linux Primer
|
||||||
|
|
||||||
My packet radio guide is focussed on running software on Linux and it probably assumes a base level of knowledge. I shall dispense some thoughts and you can judge whether this is helpful.
|
My packet radio guide is focussed on running software on Linux and it probably
|
||||||
|
assumes a base level of knowledge. I shall dispense some thoughts and you can
|
||||||
|
judge whether this is helpful.
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
|
|
||||||
|
@ -8,19 +10,44 @@ My packet radio guide is focussed on running software on Linux and it probably a
|
||||||
|
|
||||||
## What is Linux?
|
## What is Linux?
|
||||||
|
|
||||||
Linux is, in general terms, a family of operating systems that share a common core set of software and exhibit similar characteristics. It is no one simple thing, and doesn't fit in one neat category.
|
Linux is, in general terms, a family of operating systems that share a common
|
||||||
|
core set of software and exhibit similar characteristics. It is no one simple
|
||||||
|
thing, and doesn't fit in one neat category.
|
||||||
|
|
||||||
It can be seen as an alternative to Windows, MacOS, DOS, FreeBSD etc on the desktop - there are many similarities and many differences.
|
It can be seen as an alternative to Windows, MacOS, DOS, FreeBSD etc on the
|
||||||
|
desktop - there are many similarities and many differences.
|
||||||
|
|
||||||
It is built collaboratively by enthusiast and professional software developers in the spirit of freely sharing and improving the world for all humans - in this sense, there is a strong overlap with the goals of man radio amateurs.
|
It is built collaboratively by enthusiast and professional software developers
|
||||||
|
in the spirit of freely sharing and improving the world for all humans - in
|
||||||
|
this sense, there is a strong overlap with the goals of man radio amateurs.
|
||||||
|
|
||||||
Through this guide I will regularly refer to "[Debian](https://debian.org)" - this is the 'Distribution' of Linux that I work on in my free time. A distribution is a collection of software maintained by a group of people. In the case of Debian, there's around 1000 of us.
|
Through this guide I will regularly refer to "[Debian](https://debian.org)" -
|
||||||
|
this is the 'Distribution' of Linux that I work on in my free time. A
|
||||||
|
distribution is a collection of software maintained by a group of people. In
|
||||||
|
the case of Debian, there's around 1000 of us working on it.
|
||||||
|
|
||||||
As the source code is available for all to see and use due to permissive licenses, if another group has an opinion which differs from the team producing a distribution, they can use our work as a foundation and build something different and new based on that - we call this 'forking'. This is what [Ubuntu](https://ubuntu.com) is, and why we refer to Ubuntu as a 'Debian Derivative'. It's also why 90% of tutorials that target Ubuntu will work for Debian and vice versa. We share common components and building blocks. Raspberry Pi OS falls into this category too - they are standing on Debian's shoulders and commonly re-base their system on ours, so that they can focus their efforts on making the Raspberry Pi work well instead of getting bogged down in tangential detail.
|
As the source code is available for all to see and use due to permissive
|
||||||
|
licenses, if another group has an opinion which differs from the team producing
|
||||||
|
a distribution, they can use our work as a foundation and build something
|
||||||
|
different and new based on that - we call this 'forking'. This is what
|
||||||
|
[Ubuntu](https://ubuntu.com) is, and why we refer to Ubuntu as a 'Debian
|
||||||
|
Derivative'. It's also why 90% of tutorials that target Ubuntu will work for
|
||||||
|
Debian and vice versa. We share common components and building blocks.
|
||||||
|
Raspberry Pi OS falls into this category too - they are standing on Debian's
|
||||||
|
shoulders and commonly re-base their system on ours, so that they can focus
|
||||||
|
their efforts on making the Raspberry Pi work well instead of getting bogged
|
||||||
|
down in every tangential detail.
|
||||||
|
|
||||||
An alternative to Debian and its derivatives is [Fedora](https://www.fedoraproject.org) - while this shares many common components and code at the core of the system, some of the tools used in Fedora differ to such an extent that software built for it can't be guaranteed to run on a Debian based system - similar to Mac vs Windows.
|
An alternative to Debian and its derivatives is
|
||||||
|
[Fedora](https://www.fedoraproject.org) - while this shares many common
|
||||||
|
components and code at the core of the system, some of the tools used in Fedora
|
||||||
|
differ to such an extent that software built for it can't be guaranteed to run
|
||||||
|
on a Debian based system - similar to Mac vs Windows.
|
||||||
|
|
||||||
There are hundreds, if not thousands, of Linux Distributions all with different goals. Some are derivatives focussed on a specific task, some are very General and left to you to configure and use. Some are even delivered as code and you need to compile it from the ground up.
|
There are hundreds, if not thousands, of Linux Distributions all with different
|
||||||
|
goals. Some are derivatives focussed on a specific task, some are very General
|
||||||
|
and left to you to configure and use. Some are even delivered as code and you
|
||||||
|
need to compile it from the ground up.
|
||||||
|
|
||||||
|
|
||||||
## Desktops and Terminals
|
## Desktops and Terminals
|
||||||
|
@ -43,9 +70,9 @@ keen explorer it should look approachable at the very least.
|
||||||
If you're running Debian, during install we'll ask you what graphical desktop
|
If you're running Debian, during install we'll ask you what graphical desktop
|
||||||
environment you want to install, if any. This is the desktop you boot in to -
|
environment you want to install, if any. This is the desktop you boot in to -
|
||||||
unlike Windows, there are multiples available for Linux. As a beginner, I
|
unlike Windows, there are multiples available for Linux. As a beginner, I
|
||||||
strongly recommend [KDE](https://kde.org) - it is most Windows like and is
|
strongly recommend [KDE](https://kde.org) Plasma - it is quite Windows like and
|
||||||
pretty full featured. If you're running Ubuntu, typically you install an Ubuntu
|
is pretty full featured. If you're running Ubuntu, typically you install an
|
||||||
derivative focussed on a specific desktop environment - perhaps
|
Ubuntu derivative focussed on a specific desktop environment - perhaps
|
||||||
[Kubuntu](https://kubuntu.org) for KDE.
|
[Kubuntu](https://kubuntu.org) for KDE.
|
||||||
|
|
||||||
## Applications and Repositories
|
## Applications and Repositories
|
||||||
|
@ -71,7 +98,12 @@ by RasPi OS too.
|
||||||
|
|
||||||
### Install from the Command Line
|
### Install from the Command Line
|
||||||
|
|
||||||
To install from the command line, the standard command would be `apt install x` where x is any application you're looking for. This is often prefixed with `sudo`, see below in 'Users, Permissions and sudo' to learn more about why.
|
To install from the command line, the standard command would be:
|
||||||
|
!!! note "Terminal Command
|
||||||
|
`apt install x`
|
||||||
|
|
||||||
|
Where x is any application you're looking for. This is often prefixed with
|
||||||
|
`sudo`, see below in [Users, Permissions and sudo](linux.md/#users-permissions-and-sudo) to learn more about why.
|
||||||
|
|
||||||
### Graphical App Store Frontend
|
### Graphical App Store Frontend
|
||||||
|
|
||||||
|
@ -88,12 +120,12 @@ Add/Remove software.
|
||||||
|
|
||||||
Have a little look through your application launcher menu to see if there is an
|
Have a little look through your application launcher menu to see if there is an
|
||||||
app catalogue, application store, package list or similar. If nothing is there,
|
app catalogue, application store, package list or similar. If nothing is there,
|
||||||
then you might need to look to install something.
|
then you might need to look to install something. In KDE this is called 'Discover'.
|
||||||
|
|
||||||
One I recommend is 'Synaptic' - you might have it installed already, or you
|
One I recommend is 'Synaptic' - you might have it installed already, or you
|
||||||
might have to quickly run `apt install synaptic` in the command line to get
|
might have to quickly run the below to get it
|
||||||
yourself the software.
|
!!! note "Terminal Command"
|
||||||
|
`apt install synaptic`
|
||||||
|
|
||||||
On the Raspberry Pi, it's as below. To find it, go to the Raspberry Pi menu (Raspberry Icon, Top Left), Preferences and select Add/Remove software.
|
On the Raspberry Pi, it's as below. To find it, go to the Raspberry Pi menu (Raspberry Icon, Top Left), Preferences and select Add/Remove software.
|
||||||
|
|
||||||
|
@ -120,6 +152,9 @@ bin@ dev/ home/ lost+found/ mnt/ proc/ run/ srv/ tmp/ var/
|
||||||
boot/ etc/ lib@ media/ opt/ root/ sbin@ sys/ usr/
|
boot/ etc/ lib@ media/ opt/ root/ sbin@ sys/ usr/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
I used `ls` here to list the folders in the terminal, but the DOS classic `dir` will also work!
|
||||||
|
|
||||||
Many folders won't be of interest to you day to day, but some helpful ones to know are:
|
Many folders won't be of interest to you day to day, but some helpful ones to know are:
|
||||||
|
|
||||||
* `/dev/` - A folder containing devices, it's likely your modem appears here as `/dev/ttyACM0`
|
* `/dev/` - A folder containing devices, it's likely your modem appears here as `/dev/ttyACM0`
|
||||||
|
@ -130,74 +165,128 @@ Many folders won't be of interest to you day to day, but some helpful ones to kn
|
||||||
|
|
||||||
## Users, Permissions and 'sudo'
|
## Users, Permissions and 'sudo'
|
||||||
|
|
||||||
Much like other systems, Linux has the concept of a regular 'user' which you log in as, day to day and an 'administrator' user who is empowered to make configuration changes to the system, install software and so on. In the Linux world, the administrator is known as 'root'. As root has a lot of power - changing users passwords, deleting every file, overriding safe norms to damage hardware potentially - it is generally recommended that you do not log in day to day as root. If a bad actor or malicious piece of software runs while you are root, it can cause all of the aforementioned damage and more!
|
Much like other systems, Linux has the concept of a regular 'user' which you
|
||||||
|
log in as, day to day and an 'administrator' user who is empowered to make
|
||||||
|
configuration changes to the system, install software and so on. In the Linux
|
||||||
|
world, the administrator is known as 'root'. As root has a lot of power -
|
||||||
|
changing users passwords, deleting every file, overriding safe norms to damage
|
||||||
|
hardware potentially - it is generally recommended that you do not log in day
|
||||||
|
to day as root. If a bad actor or malicious piece of software runs while you
|
||||||
|
are root, it can cause all of the aforementioned damage and more!
|
||||||
|
|
||||||
Again, similar to windows, you can run a command as the root user, effectively temporarily granting access to just one program to perform a specific task. In Windows, what usually happens is a pop up window appears asking if you want to do that and pressing yes or no. In Linux, we will have configured the system in advance to know that your user is allowed to do this, and then it will ask for your password to grant permission to carry out the action.
|
Again, similar to windows, you can run a command as the root user, effectively
|
||||||
|
temporarily granting access to just one program to perform a specific task. In
|
||||||
|
Windows, what usually happens is a pop up window appears asking if you want to
|
||||||
|
do that and pressing yes or no. In Linux, we will have configured the system in
|
||||||
|
advance to know that your user is allowed to do this, and then it will ask for
|
||||||
|
your password to grant permission to carry out the action.
|
||||||
|
|
||||||
In graphical environments this may take the form of a pop up window - more often than not, however, we do this from the command line by prefixing our whole command with `sudo` - you can see a lot of examples of `sudo` in use at [the repo page](repo.md).
|
In graphical environments this may take the form of a pop up window - more
|
||||||
|
often than not, however, we do this from the command line by prefixing our
|
||||||
|
whole command with `sudo` - you can see a lot of examples of `sudo` in use at
|
||||||
|
[the repo page](repo.md).
|
||||||
|
|
||||||
Looking at the repo as an example and considering our earlier learning from Applications and Repositories above - it's no wonder that you need to carry out the commands mostly as the root user!
|
Looking at the repo as an example and considering our earlier learning from
|
||||||
To add my repository, you are making a major system configuration change in two manners:
|
Applications and Repositories above - it's no wonder that you need to carry out
|
||||||
|
the commands mostly as the root user! To add my repository, you are making a
|
||||||
|
major system configuration change in two manners:
|
||||||
|
|
||||||
* Telling it to trust absolutely the software that I distribute
|
* Telling it to trust absolutely the software that I distribute
|
||||||
* Telling the package manager where to download that software from
|
* Telling the package manager where to download that software from
|
||||||
|
|
||||||
From this point on, you're placing a lot of trust in me personally - I can make quite significant changes to your system, or open up security holes, or accidentally break programs. I promise to not abuse this trust - to do so would break our Social Contract, result in me being ejected from several communities I love and I'd probably have to find a new set of hobbies.
|
From this point on, you're placing a lot of trust in me personally - I can make
|
||||||
|
quite significant changes to your system, or open up security holes, or
|
||||||
|
accidentally break programs. I promise to not abuse this trust - to do so would
|
||||||
|
break our Social Contract, result in me being ejected from several communities
|
||||||
|
I love and I'd probably have to find a new set of hobbies.
|
||||||
|
|
||||||
You can, of course, revoke this decision at any point by removing the repo key and entry in `/etc/apt.conf`.
|
You can, of course, revoke this decision at any point by removing the repo key
|
||||||
|
and entry in `/etc/apt.conf`.
|
||||||
|
|
||||||
### How do I know if I can run programs as root?
|
### How do I know if I can run programs as root?
|
||||||
|
|
||||||
This is one for the command line! I recommend running `groups`:
|
This is one for the command line! I recommend running groups:
|
||||||
|
!!! note "Terminal Command"
|
||||||
|
`groups`
|
||||||
|
|
||||||
|
The output on my system looks like:
|
||||||
```
|
```
|
||||||
❯ groups
|
❯ groups
|
||||||
hibby cdrom floppy sudo audio dip video plugdev users netdev lpadmin scanner sbuild
|
hibby cdrom floppy sudo audio dip video plugdev users netdev lpadmin scanner sbuild
|
||||||
```
|
```
|
||||||
|
|
||||||
You can see in my group list that I can access the cd rom drive, the floppy drive and run things as sudo, amongst other less important groups!
|
You can see in my group list that I can access the cd rom drive, the floppy
|
||||||
|
drive and run things as sudo, amongst other less important groups!
|
||||||
|
|
||||||
If you do *not* have sudo in this list, you'll need a bit more help than I can give here - time to [ask for help!](beginners-guide.md#ask-for-help). If you're running a Raspberry Pi or Ubuntu, chances are that you'll be able to. Debian is a little more paranoid so we don't grant it by default.
|
If you do *not* have sudo in this list, you'll need a bit more help than I can
|
||||||
|
give here - time to [ask for help!](beginners-guide.md#ask-for-help). If you're
|
||||||
|
running a Raspberry Pi or Ubuntu, chances are that you'll be able to. Debian is
|
||||||
|
a little more paranoid so we don't grant it by default.
|
||||||
|
|
||||||
You'll need to run a command called `usermod` as the root user to grant your regular user a new group - `usermod -aG <groupname> <username>` effectively translates to 'add <username> to <groupname>. Get rid of the brackets and add the user and group you're trying for! See [Permissions and Groups](#Permissions-and-Groups) for an example.
|
You'll need to run a command called `usermod` as the root user to grant your regular user a new group -
|
||||||
|
!!! note "Terminal Command"
|
||||||
|
`usermod -aG <groupname> <username>`
|
||||||
|
|
||||||
|
This effectively translates to 'add <username> to <groupname>. Get rid of the
|
||||||
|
brackets and add the user and group you're trying for! See [Permissions and
|
||||||
|
Groups](#Permissions-and-Groups) for an example.
|
||||||
|
|
||||||
### Editing text as root
|
### Editing text as root
|
||||||
|
|
||||||
The path of least resistance for many is to use the command line - if you know what file you need to edit, you can do that quickly and directly using a command line text editor.
|
The path of least resistance for many is to use the command line - if you know
|
||||||
|
what file you need to edit, you can do that quickly and directly using a
|
||||||
|
command line text editor.
|
||||||
|
|
||||||
The GUI offers some choices - my preferred method is below.
|
The GUI offers some choices - my preferred method is below.
|
||||||
|
|
||||||
##### GUI
|
##### GUI
|
||||||
|
|
||||||
I recommend installing Featherpad for this - it's lightweight and will only ask for a password when you save the file.
|
I recommend installing Featherpad for this - it's lightweight and will only ask
|
||||||
|
for a password when you save the file.
|
||||||
|
|
||||||
If you use the KDE Desktop, Kate works and has the below functionality inbuilt.
|
If you use the KDE Desktop, Kate works and has the below functionality inbuilt.
|
||||||
|
|
||||||
To install it see [above](linux.md/#graphical-app-store-frontend) for more.
|
To install it see [above](linux.md/#graphical-app-store-frontend) for more.
|
||||||
|
|
||||||
You can open Featherpad from the application launcher and use the file->open menu to get access to files all round the system:
|
You can open Featherpad from the application launcher and use the file->open
|
||||||
|
menu to get access to files all round the system:
|
||||||
|
|
||||||
![Featherpad Open File](static/img/featherpad-open.png)
|
![Featherpad Open File](static/img/featherpad-open.png)
|
||||||
|
|
||||||
Take yourself back to `/` with the Path breadcrumb at the top, and to edit the bpq32.conf config file, for example, find `/etc/bpq32.cfg`.
|
Take yourself back to `/` with the Path breadcrumb at the top, and to edit the
|
||||||
|
bpq32.conf config file, for example, find `/etc/bpq32.cfg`.
|
||||||
|
|
||||||
On saving the file, the system will ask you to enter your password as it's a protected file that only the root user can write to:
|
On saving the file, the system will ask you to enter your password as it's a
|
||||||
|
protected file that only the root user can write to:
|
||||||
|
|
||||||
![Featherpad Save as Root Dialogue](static/img/featherpad-rootsave.png)
|
![Featherpad Save as Root Dialogue](static/img/featherpad-rootsave.png)
|
||||||
|
|
||||||
Alternatively, after installing featherpad you can open your file manager, navigate to `/etc/`, open `bpq32.cfg` and the system will present a similar popup when you try to save:
|
Alternatively, after installing featherpad you can open your file manager,
|
||||||
|
navigate to `/etc/`, open `bpq32.cfg` and the system will present a similar
|
||||||
|
popup when you try to save:
|
||||||
|
|
||||||
![Fileman Select File](static/img/fileman-select.png)
|
![Fileman Select File](static/img/fileman-select.png)
|
||||||
|
|
||||||
In all these programs, you can find `/etc/` by typing `/etc` in the navigation bar that is top-central, or by Pressing 'Filesystem Root' on the left hand side and navigating to etc in the main pane.
|
In all these programs, you can find `/etc/` by typing `/etc` in the navigation
|
||||||
|
bar that is top-central, or by Pressing 'Filesystem Root' on the left hand side
|
||||||
|
and navigating to etc in the main pane.
|
||||||
|
|
||||||
#### Command Line
|
#### Command Line
|
||||||
|
|
||||||
Every Debian system ships with a text editor called `nano` which is relatively approachable.
|
Every Debian system ships with a text editor called `nano` which is relatively approachable.
|
||||||
|
|
||||||
You open your file directly, so to edit the BPQ config file, run `sudo nano /etc/bpq32.cfg`. This translates to: `As root user, open nano to edit /etc/bpq32.cfg`
|
You open your file directly, so to edit the BPQ config file, run:
|
||||||
|
|
||||||
Navigation is with arrow keys (no mouse, sorry!). There are a list of commands at the bottom of the screen - they use ^ as a shortcut to indicate you must press control at the same time as those letters. Similarly, M is an indication of 'meta' key, which will likely be the alt key. This is quite similar to keyboard shortcuts in Microsoft Word (ctrl&s for save, alt-f4 for exit).
|
!!! note "Terminal Command"
|
||||||
|
`sudo nano /etc/bpq32.cfg`
|
||||||
|
|
||||||
|
This translates to: `As root user, open nano to edit /etc/bpq32.cfg`
|
||||||
|
|
||||||
|
Navigation is with arrow keys (no mouse, sorry!). There are a list of commands
|
||||||
|
at the bottom of the screen - they use ^ as a shortcut to indicate you must
|
||||||
|
press control at the same time as those letters. Similarly, M is an indication
|
||||||
|
of 'meta' key, which will likely be the alt key. This is quite similar to
|
||||||
|
keyboard shortcuts in Microsoft Word (ctrl&s for save, alt-f4 for exit).
|
||||||
|
|
||||||
Some helpful commands to know:
|
Some helpful commands to know:
|
||||||
|
|
||||||
|
@ -214,17 +303,32 @@ Some helpful commands to know:
|
||||||
|
|
||||||
### Permissions and Groups
|
### Permissions and Groups
|
||||||
|
|
||||||
Files, devices and folders can have read and write permissions tied to both a user and a group, just as in Windows. You can check this in your file manager by right clicking and selecting properties.
|
Files, devices and folders can have read and write permissions tied to both a
|
||||||
|
user and a group, just as in Windows. You can check this in your file manager
|
||||||
|
by right clicking and selecting properties.
|
||||||
|
|
||||||
In the command line, this can be checked also - to understand who can do what with a NinoTNC, plug it in and run
|
In the command line, this can be checked also - to understand who can do what
|
||||||
|
with a NinoTNC, plug it in and run
|
||||||
|
!!! note "Terminal Command"
|
||||||
|
`ls -l /dev/ttyACM0`
|
||||||
|
|
||||||
|
The output on my system looks like:
|
||||||
```
|
```
|
||||||
❯ ls -l /dev/ttyACM0
|
❯ ls -l /dev/ttyACM0
|
||||||
crw-rw---- 1 root dialout 204, 64 Apr 11 08:32 /dev/ttyACM0
|
crw-rw---- 1 root dialout 204, 64 Apr 11 08:32 /dev/ttyACM0
|
||||||
```
|
```
|
||||||
|
|
||||||
This can be read as the device is owned by root and accessible by the group `dialout`. This is a common group you'll see regularly for serial devices, and worth being a member of. If a device has dialout as its group, this is telling us unless your user is root or in the dialout group, you cannot use the device.
|
This can be read as the device is owned by root and accessible by the group
|
||||||
|
`dialout`. This is a common group you'll see regularly for serial devices, and
|
||||||
|
worth being a member of. If a device has dialout as its group, this is telling
|
||||||
|
us unless your user is root or in the dialout group, you cannot use the device.
|
||||||
|
|
||||||
To add your user to the dialout group, you may need to run the usermod command as mentioned above. To add my user hibby, it would be `usermod -aG dialout hibby`. As this command needs to be run as the root user, we probably need to run `sudo usermod -aG dialout hibby`.
|
To add your user to the dialout group, you may need to run the usermod command
|
||||||
|
as mentioned above. To add my user hibby, it would be
|
||||||
|
!!! note "Terminal Command"
|
||||||
|
`usermod -aG dialout hibby`
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
As this command needs to be run as the root user, we probably need to run `sudo usermod -aG dialout hibby`
|
||||||
|
|
||||||
For this change to take effect, you will need to log out and log in again.
|
For this change to take effect, you will need to log out and log in again.
|
||||||
|
|
Loading…
Reference in New Issue