Notes written / lifted from documentation whilst trying to figure out this whole
Linux thing. Stuff I know I'd need to refer to again but never be able to find
unless I had it somewhere.
Filesystem Hierarchy Standard
/ the root directory
bin Essential command binaries
for sysadmin and users but needed in single user mode
should be no subdirectories. binaries not essential enough
should be placed in /usr/bin
boot Static files of the boot loader
contains everything required for the boot process except configuration files
and the map installer. Thus /boot stores data that is used before the kernel
begins executing user-mode programs. This may include saved master boot sectors,
sector map files, and other data that is not directly edited by hand. Programs
necessary to arrange for the boot loader to be able to boot a file should be
placed in /sbin. Configuration files for boot loaders should be placed in /etc.
dev Device files
location of special or device files.
If it is possible that devices in /dev will need to be manually created, /dev
shall contain a command named MAKEDEV, which can create devices as needed. It
may also contain a MAKEDEV.local for any local devices.
If required, MAKEDEV should have provisions for creating any device that may
be found on the system, not just those that a particular implementation installs
etc Host-specific system configuration
contains configuration files and directories that are specific to the current system.
No binaries should be located under /etc
home User home directories
lib Essential shared libraries and kernel modules
The /lib directory contains those shared library images needed to boot the system
and run the commands in the root filesystem.
Shared libraries that are only necessary for binaries in /usr (such as any X Window
binaries) do not belong in /lib. Only the shared libraries required to run binaries in
/bin and /sbin should be here.
mnt Mount point of temporary partitions
opt Add-on application software packages
reserved for the installation of add-on application software packages.
/etc/opt local configuration for the add-on packages
/var/opt variable data files for the add-on packages
root Home directory for the root user
sbin Essential system binaries
contains binaries essential for booting the system in addition to the
binaries in /bin.
Deciding what things go into "sbin" directories is simple: If a normal
(not a system administrator) user will ever run it directly, then it
should be placed in one of the "bin" directories. Ordinary users should
not have to place any of the sbin directories in their path
We recommend that users have read and execute permission for everything
in /sbin except, perhaps, certain setuid and setgid programs. The division
between /bin and /sbin was not created for security reasons or to prevent
users from seeing the operating system, but to provide a good partition
between binaries that everyone uses and ones that are primarily used for
administration tasks. There is no inherent security advantage in making
/sbin off-limits for users
tmp Temporary files
The /tmp directory shall be made available for programs that require temporary files.
Although data stored in /tmp may be deleted in a site-specific manner,
it is recommended that files and directories located in /tmp be deleted
whenever the system is booted.
usr Secondary hierarchy
/usr is the second major section of the filesystem. /usr is shareable,
read-only data. That means that /usr should be shareable between various
hosts running FHS-compliant and should not be written to. Any information
that is host-specific or varies with time is stored elsewhere.
No large software packages should use a direct subdirectory under the /usr
hierarchy
var Variable data
(source: http://www.pathname.com/fhs)
The /usr hierarchy:
X11R6 X Window System, version 11 release 6
X386 X Window System, version 11 release 5 on x86 platforms
bin Most user commands
Binaries that are not needed in single user mode
games Games and educational binaries
include Header files included by C programs
This is where all of the system's general-use include files for the C and
C++ programming languages should be placed
lib Libraries
includes object files, libraries, and internal binaries that are not intended
to be executed directly by users or shell scripts
local Local hierarchy (empty after main installation)
for use by the system administrator when installing software locally. It needs
to be safe from being overwritten when the system software is updated. It may
be used for programs and data that are shareable amongst a group of hosts, but
not found in /usr
Locally installed software should be placed within /usr/local rather than /usr
unless it is being installed to replace or upgrade software in /usr.
Note that software placed in / or /usr may be overwritten by system upgrades
(though we recommend that distributions do not overwrite data in /etc under these
circumstances). For this reason, local software should not be placed outside of
/usr/local without good reason
sbin Non-vital system binaries
This directory contains any non-essential binaries used exclusively by the system
administrator. System administration programs that are required for system repair,
system recovery, mounting /usr, or other essential functions should be placed in
/sbin instead.
Typically, /usr/sbin contains networking daemons, any non-essential administration
tools, and binaries for non-critical server programs
Locally installed system administration programs should be placed in /usr/local/sbin
share Architecture-independent data
src Source code
The /usr/share hierarchy: Architecture-independent data
dict Word lists
doc Miscellaneous documentation
games Static data files for /usr/games
info GNU Info system's primary directory
locale Locale information
man Online manuals
nls Native language support
misc Miscellaneous architecture-independent data
terminfo Directories for terminfo database
tmac troff macros not distributed with groff
zoneinfo Timezone information and configuration
The /var hierarchy: Variable data
account Process accounting logs (if supported)
cache Application cache data
crash System crash dumps (if supported)
games Variable game data
lock Lock files
log Log files and directories
mail User mailbox files
opt Variable data for /opt
run Files relevant to running processes
This directory contains system information files describing the system since it
was booted. Files in this directory should be cleared (removed or truncated as
appropriate) at the beginning of the boot process. Process ID files live here.
spool Application spool data
contains data which is awaiting some kind of later processing. Data in /var/spool
represents work to be done in the future (by a program, user, or administrator);
often data is deleted after it has been processed
state Variable state information
This hierarchy holds state information pertaining to an application or the system.
State information is data that programs modify while they run, and that pertains
to one specific host. Users should never need to modify files in /var/state to
configure a package's operation.
State information is generally used to preserve the condition of an application
(or a group of inter-related applications) between invocations and between different
instances of the same application. State information should generally remain valid
after a reboot, should not be logging output, and should not be spooled data.
tmp Temporary files preserved between system reboots
The /var/tmp directory is made available for programs that require temporary files
or directories that are preserved between system reboots. Therefore, data stored in
/var/tmp is more persistent than data in /tmp.
yp Network Information Service (NIS) database files
The /var/spool hierarchy: Spool Directories
lpd Printer spool directory
mqueue Outgoing mail queue
news News spool directory
rwho Rwhod files
smail Spool directories for smail
uucp Spool directory for UUCP
The /var/state hierarchy: Variable state information
Editor backup files and state
misc Miscellaneous state data
xdm X display manager variable data
Packaging support files
State data for packages and subsystems
The /usr/local hierarchy: Local Software and other
bin Local binaries
games Local game binaries
include Local C header files
lib Local libraries
sbin Local system binaries
share Local architecture-independent hierarchy
src Local source code
Filename characters allowed: ~!@$^&*()_+-=`{}[]|\:;"'<>?, a-z A-Z ...
Filename characters not allowed: # % . / .. // /// etc.
C Shell Special Symbols: | < > >> & |& >& #
>& |& Std Error and Out
cmd& run command in background
Variable characters allowed: _ a-z A-Z
set var=string # assigns a string to a variable
echo -n "Enter Value: "
set var=$< # prompts user for a single word to store in a variable value
echo $var # displays a variable's value
@var = expression # assigns a numeric value to a variable
set var = (one two three)
set var = ("one", "two", "three") # create an array variable
echo $var # displays one, two, three
echo $var[1] # displays one
echo $#var # displays 3 - number of entries in array
echo ${var}text # append some text to a variable with no separator space
set var = a/long/path/to/a/file.name
echo $var:gt # file.name (gt=get tail)
echo $var:ge # name (ge=get extension)
echo $var:gr # a/long/path/to/a/file (gr=get root filename)
echo $var:gh # a/long/path/to/a (gh=get head)
echo ${var:gr}.ext # changes the file's extension
set var = `date` # sets variable to the result of a unix command - here we use the date command
set echo # turns on echo of script before execution - debugging
parameters to a script
$#argv # the number of parameters passed in
$argv # the entire argument array
$argv[1] # the first argument
; separates commands on a single line
() group commands together to operate before other commands
i.e. (ls ; pwd) > file
alias name command
\!:1 the first argument to an alias
\!:^ the first argument to an alias
\!:$ the last argument to an alias
\!:* all the arguments to an alias
there are others see man help
foreach var ($vararray)
statements
end
while (condition)
statements
end
if (condition) then
statement
else if (condition) then
statement
else
statement
endif
switch (string)
case pattern1:
statement
breaksw
case pattern2:
statement
breaksw
default:
statement
endsw
conditions
0: false
1: true
&& and
|| or
! not
< less than
<= less than or equal to
> greater than
>= greater than or equal to
== equals
!= not equal to
-e filename the file or directory named exists
-f filename filename is a file and exists
-d filename filename is a directory and not a file
-r filename user has read permission for filename
-w filename user has write permission for filename
-x filename user has execute permission for filename
BASH string manipulations:
for i in *.tar.gz ; do
cd ${i%.tar.gz}
strip off .tar.gz from end of file name
               (
geocities.com/gurucoder/Tools)                   (
geocities.com/gurucoder)