MX on Linux: Difference between revisions

1,761 bytes added ,  30 September 2020
m
added precis
mNo edit summary
m (added precis)
=Using MX on UNIX-derived Operating Systems=
 
MX runs on various UNIX-derived operating systems (OS), including those found on Apple Mac computers, and those found on devices running Linux. Although the article focusses on one computer type, the Raspberry Pi, the idea is that this article will complement another article [[Moving from Cumulus 1 to MX|Running Cumulus MX on Windows]], so feel free to add more to this article to explain how it can be applied to another Unix-derived devices.
 
==This article focuses on a computer called the Raspberry Pi==
 
Although the article focusses on one computer type, the Raspberry Pi, the idea is that this article will complement another article [[Moving from Cumulus 1 to MX|Running Cumulus MX on Windows]], so feel free to add more to this article to explain how it can be applied to another Unix-derived devices.
 
In the Cumulus support forum, there are many posts from people who are struggling with using Windows PCs, and it seems a lot of them find "installing" MX difficult.
 
The same forum reveals few posts from people struggling with setting up the Raspberry Pi, and several posts reporting success with using MX on this small computer.
 
==Précis==
 
*The Raspberry Pi is a simple computer that is far easier to learn than a complicated machine like a Personal Computer (PC) running Windows.
*The Raspberry Pi is a computer that is better for the environment, unlike a PC manufactured with lot of components, and a PC wastes a lot of electricity if left running.
*You can choose either to install the Windows operating system on your Raspberry Pi or to install the simpler Raspberry Pi operating system (based on debian Linux).
**This article focusses on the latter as another article covers Windows.
**You don't need to learn much Linux, but this article does cover some commands.
*The Raspberry Pi is ideal to tun Cumulus MX
**Downloading the release distribution, and unzipping the files, is the same on any device
**On Linux you need to (simply) manually install one extra component (Mono-complete), while the equivalent component (.NET) is automatically installed on Windows.
**Running MX is same on any device (precise command syntax to start it varies, but what MX does when running does not depend on device)
*It is simplest to connect keyboard and monitor to the Raspberry Pi so all actions are done directly on it.
*Some optional topics are also covered.
**One option covered is adding a web server and a database server
**Another option discussed is using a PC to control a "headless" Raspberry Pi (i.e. one without keyboard and without monitor).
 
 
==Introduction==
 
This article focuses on a computer called the Raspberry Pi.
 
It is a small board of electronics that can actually run Windows, Mac OS, Chrome OS, various Linux distributions, or the Raspberry Pi OS (based on Ubantu Linux).
It also covers some optional extras!
 
== A very quick introduction to Linux ==
 
This article is not the place to teach you Linux, you can find books and on-line articles for yourself, but I list here enough for you to understand the instructions used elsewhere in this article.
 
If you have a Raspberry Pi with a monitor attached, you will see a raspberry icon that you can click to get access to many features including shutdown options.
 
=== sudo ===
 
Almost all instructions here start with a "sudo", it basically gives administrative rights to whatever follows, and therefore allows you to do tasks that only work in the root user. You use it as a prefix to almost every command you type in terminal mode. There are 3 system commands that will only work with this prefix:
 
*'''sudo halt''' = stops any cpu functions, but leaves Pi running; used when you have reached the end of commands you want to do for now
*'''sudo poweroff''' = makes pi do a tidy shutdown and turn off its power; used when you will not be using Pi for a while
*'''sudo reboot''' (or "sudo reboot -verbose" for diagnostic output during shutdown and reboot) = makes pi close down and then reboot; used when you change settings, and after you install new software, to ensure Pi starts with all applications
 
=== ~ and / ===
 
