UNIXary
This is a work in progress. If you want something added, or explained better please let us know.
argument
argument(s) are provided to commands to tell them what to act on. For example, a file or #directory #path could be provided to the ls command to alter its default behavior of listing out the current working #directory.
cat
cat displays the contents of files listed its arguments in order even if it scrolls off the screen. This is more useful with standard output rediection; ie,
cat a b c > d
concatenates files a, b, c and stores the result in d.
cd
cd is the command used to change your current working #directory; eg,
cd /share/apps
cp
The copy command, cp, is used to copy files from #pathname to another. The basic usage is
cp src dest
where dest may be a file or directory in which case the file dest/src is created. More than one src can be provided in which case the destination must be a directory. For example,
cp src1 src2 dest
creates the files dest/src1 dest/src2. cp provides some useful #options:
-p => newly created files should have the permissions, and timestamps of existing files
-r => copies directories
diff
directory
A directory in UNIX is a file whose contents are the members of the directory. Some inferior Operating Systems refer to these as folders. Some important directories that you may deal with when using CCBB systems are
/share/apps => the location of many 3rd party, and non-standard applications, development toolkits, and so on
/share/scripts => the location of some job script templates that we provide
/home/username => the home directory of a particular user. When typing on a #shell commandline, or in a shell script this may also be referred to using ~ (for your own), ~username, or using the $HOME #shellvariable.
Every #process (including your #shell command line) has a current working directory. This is the directory that you are currently processing in. Within your current directory there are two more directories that you can access
. => the current directory
.. => the parent of the current directory
Your current working directory, if you have not paid attention, can be determined with the command: pwd. You can view the contents of a directory using #ls.
Environment
Every program runs in environment which is a collection of variables that are inherited from their parent, and which they pass on to their children. They use these variables to modify how they run. One important variable is #PATH which is used to find executable programs, but there are many others. For example, BLAST uses a variable called BLASTDB to find its databases.
globs
Globs are shell constructs which are used on the command line to stand for patterns of numbers. They are related to Regular Expressions so care must be made to understand their differences. There are 3 types of globs
* which matches any number of characters or none at all
? which matches any single character
[] which may contain single characters to be matched
Some example uses:
ls *.tar.gz (matches any file ending in .tar.gz)
ls c?t (matches cut, cat, and any other 3 letter words starting with c and ending with t)
ls c[au]t (matches cut, cat, but not other 3 letter words starting with c and ending with t)
WARNING When using globs with rm you need to be very careful to make sure the glob doesn't match more than intended. Using ls possibly with the -d option first is suggested. More so when used with -r. Some people run into problems because * does not match files that begin with a leading . as these are 'hidden' files, and are usually config files of some sort. This leads them them to run
rm .*
and disaster ensues if -r is also specified. This is because .* matches the special directory entry .. which stands for my parent. Always use .??* as a glob which matches hidden files.
grep
head/tail
kernel
The kernel is the core of the operating system. It is responsible for managing devices like disk drives, enforcing user permissions and access controls, and scheduling processes to be be run on the CPU.
ln
The ln command creates links which are file tree entries. Most common are symbolic links which are just fake names which point to an existing name. You create a symbolic link using
ln -s old new
where old and new are paths. Less common at least for normal uses are hard links. A hard link is a 2nd name for the same blocks of data. To create a hard link you use
ln old new
They are different in many ways, but the most notable difference is that with symbolic links you know that the link exists. Thus, if you remove the old file then the link dangles waiting for it to be recreated. On the other hand, there is no overt indication that a hard link exists. Either name may be removed with out affecting the fact that the other still exists, and can be used to refer to the blocks on the disks that store a particular file. The next major difference is that you cannot hard link a directory, but you can soft link one. Finally, soft links can be seen using ls -l which shows them as new -> old.
ls
ls is, next to cd, probably the most used UNIX command. It is used list out the contents of a directory. For example, you can do
ls path
to have the listing of #path. The #path #argument is optional; if you don't provide one, then the current working #directory is listed out. If #path is a directory the contents of the directory are listed out. If #path is a file, then only the file is listed out which at least confirms its existence. You can provide multiple paths, too.
ls has many useful #options
-l => show also meta-data such as modification and access times, permissions, sizes, and ownerships
-a => show all files (by default, files which start with . are not listed out since they are usually configuration files)
-d => list out a directory, and not it's contents
-t => sort by modification time (puts newly created or modified files at top)
-r => reverse sort
-F => add 1 character at end to indicate file type:
* => executable (or at least executable permissions granted)
/ => directory
others