advanced file systems (original) (raw)
| | | OSdata.com | | ---------------------------------------------------------------------------------------------- | | ---------- |
summary
This subchapter is an advanced look at UNIX (and Linux) file systems.
Important reminder: Always use the root or superuser account sparingly. Do most of your work with an ordinary user account and switch to the root account only when needed. And then switch back as soon as possible. The sudo command can be used for temporarily switching to the root account to run a particular command.
advanced file systems
This subchapter is an advanced look at UNIX (and Linux) file systems.
Some of the information in this subchapter is a refresher carried over from previous subchapters. Also see the subchapter on major directories.
absolute paths
It is common for a system administrator logged in to the root or superuser accunt to type out the absolute path to a command or utility. This will skip any aliases. This will also skip over any commands in the user’s defined search path. This guarantees that the correct command or utility will run.
everything is files
In UNIX, everything is a file, even hardware devices such as printers, hard drives, and other devices. Even UNIX abstractions such as directories, pipes, and file redirection are treated as files.
Becuase everything is a file, the operating system can provide a common processing and communication interface. This is essential to the UNIX approach of using lots of small programs or utilities that do one job well and connecting these programs with shell scripts to do a wide variaety of activities.
man pages
Many forms of UNIX have a man page on filesystems.
$ man filesystems
If your system has this man page, you will find a general overview of UNIX file systems of all types, including CDROMs, floppy disks, and tape drives.
diskless
Almost every UNIX system has a root directory and file system, which is stored on one or more hard drives connected to the computer system.
There are diskless nodes. These are computers that don’t have their own local hard drive. Diskless nodes run off a network server. Mac OS X makes it easy to set up a computer to run in this manner. This approach is often used when an organization wants central control of all of the computers in the organization, such as a computer lab at a school.
root directory
You can examine the contents of the root directory with the ls -F / command.
$ ls -F /
Applications/ Volumes/ mach_kernel.ctfsys
Desktop DB bin/ net/
Desktop DF cores/ private/
Developer/ dev/ sbin/
Library/ etc@ tmp@
Network/ home/ usr/
System/ mach-Kernal var@
Users/
The above example is for Mac OS X 10.5.8 Leopard.
On many systems you will find a file called unix This is the main UNIX operating system kernel.
On some systems you will find root.home. This is a temporary file created when running Netscape as root. This would be an example of an application-specific file.
some important directories
The following is a brief description of some of the major directories. Not all systems will have all of these directories. This list has additional information beyond the similar list in file system basics.
/ The root directory of the entire file system.
/bin A collection of binary files, better known as programs. Many of the standard system commands are stored here.
/boot or /kernel The files needed to boot or start your computer.
/dev The devices connected to your computer (remember, everything, even hardware devices, is treated as a file in UNIX or Linux). Examples are the keyboard, disks, and printers.
/etc System configuration files, startup procedures, and shutdown procedures.
/home or /users The home directories for each user.
/lib or /Library Library files used by executable programs.
/net Other networked systems (again, treated as files).
/opt Third party software. In older systems this might be /usr/local
/private On Mac OS X, this is the location of the UNIX files. It is normally kept hidden from all users in Finder, but is visible in your terminal emulator and shell. Mac OS X has links to the major UNIX directories at the root level so that UNIX and Linux tools can find their files in the standard locations.
/proc Information about processes and devices.
/sbin System binaries (that is, system programs).
/tmp Space for temporary files. Required by all forms of UNIX. This directory is normally erased on bootup.
/usr User binaries (programs), libraries, manuals, and docs. Common subdirectories include online help (/usr/share), header files for application development (/usr/include), and system configuartion files related to low-level hardware (such as /usr/cpu and /usr/gfx).
It is rare that a system administrator would even look at the low level hardware directories, such as /usr/cpu. The system automatically manages these directories and their contents. It is unwise for a system administrator to modify these directories and their contents. Messing with these will almost certainly bring the system down and may require reinstalling the entire system.
/var Variable files. Some common subdirectories include X Windows files (/var/X11), system services files, applications related files (/var/netscape), system administration files and data (/var/adm or /var/spool), a second temporary directory (/var/tmp) that is not normally erased on bootup.
Swap Virtual memory on a hard drive. Allows the memory manager to swap some data and program segments to hard drive to expand the amount of memory available beyond the limits of physical memory.
For a more advanced and complete listing, see major directories.
FAQs
You can find a FAQ (Frequently Asked Questions) file for all UNIX variants. Find the appropriate FAQ for your version of UNIX or Linux and look up the details for your system.
/etc
A key directory for new system administrators to learn is the /etc directory. The /etc directory contains key system administration files.
Because the /etc files change system behavior and properties, a system administrator spends a lot of time modifying and updating these files.
A new system administrator can learn a lot about UNIX by studying the files in the /etc directory. Do not change these files until you have figured out what you are doing. This is not the place for random experimentation.
A few key /etc files a system administrator should know.
/etc/sys_id is the name of the system. It may contain the full domain. Not used on Mac OS X.
/etc/hosts is the summary of the full host names. A system administrator will add to this standard file.
/etc/fstab is a list of file systems to mount on bootup. Mac OS X has /etc/fstab.hd.
/etc/passwd is the password file. It includes a number of items of basic information on user accounts.
/etc/group is the group file. It contains details of all user groups.
/var
Another important directory for system administrators to know is the /var directory, which contains configuration files for many system services.
For example, the /var/named file configures Domain Name Service and the /var/yp file configures Network Information Service.
where to find answers
Surprisingly, there won’t be a grand tour of the UNIX file system here.
A UNIX system typically has thousands of files. Maybe tens of thousands of files. A system administrator doesn’t normally need to know what these files are or where they are located.
A system administrator should know where to find relevant information when a problem occurs.
Many system administrators keep a handy notebook with information on where to find answers to various problems. It is far more useful to know where to find correct answers than to know try to memorize all answers.
And don’t forget popular search engines as a source for answers. There is very little chance that you are the first system administrator in the world to encounter a particular problem. A quick internet search should reveal many others asking for help on the same problem, along with answers.
hidden files and directories
Any file or directory that starts with the period or dot ( . ) character is considered hidden.
In MS-DOS (and Windows) and the original Macintosh, files and directories are hidden by setting a special attribute.
Mac OS X has a hybrid. When using the command line shell, Mac OS X acts exactly like any other version of UNIX. But when using the Finder, Mac OS X also recognizes the invisible bit. This is how the entire UNIX operating system is kept out of the hands of the typical Mac OS X user.
Access permissions are separate from invisibility. In MS-DOS, a hidden file can not be written to. In UNIX, you can freely read and write and otherwise modify a hidden file.
In UNIX, file access is controlled by access permissions.
As a reminder from the ls subchapter, the -a option will give a list of all files, including hidden files.
$ ls -a
Each user has a few important hidden files that configure their basic working environment when they login. These include:
- .cshrc
- .login
- .profile
comments, suggestions, corrections, criticisms
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
†UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.