As I’ve thought about how to write up a tutorial on setting up a FTP server using Linux, I keep coming back to one, glaring problem: it’s difficult to edit text in Linux. This is actually an amazing oxymoron if you know anything about Linux systems. There are probably thousands of commands and software tools available for text manipulation. Programming languages were developed purely for text manipulation. The entire Linux operating system is developed to be configured via simple, plain text documents.
So how can it be difficult to edit text when it’s so fundamental to the system?
Well, truth be told, it’s not difficult at all. It’s actually unbelieved easy to edit, processed and manipulate text in Linux. Once you know how. But learning how? Well that takes a little time. It’s not as intuitive as opening Notepad on Windows. And there are lots of options out there. Some people like to use
vi (my favorite text editing program, some like
nano, some like
emacs. And there are others.
The thing is, other than editing text files, the rest of a Linux tutorial is pretty easy.
So if I were writing a Windows tutorial, I could just say, “Open up the file in Notepad and type…” For Linux, I’d either have to walk you through vi step by step, “Type
vi smb.conf. Now press G to get to the bottom. Press the i key. Type in xyz. Press escape. Type :wq.” Not only is this confusing and difficult to read, it’s difficult to write, requires that I not skip any steps and it ultimately more of a tutorial on
vi than it is on what I’m actually writing about.
The thing is, other than editing text files, the rest of a Linux tutorial is pretty easy. For example, if I need you to see what directories are available in your user home directory I can just tell you to enter the following commands at the command line:
$ cd /home
And that’s it! It’ll shows you all the directories in your home folder. With a Windows tutorial, I’d have to either post screenshot after screenshot or try to describe things and account for changes in Windows XP and 7.
Click the Start/Windows button
Click on My Computer or Computer
Click on the drive labeled C:
Look for a directory called ‘Documents and Settings’ in Windows XP or ‘Users’ on Windows 7
I probably could simplify this a bit. But you get the point I’m trying to make.
Let me give you a better example of a Linux command and how easy and handy they can be. Let’s say your using vsftp for your FTP server and you want to see how often a PC with the IP address 192.168.1.100 is connecting to the server and what it is downloading. Type the following command at the command line:
$ grep 192.168.1.100 /var/log/vsftpd.log | less
I don’t want to just give it all up and say, “To hell with Linux, it’s too complex for regular uses.” Because it’s not. It’s actually very elegant and easy to use, text editing just requires some training.
This will list every line in the vsftp log file where 192.168.1.100 shows up in a display where you can scroll up and down with the arrow keys. This can be extremely handy and useful in a tutorial because I know exactly what you are going to be looking at when you type that command.
So where does that leave us?
Well, I don’t want to just give it all up and say, “To hell with Linux, it’s too complex for regular uses.” Because it’s not. It’s actually very elegant and easy to use, text editing just requires some training. And I don’t want to give a text editing tutorial with every, single tutorial I write on using a Linux box.
That’s why I’m writing this post. For all of my Linux tutorials I will simply tell you what text files to edit and what to put in them. Bellow is information on the mechanics of editing a text file and I’ll simply link to this post anywhere editing a text file is required.
Editing Text in Linux
For all of my Linux tutorials I will simply tell you what text files to edit and what to put in them. Bellow is information on the mechanics of editing a text file and I’ll simply link to this post anywhere editing a text file is required.
Assuming we’re working on a command line based, server version of Linux. There are three popular editors and two that I would recommend. The three are:
nano are the easiest to use with
nano being the easier of the two.
vi is an amazing text editor. Once you get the hang of it, it’s an incredibly fast and efficient editor. But you will need to take a little time to train with it. If you plan to seriously manage a Linux server, you will need to learn
vi. If you just need to modify a few config files,
nano will get the job done.
If you plan to seriously manage a Linux server, you will need to learn vi.
nano text editor is pretty easy and straight forward. To start it just type
nano followed by the filename. Example:
$ nano /etc/samba/smb.conf
This will open the Samba config file. At the bottom will be all of the commands you can use in
nano. The the ^ symbol means to hold down the Ctrl key while pressing it. So if you see ^R it means to hold down the Ctrl key and press R.
One thing that might confuse you a little bit is the nomenclature. For example, where a Windows users might think of loading a file as “Opening” the file
nano uses the word “Read” for loading a file, as in “Read the file” rather than “Open the file”. They’re the same thing, just different words. Instead of Save, it uses the phrase Write Out. Search is Where Is. It’s not too hard to figure out what the commands do, as long as you know up front that it mights not be what you’re use to.
vi (technically it’s vim, but the command
vi will run vim so don’t worry about it) just enter the following command at the command line:
If you are using a Linux distribution with a full GUI, like Ubuntu Desktop, Fedora or Mint, you’ll find working with text files is very, very similar to working with text in Windows.
This is an interactive tutorial that will walk you through using
vi. It takes about 30 – 40 minutes to go through and is worth it. One point that might make your life a little easier; the tutor tells you to use the keys h j k and l for navigation; you can just use the arrow keys.
If you want to learn emacs. You’re on your own.
Next up is the GUI (Graphical User Interface) option. If you are using a Linux distribution with a full GUI, like Ubuntu Desktop, Fedora or Mint, you’ll find working with text files is very, very similar to working with text in Windows. Gnome – the GUI software used in Ubuntu, Fedora and many, many others – uses a program called
gedit (it usually shows up as “Text Editor” in the menus) and it is similar enough to notepad under Windows that you won’t need any extra training to use it.
The only thing you have to know is how to start
gedit as root (the systems superuser). Configuration files are all owned by root, so you’ll have to become root to edit them. This is easy enough, you can do it through a terminal window. Start a terminal (press Alt+F2 and type
gnome-terminal) and enter the following command:
$ sudo gedit /etc/samba/smb.conf
The only thing you have to know is how to start gedit as root (the systems superuser). Configuration files are all owned by root, so you’ll have to become root to edit them.
This will ask you for a password. Enter the password and the Samba config file will open in
gedit with root user access. The
sudo(super user do) command runs the program after it as root. It is much safer than actually using the system as root, where you can easily cause damage.
If you have done as I would suggest and used Ubuntu Server edition as your Linux server and just can’t wrap your mind around using the command line. You can install the full desktop on your server with the following command:
$ sudo apt-get install ubuntu-desktop
Now, just FYI, this is strictly frowned upon because the more software you install on a server the more open it is to potential hacks. It might be paranoia on Linux server folks part (they are a paranoid bunch because they’re mostly hackers themselves), but that’s just what they think. If you have a firewall (usually a router your server goes through to get to the Internet) you’re probably fine. And even if your server is connected directly to the Internet you’re probably find. I just want to let you know it’s not considered best practices.