So, you've got a shell account with TASTYTRONIC INDUSTRIES, but you don't know the first thing about UNIX? Never fear! This document will help you understand how to get around on flynn, and next thing you know, you'll be a l33t h4x0r. Well, we hope not. But anyway.
Let's start with the shell. The shell is so named because it is what interfaces with the kernel or "operating system" of the computer. (It's a pun. Shell, kernel, get it?) The shell has often gotten a bad name, because it involves a lot of typing, has no pictures, and practically never uses the mouse. It also has a bad name because the only shell-like interface most people have ever had to use is MS-DOS, which is a great example of all the bad parts of a command-line interface.
But the shell -- that is real shells -- are fantastico: they are still some of the most efficient and versatile interfaces yet created for the computer, despite their being over 30 years old!
The shell was created way back in the day -- so long ago that computers were infinitesimally slower than they are now. Efficiency had to be milked out of the computer at every available opportunity -- and this meant limiting the input and output of the computer to only necessary information -- every keystroke counted since it had to be sent back and forth over slow modem connections.
This means that most of the standard commands in the shell are usually almost as short as possible: ls, cd, cp, mv, rm -- all good examples of cryptic-looking commands -- but what at first appears cryptic isn't necessarily so.
You see, the common "user friendly" idea of "folders" and "files" is practically as old as computer filesystems themselves. It's just that recently, we've been seeing files and folders represented as pictures instead of words. But the concept is the same: Folders (called directories in UNIX) contain files and other folders, and to access them, you "move" from folder to folder, or you specify the folder by name. This introduces the concept of a "current working directory" -- which in a graphical user interface (or GUI) is the "folder" you're currently "looking at."
In Windows, you might double-click on "My Computer" and then on the "C: drive" -- this opens up a window showing the contents of your C: drive, making C:\ (the top folder of your hard drive) your current working directory. Anything you do in that window will be performed on the contents of that directory. In the shell, the same thing is true, except that the representation is text, not graphical.
In fact, those commands listed above: ls, cd, cp, mv, rm -- are all the same kinds of commands that you would perform with a mouse in Windows or MacOS. Compare:
ls : list files. Typing ls displays the files in the current working directory, i.e. "the directory you're 'in'". This is analogous to opening a window to look at your files in a GUI (graphical user interface) such as Windows. In the shell, you can provide ls with an argument, such as:ls pictures
This will display the contents of the folder "pictures", or will indicate that "pictures" is indeed a file.
This will list the files in the current working directory. Notice that we did not provide ls with an argument (a file or directory for it to "look at"), so it assumed you meant "list the files 'here'", with "here" being your "current working directory".
cd : change directory. Typing cd changes your working directory. Like ls, you can either give it an argument (a directory you want to change to) or no argument for a default action.cd pictures
This will change the current working directory to the directory "pictures" or will indicate that "pictures" is a file and not a directory.cd
If you type cd without an argument (pictures was the argument in the last example) it will change to your "home directory," which is usually the top level of your personal space on the computer. Shells usually run on top of a UNIX-like operating system, which has special places for each user to store his or her files.cd ~
On most systems, "~" is a synonym for "my home directory" -- so you can type cd ~ to change to your home directory, or use ~ as a "shorthand" to mean "my homedirectory." This means that you can do fun things like type cd ~/pictures/vacation to change your working directory to the vacation directory, which is in the pictures directory, which is in turn, in your home directory.cd ..
This is another shorthand argument, which means "go up one directory." In Windows, it is often represented by an up arrow inside a folder. If you had changed to ~/pictures/vacation and wanted to change back to ~/pictures, you could just type cd .. to move "up" one level, rather than retyping cd ~/pictures. Likewise, you can move up several levels by typing cd ../../.. and combining the shorthand operators. .
cp: copy. cp is the copy command -- you use it to copy files, and you must provide it with two arguments, the first being the file you want to copy, and the second argument being the destination to copy the file to.cp ~/pictures/mom.jpg ~/sue_peterson.jpg
This command reads the file mom.jpg in the pictures directory and makes a copy of it called sue_peterson.jpg in your home directory. If I had just typed:cp ~/pictures/mom.jpg ~/
...it would have copied the file to my home directory with the filename intact -- in this case, mom.jpg.
rm: remove. rm is the remove command -- you use it to remove or delete files. You must provide it with at least one argument -- the file you want to delete.rm ~/pictures/chef_boyardee.jpg
This will remove the file "chef_boyardee.jpg" from the ~/pictures directory.
mv: move. mv is the command for moving files or directories. It requires two arguments -- the file to move and where to move it to. Notice that mv is sort of like a cp followed by an rm which removes what was just copied. Consider:mv ~/pictures/mom.jpg ~/
This will move the file "mom.jpg" to my home directory. It will no longer exist in the pictures directory.