MX on Linux: Difference between revisions

504 bytes added ,  16:53, 4 September 2020
m
Line 43: Line 43:
To make a new folder in the current directory, type <tt>sudo mkdir folder_name</tt>.  To give a folder and all its sub-folders and files full permissions (think carefully whether you really want to do this) type something like <tt> sudo chmod -R ugo+rw /var/www/html</tt>. See next sub-section for explanation.
To make a new folder in the current directory, type <tt>sudo mkdir folder_name</tt>.  To give a folder and all its sub-folders and files full permissions (think carefully whether you really want to do this) type something like <tt> sudo chmod -R ugo+rw /var/www/html</tt>. See next sub-section for explanation.


=== nano ===
=== chmod ===


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. The sudo gives you access to any file, it does not change the actual file access, so you might find you can read a file, but not save it after you have done your edit. 
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).
 
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.
 
 
After typing the nano command you need to specify a filename (it might include a path, see previous sub-section) 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 used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), although the Y carries on, any other key stroke cancels without saving, then it shows the current file name, if you press '''Enter''' then that file will be overwritten.
 
Look out for any error message here, you might not have write permissions on an existing file. If you change the file name shown, then it can save as another file, but you will be asked if the new name is correct (again type '''Y''' to continue saving).  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
*'''chmod''' command to modify permissions
*letters indicating whose permission is being modified
*letters indicating whose permission is being modified
** '''u''' = Owning user
** '''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
** '''g''' = Group (by default there are no groups, but a group can be defined if you want to define multiple users, with different passwords, but same rights of access)
** '''o''' = Other users (Public)
** '''o''' = Other users (Public, needed if for example you are using FTP to move a file from a PC to your Pi)
* sign for add or remove permissions
* sign for add or remove permissions
* '''+''' = add permission
* '''+''' = add permission
Line 69: Line 60:


Note that as an alternative shorter syntax you can use numbers e.g. '''666''' is equivalent to '''ugo+rw'''. The first number relates to u, the second to g and the last to o. The values in brackets in list above are added to derive the number.  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.
Note that as an alternative shorter syntax you can use numbers e.g. '''666''' is equivalent to '''ugo+rw'''. The first number relates to u, the second to g and the last to o. The values in brackets in list above are added to derive the number.  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. The sudo gives you access to any file, it does not change the actual file access, so you might find you can read a file, but not save it after you have done your edit.  If you change the file name shown, then it can save as another file, but you will be asked if the new name is correct (again type '''Y''' to continue saving).
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.
After typing the nano command you need to specify a filename (it might include a path, see previous sub-section) 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 used control and O to save the file, it asks whether you want to save the edited file (type '''Y'''), although the Y carries on, any other key stroke cancels without saving, then it shows the current file name, if you press '''Enter''' then that file will be overwritten.


=== install ===
=== install ===
5,838

edits