Lars Wirzenius, Daniel Silverstone Welcome

Welcome to Yakking.

This is a blog for topics relevant to someone new to free software development. We assume you are already familiar with computers, and are curious about participating in the production of free software. You don't need to be a programmer: software development requires a wide variety of skills, and you can be a valued core contributor to a project without being a programmer.

To get the most out of Yakking, you will need to be curious, and you will need to enjoy doing things with computers, and making computers do things. That's the essence of being a hacker. We'll write more about that some day.

We particularly target development in the free software world. This is different from general software development in various ways, some of them ethical or motivational, others technical or procedural. We'll discuss those too, in a future blog post.

We'll be doing about one post per week, on Wednesdays. Topics we plan to cover include:

  • principles and ethics of software freedom
  • basics of using Linux (or other Unices) from the command line
  • development tools
  • development processes

Of course, if you're interested in seeing us write about other topics, please do contact us and let us know.

All in all, think "Boing Boing", except for new free software hackers.

Let's have fun.

Posted Wed Aug 21 12:56:55 2013

Software freedom is the idea that the software you use, or that society uses, affects your freedom as a human being. As an example, the operating system might limit you to a small number of programs running at the same time, so that the vendor can charge you more for a "professional version". The operating system in your DVD or Blu-Ray player may prevent you from playing a DVD bought in a different country. The e-book application on your phone or tablet may decide you're now in a country where it's not allowed to function, and deletes all your e-books. These are all real examples of antifeatures.

Free software promotes the freedom of its users. It is based on four basic freedoms, as defined by the Free Software Foundation:

  • The freedom to run the program, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

There are other definitions of freedom. The Debian project has its own guidelines (DFSG), which are somewhat more detailed.

Software freedom is often defined in terms of licences. A licence is a free software licence if it allows the four freedoms to anyone who receives a copy of the software. There are two major kinds of free licences: permissive and copyleft. Copyleft licences require that any changes to the software get licensed under the same licence; permissive licences do not. Much heated discussion has been had about this difference.

The GPL, or GNU General Public License, is the most common copyleft licence. The Mozilla Public License is another one. The BSD licence is the archetypal permissive one.

Open source is a related, but different concept. It builds on the DFSG, but instead of freedom, it concentrates on the practical benefits to the software development process of free software licenses. It turns out that when everything is done in the open, and everyone can participate on equal terms, and everyone is allowed to make any changes they want, the development can often proceed at a very fast speed.

In practice, open source and free software use the same licences. Developers will usually identify with one or the other approach, or both, and happily work together with the other kind.

The commercial world obviously favours open source, as a concept, over free software. Don't let that stop you from doing what's right.

Happy hacking.

SEE ALSO

Posted Wed Aug 21 13:00:39 2013 Tags:
Daniel Silverstone Basics of the command line

In the beginning was the command line and yet these days it's considered the realm of the neckbeard hackers. The mass media use command lines to illustrate digital-misbehaviour and Hollywood uses it to prove that the character knows something super-duper-clever about computers. However, in reality, the command line is a critically powerful tool which no self-respecting reader of this blog would ever go without knowing, understanding, and ultimately loving.

Almost every Linux desktop you find (and Mac OS X, and in fact Windows) has a terminal application of some kind. It might be called Terminal or Console or perhaps something more technical-looking such as gnome-terminal or urxvt. Regardless of its name, the purpose is the same. To provide you with a window onto the underlying power of the command line.

The command line is often referred to as an interactive shell and in later articles we will speak more about the shell as a whole. We talk about shell prompts when we are talking about interactive shells. The prompt is how the shell program tells you that it is waiting for you to tell it what to do.

Almost all shell programs have sh in their name, typically at the end. You will find a plethora of them available, from the humble dash through the very common and well used bash to the super-powerful (and somewhat hard to understand at times) zsh. There are two major families of shells in the Linux world. Those which are considered Bourne shells and those which are considered C shells. In the former are bash zsh ksh and similar. In the latter are tcsh and friends. These two families represent very divergent syntaxes (the language they implement) and we will mostly concern ourselves with the Bourne shells in Yakking articles.

My first shell prompt

When you open your terminal program, you'll likely be faced with a squareish window with a single bit of monospace text in the top-left of the window. Depending on your terminal it'll typically be white-on-black or black-on-white, however many other colour schemes exist, and you can usually customise it yourself if you wish.

myuser@mycomputer:~$ 

You'll usually see a flashing box or underline next to that text. This is the prompt and we'll break it down in a moment. It is worth noting that this is just the default bash prompt for Debian and derived systems. If your shell is dash (or even the venerable sh itself) then your prompt may be as simple as a single $ sign. If your shell is an unconfigured zsh then it may be simply mycomputer$.

The bash prompt above has four major parts. The first two before the colon and the second two after it. The first part is the user name. This is the name you use when you log into your computer. Then you have an at-sign followed by the short host name of the computer. After the colon you have the path you are currently in. This is the full name of the directory (or folder) where your shell is currently residing. We will see more about directories later. Finally the $ indicates that your shell is not running with administrator privileges (as root). If instead of a $ you have a # then you know that the shell is running with elevated privileges and that you should be super-careful.

Navigating the filesystem

Up until now, you've probably been used to navigating your filesystem in a file manager such as Nautilus, Thunar or Konqueror. You may even only have interacted with the filesystem through the load and save dialog boxes in your GUI applications.

