Introduction To Unix Operating System Accessing Files and Directories
Introduction To Unix Operating System Accessing Files and Directories
[1]. The Filesystem Hierarchy Standard (FHS) defines the main directories and their contents in Linux operating systems. Filesystem Hierarchy Standard This standard consists of a set of requirements and guidelines for file and directory placement under UNIXlike operating systems. The guidelines are intended to support interoperability of applications, system administration tools, development tools, and scripts as well as greater uniformity of documentation for these systems. "Static" files include binaries, libraries, documentation files and other files that do not change without system administrator intervention. "Variable" files are files that are not static. The Single UNIX Specification (SUS) is the collective name of a family of standards for computer operating systems to qualify for the name
"Unix". The SUS is developed and maintained by the Austin Group, based on earlier work by the IEEE and The Open Group. SUSv3 totals some 3700 pages, which are thematically divided into four main parts: Base Definitions (XBD) - a list of definitions and conventions used in the specifications and a list of C header files which must be provided by compliant systems. 84 header files in total are provided. Shell and Utilities (XCU) - a list of utilities and a description of the shell, sh. 160 utilities in total are specified. System Interfaces (XSH) - contains the specification of various functions which are implemented as system calls or library functions. 1123 system interfaces in total are specified. Rationale (XRAT) - the explanation behind the standard. The standard user command line and scripting interface is the POSIX shell, an extension of the Bourne Shell based on an early version of the Korn Shell. Other user-level programs, services and utilities include awk, echo, ed, vi, and hundreds of others. Required program-level services include basic I/O (file, terminal, and network) services. A test suite accompanies the standard. It is called PCTS or the POSIX Certification Test Suite. Additionally, SUS includes CURSES (XCURSES) specification, which specifies 372 functions and 3 header files. All in all, SUSv3 specifies 1742 interfaces. Note that a system need not include source code derived in any way from AT&T Unix to meet the specification. For instance, IBM OS/390, now z/OS, qualifies as a "Unix" despite having no code in common.[citation needed] There are two official marks for conforming systems UNIX 98 - the mark for systems conforming to version 2 of the SUS (partial compliance) UNIX 03 - the mark for systems conforming to version 3 of the SUS (full compliance)
misc proc scratch sys users2 usr root selinux tmp users3 var
Special characters, such as asterisks (*), ampersands (&), pipes ( | ), quotes ( ), and dollar signs ( $ ) should not be used. These particular characters hold special meaning to the shell. Spaces should not be used in directory or file names. File and directory names, as a rule, do not contain extensions. However, if desired, extensions can be used.
cd (Change Directory)
At any given time, you are located in a current working directory within the directory tree. When you initially log in to the system, the current directory is set to your home directory. You can change your current working directory at any time by using the cd command if you have rights to access the directory you want to change to. You can give the target directory path in absolute or relative form. To directory directly under working directory you don't need to use path. You can always return to your own home directory by typing the cd command without an argument.
$ ls -a
3.3.2 Displaying File Types
Use ls -F to display file types. File Type Symbol
/ * @
$ ls -F
Desktop/ Documents/ Ubuntu-App@ firstfile Music/ Public/ Templates/ Note - A symbolic link is a special type of file that points to another file or directory. A symbolic link file contains the path name of the file or directory to which it points.(later more)
This is also known as a recursive listing. When you do this from /, it shows all the unhidden files in the whole file system recursively.
$ ls R path_name
3.3.4 Order Files Based on Last Modified Time
To display a listing sorted by the file's last modification time, with the latest modified file appearing first in the list, execute the following:
$ ls -lt
To display a listing showing the latest file modification time in reverse order, execute the following:
4. Shell Metacharacters
Shell metacharacters are specific characters, generally symbols, used to represent a special meaning to the shell. Some examples of shell metacharacters include: ~ - + * ? [] ~tilde, - dash,
4.1.2 Using ~+ and ~The tilde and plus string refers to the current working directory. The tilde and dash string refers to the previous working directory.
Note - You should not use these metacharacters when creating file and directory names. These particular characters hold special meaning to the shell.
file filename(s)
The output from the file command is most often one of the following:
- Text - Examples include ASCII text, English text, commands text, and executable shell scripts. - Data - Data files are those that are created by an application. - Executable or binary - This file type indicates that the file is a command or program.
mv file1 file2 Renames file1 to file2 mv directoryl directory2 If directory2 doesn't exist, directoryl will be renamed to directorv2. If directory2 exists, directory1 will be moved to a subdirectory under directory2. mv directoryl/filel directory2/file2 Moves filel from directory1 to directory2 renaming it to file2
mv directoryl/filel file2 Moves filel from directory1 to working directory named file2. mv directoryl/.filel directory2 Moves .file1 from directory1 to directory2 retaining the same name
1 0
Hello::Hello(void) /*! @brief Empty constructor for class Hello. @return None **/ { //! Write implementation if needed } Hello::~Hello(void) /*! @brief Empty destructor for class Hello. @return None **/ { //! Write implementation if needed } void Hello::print(void) /*! @brief Prints out the welcome message. @param None @return None **/ { std::cout << "Hello, world!\n"; }
8. nano engine.cpp #include hello.hpp int main () { Hello Hello1; Hello1.print(); return 0; } 9. ls engine.cpp hello.cpp hello.hpp 10. g++ -Wall engine.cpp hello.cpp -o hello 11. ls engine.cpp hello hello.cpp hello.hpp 12. ./hello Hello, world! 13. exit
7. References
[1] http://www.december.com/unix/tutor/filesystem.html (8.10.2010) [2] http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/ (8.10.2010)
1 1
8. Links
Bash alias man page http://ss64.com/bash/alias.html Introduction to GCC http://www.network-theory.co.uk/docs/gccintro/gccintro_54.html