What do all those Unix commands mean?

Last modified: October 9, 2009 - 01:09

You will notice references to Unix commands in some documentation or forum posts and might be a little unsure what they do. The reason a lot of the docs or forum posts just list the underlying commands is because they are a much more universal interface and the process can be expressed quickly without writing long winded paragraphs describing things.

You may wonder why you would want to know what these Unix commands do, but once you have a better idea of what they do you can then translate them to the functionality provided by your control panel or FTP client etc.

Some Unix command you'll see mentioned:

chmod
changes the permissions on files and directories. The '-R' (for recursive) option switch changes the permissions on subdirectories and files as well.
mv
moves or renames files and directories. In general to rename a file or a directory you 'move' it to its new name.
rm
removes (ie deletes) files and/or directories. To remove a directory you need to use the r (for recursive) switch ie 'rm -r'.
cp
copies files and directories. The '-p' (for preserve) option switch also copies permissions and ownerships etc. The '-r' (for recursive) option switch also copies subdirectories and files as well. The '-a' (for archive) option switch includes both -r and -p options.
mkdir
creates a directory.
ln
creates a filesystem link. The main kind you will see mentioned is a 'symbolic link' (using the '-s' option switch) which behaves a bit like a shortcut in windows. You can create a link to a file or directory located somewhere else and it will behave just like a copy of that file or directory. But because they are linked rather than just copied, changes to one are reflected in the other.
wget
a command to download web pages or files off the net and save them to disk.
tar
a zipping and unzipping utility. eg the Drupal download is what's called a tarball. tar is used to 'unzip' the tarball into a subdirectory.
mysql and mysqladmin
command line utilities for connecting to and managing a MySQL database. Just about anything they can do can also be done by phpmyadmin.

Special characters:

/
the Unix directory separator (just like with URLs) and also represents the root directory. When a path starts with / it is an absolute path ie it starts with the root directory. A path ending in / is an optional way of explicitly referring to a directory rather than a file.
..
refers to the parent directory (just like in Windows). A path starting with this is relative to the current directory. Can be chained together eg ../.. refers to the parent of the parent directory.
.
like '..' but refers to the current directory.
~
it refers the user's current home directory (e.g., /home/username)
*
wildcard that matches any number of characters (like in Windows)
?
wildcard that matches just one character (like in Windows)
 
 

Drupal is a registered trademark of Dries Buytaert.