I know that Linux is an operating system built on text files. What I would like to do is create a file using vi
of all the various commands I have learned. That way I could find each individual command very easily using the /
in vi
. But I only want to do this if it doesn't change the way that my computer functions. Would this be a good idea?
Writing a text file isn't going to "change the way that your computer functions".
In particular, in order to do something like that, you'd have to do one of
Since you're not going to explicitly be doing anything like this, there is nothing to be worried about. In particular, the other answer goes to unnecessary lengths by suggesting your text files need to begin with hashes on every line. Of course they don't. Just storing a text file somewhere within a normal home directory is not going to do anything.
You can save all the commands you have learned in a file but some important points to note:
source
the fileThe best way would be to put a
#
in the beginning of all the commands to comment out all the commands so they don't get executed accidentally. This way you can actually search for the command you need and also would be risk free. You can add#
at the start of each line by the following command:sed -i 's/^/#/' <file_name>
EDIT: I have given the third point as an extreme security measure, as "neon_overload" and "David Z" pointed out that putting hashes in all the lines is too extensive and hence not needed, i would second with them in this context. Also as pointed out by "random832", a far better alternative to my third point would be to start the file with
exit
, as no later commands will be executed then.EDIT-2: "Rinzwind" has mentioned two important points:
Do not overwrite an existing file
Store the file in the user's home directory (
/home/$USER/
).neon_overload has a very good answer.
I'll expand a bit on a certain facet of your question - I would make this a comment, but I don't have enough reputation on here.
Linux, as an operating system, is very much NOT based on text-files. That said, I can kind of see where you are coming from. To an outside observer, there is a fair bit of going on with editing and launching "text" files, especially compared to Windows.
This has several reasons, some of which are:
The short answer is, no, you won't change your computer by creating a text file in vi. However, if you aren't careful, creating that first text file just might change your life. Learning the Unix way can be a deeply rewarding practice.
vi
is a text editor, therefore if all you want is just store some text snippets in a text file, and search through it, then you can do it all directly from the terminal with the built-in commands.Write a note to a text file (will create the file if it didn't exist):
echo note with important data >> info.txt
IMPORTANT: Watch out for single and double quotes, and prefix them with slashes if you want them included.
Search the file for some text (e.g.
important
):grep --color -i important info.txt
To avoid typing
--color -i
that should be aliased in your~/.bashrc
.You can also add multiline text to existing or non-existing text files:
then type or paste the text, and when done then press CTR+Z
As for changing the system, no, it won't change the way your system works as long as you create files in your own home folder and don't execute them (you can execute a file even if it's not executable, e.g. with
bash myFile
). Also make sure you only use the root privileges strictly when you need them.And finally, your interpretation of file-based system has misled you somewhat: most operating system have files that store important settings which deeply affect the way the system operates, but they are located in predefined locations and typically are protected from modification by regular users.
It is possible though to easily shoot yourself in the foot, for example, if as a regular user you have a local 'executable' folder that you added to
PATH
, and if in that folder you happen to have executable files that have same names as built-in common utilities or bash keywords, such astest
,echo
,cat
,for
,cut
, etc.