The tilde symbol '''~''' denotes the home directory for the current user. Sub-directories within the current user's folder can be identified by '''~/documents''' or similar notation. To reference a folder in root or any other area, the prefix is always '''/'''.
 
To see what files and folders are in the current directory, type <tt>dir</tt> for just names or <tt>ls</tt> for details.
 
To make a new folder in the current directory, type <tt>sudo mkdir folder_name</tt>.
 
=== chmod ===
 
When you are attempting any of the actions listed in this article that involve reading, creating, editing, or moving, files; you might see an error message generally because of a lack of write permissions on an existing file or folder. Whilst <tt>rm filename</tt> will remove a file even if it is write protected, for nano you need to change the file permissions with <tt>sudo chmod -R ugo+rw ~/CumulusMX</tt> for full access to all files in your Cumulus installation (see the syntax below if you want to restrict access).
 
 
*'''chmod''' command to modify permissions
* the '''-R''' indicates recursive action (i.e. including not just the named folder, but all files within it and all sub-folders, and all files within sub-folders)
*letters indicating whose permission is being modified
** '''u''' = Owning user (sometimes the owner is the user root, sometimes the owner is the user Pi, for our web pages later we change ownership)
** '''g''' = Group (by default the owning user is also a group, but a group can be defined if you want to give multiple users (with different passwords) the same rights of access)
** '''o''' = Other users (write permission here is needed if for example you are using FTP to move a file from a PC to your Pi, or vice versa)
* sign for add or remove permissions
* '''+''' = add permission
* '''-''' = remove permission
*letters indicating what permission is being changed
** '''r''' = read [4]
** '''w''' = write [2]
** '''x''' = execute [1]
 
Note that as an alternative shorter syntax you can use numbers e.g. '''666''' is equivalent to '''ugo+rw'''. The first digit in the number relates to ''u'', the second to ''g'' and the last to ''o''. The values in [] brackets in list of permissions above are added to derive each digit. So if you are reading the Cumulus support forum and you see a reference to permissions which includes a string of 3 digits, now you can understand what is meant.
 
=== nano ===
 
There are various text editors available on a Pi, '''nano''' is a simple one.
 
Like other text editors this can create a file when a file does not exist and edit (subject to file permissions) an existing file.
 
Use prefix of 'sudo' to give you access to any file, '''sudo''' does not change the actual file permissions, so you might find you can read a file, but not save it after you have done your edit.
 
When in nano you select to write out to a file, it allows you to change the file name shown. If you choose to save as another file, you will be asked if the new name is correct (again type '''Y''' to continue saving).
 
Do remember that file names are case sensitive, and when you open an existing file for editing look in case "new file" message appears because you have made a typo in the path/file name.
 
The full syntax is <tt>sudo nano -B Path_file_name</tt> where the '''-B''' means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use '''-C''' which stores each version in a back-up directory. If you want to edit from a particular line and column you can use '''+line.column''', and also optionally use '''-l''' (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like [[dayfile.txt]]. If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.
 
You will probably find it useful to type <tt>sudo nano /etc/nanorc</tt> as this puts you into the configuration file for nano where you can set back-up, line-numbering, and other options
 
After typing the nano command you need to specify a filename (it might include a path, see earlier sub-section for use of '''/''' and '''~''') and there are examples later in this article, but if you decide to ''host a web site on your Pi'' then you might want to edit its home page with (.html or .php) name like <tt>sudo nano /var/www/html/index.php</tt>. After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:
*First is '''^O''' which is used to save the file whilst staying in the editor, to do this press the control key down and type O. Next it shows the current file name, if you press '''Enter''' then that file will be overwritten.
*Another is '''^X''' which means if you press the control key down and type X you get the exit dialogue. If you have not made any edits, or have already saved the file, this just exits the editor. If you have not used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), typing just the Y key lets save continue (any other key stroke exits without saving), then it shows the current file name, if you press '''Enter''' then that file will be overwritten.
 
=== install ===
 
This is used for installing packages, you will often see it used with a parameter '''-y'''; as without that parameter you have to type '''Y''' to continue at each step of an install.
 
It is important to mention here that the version of packages installed may well be obsolete, this install is finding versions from a Raspberian repository, more recent versions may be available from the providers of each package. To keep this article simple, I accept the Operating System that is installed by NOOBS, even if it is not the latest available from the Raspberian web site, I accept the versions of Mono, Apache, PHP, MariaDB, and others, that are found at the time you issue the install command. The update and upgrade command that I use in multiple places in this article is still only finding the versions available in the repository, and is included just in case the repository is being updated after any install finishes.
 
If you have more skill than the level of the person at which this article is aimed at, then you should know how to install the latest version from the appropriate web sites.
 
=== removing an unwanted file ===
 
You can remove a file or a folder with various commands, including <tt>sudo rm filename</tt>.
 
=== Miscellaneous ===
 
I have created a section here, in case anyone wants to add any more instructions. Please feel free to rename it, or indeed add any clarification anywhere in this article.
 
Meanwhile, look at either [https://raspberrytips.com/raspberry-pi-commands/ this web page] or [https://www.ubuntupit.com/useful-raspberry-pi-commands/ this one] for more commands.
 
=Which Raspberry Pi to buy=
*switch off monitor or TV attached to your Pi,
*Just ensure you leave Pi on so that terminal session continues running.
 
== A very quick introduction to Linux ==
 
This article is not the place to teach you Linux, you can find books and on-line articles for yourself, but I list here enough for you to understand the instructions used elsewhere in this article.
 
If you have a Raspberry Pi with a monitor attached, you will see a raspberry icon that you can click to get access to many features including shutdown options.
 
=== sudo ===
 
Almost all instructions here start with a "sudo", it basically gives administrative rights to whatever follows, and therefore allows you to do tasks that only work in the root user. You use it as a prefix to almost every command you type in terminal mode. There are 3 system commands that will only work with this prefix:
 
*'''sudo halt''' = stops any cpu functions, but leaves Pi running; used when you have reached the end of commands you want to do for now
*'''sudo poweroff''' = makes pi do a tidy shutdown and turn off its power; used when you will not be using Pi for a while
*'''sudo reboot''' (or "sudo reboot -verbose" for diagnostic output during shutdown and reboot) = makes pi close down and then reboot; used when you change settings, and after you install new software, to ensure Pi starts with all applications
 
=== ~ and / ===
 
The tilde symbol '''~''' denotes the home directory for the current user. Sub-directories within the current user's folder can be identified by '''~/documents''' or similar notation. To reference a folder in root or any other area, the prefix is always '''/'''.
 
To see what files and folders are in the current directory, type <tt>dir</tt> for just names or <tt>ls</tt> for details.
 
To make a new folder in the current directory, type <tt>sudo mkdir folder_name</tt>.
 
=== chmod ===
 
When you are attempting any of the actions listed in this article that involve reading, creating, editing, or moving, files; you might see an error message generally because of a lack of write permissions on an existing file or folder. Whilst <tt>rm filename</tt> will remove a file even if it is write protected, for nano you need to change the file permissions with <tt>sudo chmod -R ugo+rw ~/CumulusMX</tt> for full access to all files in your Cumulus installation (see the syntax below if you want to restrict access).
 
 
*'''chmod''' command to modify permissions
* the '''-R''' indicates recursive action (i.e. including not just the named folder, but all files within it and all sub-folders, and all files within sub-folders)
*letters indicating whose permission is being modified
** '''u''' = Owning user (sometimes the owner is the user root, sometimes the owner is the user Pi, for our web pages later we change ownership)
** '''g''' = Group (by default the owning user is also a group, but a group can be defined if you want to give multiple users (with different passwords) the same rights of access)
** '''o''' = Other users (write permission here is needed if for example you are using FTP to move a file from a PC to your Pi, or vice versa)
* sign for add or remove permissions
* '''+''' = add permission
* '''-''' = remove permission
*letters indicating what permission is being changed
** '''r''' = read [4]
** '''w''' = write [2]
** '''x''' = execute [1]
 
Note that as an alternative shorter syntax you can use numbers e.g. '''666''' is equivalent to '''ugo+rw'''. The first digit in the number relates to ''u'', the second to ''g'' and the last to ''o''. The values in [] brackets in list of permissions above are added to derive each digit. So if you are reading the Cumulus support forum and you see a reference to permissions which includes a string of 3 digits, now you can understand what is meant.
 
=== nano ===
 
There are various text editors available on a Pi, '''nano''' is a simple one.
 
Like other text editors this can create a file when a file does not exist and edit (subject to file permissions) an existing file.
 
Use prefix of 'sudo' to give you access to any file, '''sudo''' does not change the actual file permissions, so you might find you can read a file, but not save it after you have done your edit.
 
When in nano you select to write out to a file, it allows you to change the file name shown. If you choose to save as another file, you will be asked if the new name is correct (again type '''Y''' to continue saving).
 
Do remember that file names are case sensitive, and when you open an existing file for editing look in case "new file" message appears because you have made a typo in the path/file name.
 
The full syntax is <tt>sudo nano -B Path_file_name</tt> where the '''-B''' means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use '''-C''' which stores each version in a back-up directory. If you want to edit from a particular line and column you can use '''+line.column''', and also optionally use '''-l''' (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like [[dayfile.txt]]. If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.
 
You will probably find it useful to type <tt>sudo nano /etc/nanorc</tt> as this puts you into the configuration file for nano where you can set back-up, line-numbering, and other options
 
After typing the nano command you need to specify a filename (it might include a path, see earlier sub-section for use of '''/''' and '''~''') and there are examples later in this article, but if you decide to ''host a web site on your Pi'' then you might want to edit its home page with (.html or .php) name like <tt>sudo nano /var/www/html/index.php</tt>. After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:
*First is '''^O''' which is used to save the file whilst staying in the editor, to do this press the control key down and type O. Next it shows the current file name, if you press '''Enter''' then that file will be overwritten.
*Another is '''^X''' which means if you press the control key down and type X you get the exit dialogue. If you have not made any edits, or have already saved the file, this just exits the editor. If you have not used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), typing just the Y key lets save continue (any other key stroke exits without saving), then it shows the current file name, if you press '''Enter''' then that file will be overwritten.
 
=== install ===
 
This is used for installing packages, you will often see it used with a parameter '''-y'''; as without that parameter you have to type '''Y''' to continue at each step of an install.
 
It is important to mention here that the version of packages installed may well be obsolete, this install is finding versions from a Raspberian repository, more recent versions may be available from the providers of each package. To keep this article simple, I accept the Operating System that is installed by NOOBS, even if it is not the latest available from the Raspberian web site, I accept the versions of Mono, Apache, PHP, MariaDB, and others, that are found at the time you issue the install command. The update and upgrade command that I use in multiple places in this article is still only finding the versions available in the repository, and is included just in case the repository is being updated after any install finishes.
 
If you have more skill than the level of the person at which this article is aimed at, then you should know how to install the latest version from the appropriate web sites.
 
=== removing an unwanted file ===
 
You can remove a file or a folder with various commands, including <tt>sudo rm filename</tt>.
 
=== Miscellaneous ===
 
I have created a section here, in case anyone wants to add any more instructions. Please feel free to rename it, or indeed add any clarification anywhere in this article.
 
Meanwhile, look at either [https://raspberrytips.com/raspberry-pi-commands/ this web page] or [https://www.ubuntupit.com/useful-raspberry-pi-commands/ this one] for more commands.
 
=Optional actions=
5,838

edits