Unix/Linux 101 – The Environment
Back in the olden days of vfx, a lot of the studios used SGI stations and the majority of the artists had to learn unix in order to get around their shell. Nowdays, the majority of the studios have moved over to PC’s and now run linux. ( a Unix-like computer operating system that uses the Linux kernel.) The smaller boutique houses use windows, and at times moving to a bigger studio can be a bit overwhelming for those artists who have never been exposed to it. We were lucky enough to have a fellow peer, Dani Rosen, take the time to give us all a crash course for those who need a refresher or overall basic knowledge of Unix. This article is mostly for artists jumping into the Unix/Linux environment for the first time!
**********
Introduction
This article focuses on basic Unix commands, the Unix environment, and helpful commands for beginners. Although many CG artists use PC machines (IBM compatible) these days because of their popularity, and some use Macs; there often comes a time when an artist is faced with the Unix/Linux environment.
Most CG companies that use a variant of Unix use IRIX – which is the Unix operating system of the Silicon Graphics Machines. Except for graphic-specific commands found on IRIX, most Unix commands work almost the same on all types of Unix. However, nowdays most Unix houses are now Linux. Every day new Unix commands are written to make the work flow of the artist a little easier. IRIX is filled with commands to manipulate images and movies, which these days – most compositors and other external GUI applications can handle much better and with more control. It would be a waste of time to go over those command, however, feel free to explore the /usr/sbin directory for those commands.
This article will not go over the history of Unix (there are plenty of those on the Net), as well as in-depth explanations. This is merely a jump-start for animators who have never used the Unix environment before (or need a tune-up). I am taking into account you know how to log in and open a shell. If you don’t know how to log-in, speak to your system administrator and ask about entering your username and password. A shell in IRIX can be obtained by clicking (or running) “winterm” The next article – “Intermediate Unix and Unix scripting for artists”, will cover some more advanced Unix commands and some useful Unix scripting (release date is unknown…). So let’s jump right in….
The Unix/Linux Environment
PC machines using DOS or Windows as the operating system, will have a specific letter representing each drive on the system (Hard drive, CD-Rom, Zip drive, etc.) as well as different partitions. Often “C:\” represents the first partition of the first hard drive. The Unix environment, on the other hand, uses one tree structure with many branches (sub-folders / sub-directories), and even though a Unix machine might have more than one hard disk, a CD-Rom, or other peripheral, each one of these hardware devices is put under the same tree structure rather than receive a new Drive Letter. The top of the tree structure is called “Root” and is represented by a forward slash – “/” (unlike the back-slash on PCs – “\”). Underneath the Root you would normally find these typical directories (only a few are shown):
/
|
|—– etc
|
|—– usr
| ___|—– sbin
|
|—– bin
|
|—– home
____|—– myname
________|—– mail
The tree structure is a hierarchy of directories and sub-directories. Moving through this structure can be done using an absolute path or a relative path. An absolute path is one that represents the location starting from the very top, the root. In a shell (a window where we type commands – not a sea-shell) we start of at our home-space and type “pwd” to see our absolute path:
# pwd
/home/myname
The “#” symbol represents the beginning of the line where we can type our commands. It can be set to a different symbol but it’s just a representation symbol, it has no affect on your commands. You often see different symbols like “>”, “:”, “]”, “%”, “$”, etc. For these examples I’ll use the “#” symbol.
The “pwd” command shows the Present Working Directory, and in this example it shows you’re in the “myname” directory, underneath the “home” directory, which is right under the root. This line, starting from the root, “/”, is called an absolute path.
Some systems may configure your command line to include the “pwd” in it:
[/home/myname/]
When you want to move to a different directory using an absolute path, you enter the whole path starting from the root. You use the “cd” command (Change Directory) to move to other directories:
# pwd
/home/myname
# cd /bin
# pwd
/bin
We just moved to the “bin” directory, which is under the root.
An absolute path would always get you exactly where you want to go, no matter where you are. Typing “cd /bin” from anywhere in the tree structure would always get you to the “bin” directory. However, sometimes you just want to take a small step, and don’t want to enter the whole absolute path. For those cases you use a relative path. A relative path always works from your current location and will not give you the same results when you’re in a different location. For example:
# pwd
/home/myname
# cd mail
# pwd
/home/myname/mail
As you can see, I didn’t have to type the whole absolute path starting from the root “cd /home/myname/mail” because it was much quicker for me to do this relatively. However, I won’t be able to type “cd mail” from a different directory and expect to get to the same location. Relative navigation uses some useful symbols:
“.” – current directory
“..” – parent directory
“-” – last directory
“~” – home space
Examples:
# pwd
/home/myname
# cd ..
# pwd
/home
# cd ..
# pwd
/
# cd bin
# pwd
/bin
# cd ~
# pwd
/home/myname
# cd -
# pwd
/bin
What happened here? First we moved up one directory (..) to “/home”, then again to “/” (root). We then moved to the bin directory and then to our home space (~). We then moved to the last directory we’ve used before moving to home-space (-) which was back at “/bin”. Note – accessing you home-space can be done by simply typing “cd” with nothing else after it.
Relative navigation can be done in one line too:
# pwd
/home/myname/mail
# cd ../../../
# pwd
/
In one command we moved up a directory three times till we got to root. The “..” symbol is just a representation of the directory above the one we’re in. Another example:
# pwd
/home/myname
# cd ../../bin
# pwd
/bin
The “.” Symbol represents the current directory. We can use it with the copy command “cp”. The “cp” syntax is: “cp source destination”, so to copy a file called “myfile.txt” from the “/tmp” directory to the one I’m currently in, I would type:
# cp /tmp/myfile.txt .
Using an absolute path, I would type:
# cp /tmp/myfile.txt /home/myname/
Tags: Dani Rosen, linux, tutorial, unix






Sat, Jan 5, 2008
Unix/Linux