Tardis Beginner Tutorials/6
There are many text editors available for linux, the most often used ones being emacs, vi or vim, and nano. Of these, nano is by far the simplest to learn, with functionality not greatly exceeding that of windows notepad - this makes it ideal as your first editor. If you are already well versed in the use of emacs, vi, or anything else more complicated, feel free to use that instead. Using nano is exceedingly simple - all controls are performed by ctrl-key combinations, listed at the bottom of the page. So for instance to exit you press ^X (which means control and x). Whenever you want to find out how to do something that isn't listed at the bottom of the page (for instance select text), press ^G to get a helpful listing of commands.
Now you are going to modify your ".profile". This is a file in your homedir that gets executed when you log in, and is used for setting things like environment variables, paths and the way the prompt looks. First, type ls ~/.profile. If it says "no such file or directory", you will need to copy the default one - do cp /etc/profile ~/.profile. Now open it with nano ~/.profile. To begin with, let's add some aliases to make using some common commands easier, and improve the look of things. An alias is simply a string the shell will recognise on the commandline and replace with another preprogrammed string - usually used to shorten long commonly used commands. You can create them yourself on the commandline with alias - check out the man page. For now we'll add some to the .profile, so they'll be executed every time you log in. Scroll to the bottom of the file using your arrow keys or page down and add the following lines:
alias rm='rm -iv' alias cp='cp -iv' alias mv='mv -iv'
The above replace the usual remove, copy and move commands with aliases to them plus some additional flags: -i makes it ask you interactively if you want to overwrite files (whereas if files were going to be overwritten, it would happen automatically by default), and -v makes the output more verbose, so you can see what it's actually doing. Now let's add some aliases to make ls easier to use, and the output more attractive. Add the following lines to the file:
alias ls='ls -a --color' alias ll='ls -alh --color'
The first tells ls to output in colour, and to show all files (including hidden ones beginning with "."). The second creates a new alias, that you can now use as a command, to make it easier to do ls -l like we did in tutorial 2 to see file sizes and their permissions. The -h flag makes the output human readable - i.e. the file sizes are shown in megabytes and kilobytes rather than just a long number of bytes. You'll notice it's possible to string together multiple commandline flags prefixed by a single dash - another timesaving feature of bash.
Now let's save our file by pressing ^O (which means ctrl and O, as you should know by now). It will ask you what filename to write to - just press enter to accept the default one. If for some reason the filename is not .profile, type that. Then press ^X to exit. If you forgot to save, you would be prompted to save when you pressed ^X anyway. Congratulations, you just successfully edited your first file under linux! Now simply log out (using logout or exit)and log back in as described in tutorial 1. Now try typing ls and ll and see the pretty colours, and notice that hidden files are now shown! Under linux you can make a file hidden by changing its name to start with ".", such as ".profile". Such files are not shown by default, but are with the -a flag - but now you will always see them.
Next: Filesystem Tutorial