Every program on your computer has a concept called current working directory (or CWD) which is the area of the filesystem where the program is currently running. Your shell is no exception to this. In the example above, the CWD was ~ which is actually a shell shortcut for user's home directory. Often this will actually be something like /home/username but it may not be.

To change directory in the shell, we can use the cd command which is built into the shell:

myuser@mycomputer:~$ cd Desktop
myuser@mycomputer:~/Desktop$ 

As you can see, when you enter a command (and press ENTER) the command is run and then the shell prompts you again. Only this time, the shell's CWD has changed and so the prompt alters to reflect that. In every directory there are two magical directory names which represent here and parent (. and .. respectively):

myuser@mycomputer:~/Desktop$ cd .
myuser@mycomputer:~/Desktop$ cd ..
myuser@mycomputer:~$ 

You can also specify the full path to a directory to change into, for example:

myuser@mycomputer:~/Desktop$ cd /home/someoneelse
myuser@mycomputer:/home/someoneelse$

If you are not sure what the exact name you need is, you can ask for a listing of files, both in the current directory or in any specific directory of your choosing:

myuser@mycomputer:~$ ls
bin      Desktop   Documents  Welcome.txt
myuser@mycomputer:~$ ls /
bin   etc         lib         media  proc  sbin     sys  var
boot  home        lib64       mnt    root  selinux  tmp  vmlinuz
dev   initrd.img  lost+found  opt    run   srv      usr
myuser@mycomputer:~$ 

Not everything that the ls command shows you is a directory, but typically in modern GNU/Linux (or similar) systems, it will colour its output to show you what is what. If it is not colouring things in for any reason, you can ask it to give you a marker for each entry to indicate what it is:

myuser@mycomputer:~$ ls -F
bin/      Desktop/   Documents/  Welcome.txt
myuser@mycomputer:~$ 

In the above example, directories are shown with trailing slash markers (/).

The cd built-in command also has a couple of very neat tricks up its sleeve. A bare cd will change back to the user's home directory:

myuser@mycomputer:/somewhere/odd/goodness/knows/why$ cd
myuser@mycomputer:~$

If you say cd - then you switch back to where you were before:

myuser@mycomputer:/somewhere/odd/goodness/knows/why$ cd /bin
myuser@mycomputer:/bin$ cd -
myuser@mycomputer:/somewhere/odd/goodness/knows/why$ cd -
myuser@mycomputer:/bin$

Running programs

In the previous section, we saw two kinds of action at a shell prompt. Running a built-in command such as cd or running another program such as ls.

Commands you typically run at the command line will often have very short confusing looking names (until you get used to them) such as ls, pwd, grep, xargs etc. Do not worry too much about this for now. We will cover essential shell utilities in another article in the future.

When you run a command at the command line, you can give it extra information on what to do; these are called arguments. Above we gave ls the extra argument -F which told it to annotate each entry so that we could tell what kind of entry in the filesystem it actually was. Commands may take between zero and many-lots arguments and may change their behaviours based on those arguments. Where arguments begin with a dash or double-dash, we call the argument an option or switch. (In MS-DOS, switches started with a slash instead).

Editing your commands

The shell's interactive prompt is also often called the line editor as you can actually edit your command line before running it.

If you are typing in a long command, you may find that you need to go back and edit something early on in the command line. There are a number of keys and key combinations which can help you to edit your command line. The simplest and perhaps most obvious of which are the Left and Right arrow keys which move your cursor left and right along the command line you are entering right now. Other handy keypresses (bash specific in some cases) include:

  • Control+A: Go to start of line
  • Control+E: Go to end of line
  • Control+K: Delete from cursor to end of line
  • Control+U: Delete from cursor to start of line
  • Control+Left: Go left one word
  • Control+Right: Go right one word
  • Control+D: Delete character to the right of the cursor. (Note, sometimes your cursor is represented by a block not a line. In that case, the character underneath the cursor is the one which will be deleted). There's plenty more but those are the basics.

Delving into history

The shell keeps a log of the commands you run. It will even save this when you leave an interactive shell and restore it when you start your next interactive shell. The history can be accessed in a variety of ways. The most commonly useful are the Up and Down arrow keys. These go back and forward through the history of commands you have entered.

The next history command you should learn is Control+R which provides an unusual prompt:

(reverse i-search)`':

As you then type, the shell will search backwards in the history looking for a command which matches what you type. When you find the command you want, you can use the Left and Right arrow keys to then bring it into the line editor for you to work on before pressing Enter to run the command.

There are many more history related keypresses and shortcuts, but they are a topic for a future article here on Yakking.

How do I get out?

There is a shell built-in command called exit which will leave the current shell. If you enter that at a prompt, the shell will exit and the terminal window it was running in will likely close automatically.

Conclusion

The interactive shell is a simple but immensely powerful way to have a conversation with your computer. It is not something to be scared of, but rather something to learn to master to improve your general productivity. You can often do quickly on the commandline something which might take a significant amount of clicking around to achieve in a GUI.

If you want to find more, you can look at the shell related articles here on Yakking, read the article linked in the first paragraph of this article or just get going and see what you can find out just by playing with your shell prompt.

Posted Wed Aug 28 11:02:44 2013 Tags: