You are on page 1of 15

Directory File System in Linux and Error Codes

Linux Directory Structure (File System Structure)


Structure could vary from distro to distro. Most distributions have same general structure of the linux base dir system.

/ The root directory This is where the Linux system begins. Only root user has write privilege under this directory. Every single file and directory starts from the root directory. Need root permissions to write to this folder, in fact, u need root permissions to access any folder on the system different from your home directory. Successful People in life seem to like LINUX

Page 1 of 15

Directory File System in Linux and Error Codes / root The super users (roots) home directory. Dont confuse this with the root dir (/) of a Linux system. This is distinct from /, which is the system root directory. /boot Contains boot loader related files they are the kernel, grub , system.map config files etc. This is the place where Linux keeps information that it needs when booting up. /home where users keep their personal files. Every user has their own directory under /home, and usually each user only has write access to their own home folder. home folder contains the users data files and user-specific configuration files. This file system differs from host to host. Once the user is logged in ; user is placed in his home directory. LINUX creates directories for all users directory. e:g : /home/rose. /dev Contains all device files these include terminal devices, usb, or any device attached to the system. Dev directory contains the essential system files and drivers. All the devices that a Linux kernel can understand are located under /dev /dev/fd0 is your floppy drive, /dev/cdrom is your CD drive, / tmp Programs can write their temporary files here. A temporary file system which hold temporary files which are cleared a t system reboot. There is also a Successful People in life seem to like LINUX
Page 2 of 15

Directory File System in Linux and Error Codes

/var/tmp directory which holds temporary files too. The only difference between the two is that /var/tmp directory holds files that are protected at system reboot. In other words, /var/tmp files are not flushed upon a reboot. /proc This file system does not exist on the hard disk. It is created by the kernel in its memory to provide information about the system. This special directory Well, actually /proc is just a virtual directory does not contain files. In fact, this directory does not really exist at all. It is entirely virtual. It contains information about system process. There s a bunch of numbered entries that correspond to all processes running on the system also named entries that permit access to the current system configuration. Many of these entries can be viewed. cd /proc/cpuinfo. This entry tells what the kernel thinks of the CPU. Proc is a pseudo filesystem contains information about running process. eg: /proc/{pid} It contains info about the process with that particular pid. eg: /proc/pid , /proc/uptime /cpuinfo (information about cpu), /devices (information about devices installed), /filesystem (file systems configured), /net (information about network protocols), /mem (memory usage) Few of the Directories include /1 (directory with information about Proc process num 1, where 1 is the identification number). Successful People in life seem to like LINUX
Page 3 of 15

Directory File System in Linux and Error Codes /mnt Mount point for temporary file systems . Directory is used for mount points. The different physical storage devices (like the hard disk drives, floppies , CDROMs) must be attached to some directory in the file system before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called the mount point. /usr filesystem This file system is generally large as it contains the executable files to be shared amongst different machines. Files are usually the ones installed while installing Linux. This makes it possible to update the system from a new version of the distribution, or even a completely new distribution, without having to install all programs again. Sub directories include /bin, /include, /lib, /local (for local executables) /bin , /usr/bin ( User Binaries ) The /usr directory contains applications and files used by users. while /usr/bin contains applications for the system's users . Contains binary executables. These two directories contain most of the

programs for the system. The /bin directory contains the most important programs that the system needs to operate, such as the shells, ls, grep, and other essential things. usr/bin is one of the major sub directories of the /usr directory. It contains most of the executable files (i.e. ready-to-run programs) that are not needed for booting (i.e., starting). There are more than 1900 executable files in /usr/bin on a typical system. Check following commands . The are awk ,cal ,find , finger ,free , stat, tail ,top etc .. Successful People in life seem to like LINUX
Page 4 of 15

Directory File System in Linux and Error Codes /sbin, /usr/sbin /sbin System binaries (Utilities used for system administration). sbin directories contain programs for system administration, mostly for use by the superuser. Stored in /sbin, /usr/sbin, and /usr/local/sbin. /sbin contains binaries essential for booting, restoring, recovering the system. eg: reboot, iptables, fdisk, ifconfig, swapon /lib /usr/lib contains libraries for /usr/bin and /usr/sbin. Shared libraries for i.e program libraries.

programs that are dynamically linked. Library files

Libraries are collections of frequently used program routines. that supports the binaries located under /bin and /sbin. Library filenames are either ld* or lib*.so.* ( ld-2.11.1.so, libncurses.so.5.7) /usr /usr is the largest directory on a Linux system. It contains user installed applications (applications) ie. contains Sub- directories , for many programs like their source codes, and pictures, docs etc .. /usr/src /usr/local /usr/share/dic) /usr/share/doc /usr/share/X11 (/src) linux' sub-directory holds the Linux kernel sources, header-files and documentation. Source code files. If we install the kernel source code

package, will find the entire Linux kernel source code here. Successful People in life seem to like LINUX

Page 5 of 15

Directory File System in Linux and Error Codes

(/local) where we install apps and other files for use on the local machine. When programs to install on linux system, should be installed in one of the /usr/local directories. /usr/local and its subdirectories are used for the installation of software and other files for use on the local machine. (/X11) - Support files for the X Windows system. (/dic)- Dictionaries for the spelling checker - (look and ispell ). (/doc) - Various documentation files /var Var stands for variable files . It contains various system files i.e. files that

change as the system is running. Variable content like logs, spool files for printers, crontab,at jobs, mail, running process, lock files etc . This file system is specific to local systems , because the data keeps changing. Content of the files that are expected to grow can be found under this dir This includes system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp); (var/log) Directory that contains log files for different applications. . These are updated as the system runs. Should view the files in this directory from time to time, to monitor the health of your system. /var/run/ /var/lib /var/mail: Successful People in life seem to like LINUX

Page 6 of 15

Directory File System in Linux and Error Codes /var/tmp /var/cache/ /var/spool (/run) contains data describing since it was booted. (/lib) -Contains info relating to the current state of applications. (/cache) contanins tmp files preserved between system reboots. Storage area for cached data for applications. (/mail) -Incoming and outgoing mail. (tmp )- contanins tmp files preserved between system reboots. (/spool) - contains data i.e waiting for some kind of peocessing . This directory is used to hold files that are queued for some process, such as mail messages and print jobs. When a user's mail first arrives on the local system (assuming you have local mail), the messages are first stored in /var/spool/mail. /etc etc stands for "etcetera" ! This directory contains the configuration files for the system. All of the files in /etc should be text files. Most of these files are text files and can be edited by hand. Lots of user installed applications store the configuration files here i.e. A lot of files here (passwd , fstab , hosts , etc) .. /etc/fstab /etc/hosts /etc/passwd /etc/inittab.d (/hosts) -lists the network host names and IP addresses that known to the system. (/passwd) -The passwd file contains the essential info for each user. here that users are defined. Successful People in life seem to like LINUX

Page 7 of 15

Directory File System in Linux and Error Codes

(/fstab) - This file defines your disk drives like floppies, cdroms, even network shares and also descriptive information about the various file systems and their mount points. (inittab.d) A text file that describes what processes are started at system bootup andduring normal operation. This also contains startup and shutdown shell scripts used to start/stop individual programs. Linux Performance Commands : Managing performance on Linux systems is a lot easier with a few commands. Listed below are some of commands including top, vmstat, iostat, free, and sar. They may help in resolving performance issues quickly and easily. TOP The top command shows not only the current tasks being serviced by the kernel but also some broad statistical data about the state of a host. By default, it automatically updates this data every five seconds (this update period is configurable). The top command tells several things, for example: the current uptime, system load, number of processes and memory usage. In addition, the command shows those processes using the most CPU (including a variety of pieces of information about each process such as the running user and the command being executed). VMSTAT The vmstat command gives a snapshot of current CPU, IO, processes and memory usage. Similar to the top command, it dynamically updates and can be executed with this command: $ vmstat 10 Successful People in life seem to like LINUX

Page 8 of 15

Directory File System in Linux and Error Codes IOSTAT The iostat command (provided via the sysstat package on Ubuntu and Red Hat/Fedora) offers three reports. These are CPU utilization, device utilization, and network file system utilization. In case of running the command without options,it will display all three reports. The individual reports can be specified with the -c, -d and -h switches respectively. FREE The free command shows memory statistics for both main memory and swap. A total memory amount can be displayed by specifying the -t switch. The amounts in bytes can also be displayed by specifying the -b switch and megabytes using the -m switch (it displays in kilobytes by default). Free can also be run continuously using the -s switch with a delay specified in seconds: $ free -s 5 SAR Use the sar command line tool to collect, view and record performance data. This command is considerably more sophisticated than all the commands discussed above. It can collect and display data over longer periods. Error Codes in Linux To understand the nature of the error these codes need to be interpreted. They are recorded in /usr/include/asm/errno.h Command to find status of last command Execution $ echo $? # echo $? Successful People in life seem to like LINUX
Page 9 of 15

Directory File System in Linux and Error Codes


Number C define Message

0 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 EPERM ENOENT ESRCH EINTR EIO ENXIO E2BIG ENOEXEC EBADF ECHILD EAGAIN EWOULDBLOCK ENOMEM EACCES EFAULT ENOTBLK EBUSY EEXIST EXDEV ENODEV ENOTDIR EISDIR EINVAL ENFILE EMFILE ENOTTY ETXTBSY EFBIG ENOSPC ESPIPE

Action Success Operation not permitted No such file or directory No such process Interrupted system call Input/output error Device not configured Argument list too long Exec format error Bad file descriptor No child processes Resource temporarily unavailable Resource temporarily unavailable Cannot allocate memory Permission denied Bad address Block device required Device or resource busy File exists Invalid cross-device link No such device Not a directory Is a directory Invalid argument Too many open files in system Too many open files Inappropriate ioctl for device Text file busy File too large No space left on device Illegal seek
Page 10 of 15

Successful People in life seem to like LINUX

Directory File System in Linux and Error Codes 30 31 32 33 34 35 35 36 37 38 39 40 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 60 EROFS EMLINK EPIPE EDOM ERANGE EDEADLK EDEADLOCK ENAMETOOLONG ENOLCK ENOSYS ENOTEMPTY ELOOP EWOULDBLOCK ENOMSG EIDRM ECHRNG EL2NSYNC EL3HLT EL3RST ELNRNG EUNATCH ENOCSI EL2HLT EBADE EBADR EXFULL ENOANO EBADRQC EBADSLT EDEADLOCK EBFONT ENOSTR Read-only file system Too many links Broken pipe Numerical argument out of domain Numerical result out of range Resource deadlock avoided Resource deadlock avoided File name too long No locks available Function not implemented Directory not empty Too many levels of symbolic links (same as EAGAIN) No message of desired type Identifier removed Channel number out of range Level 2 not synchronized Level 3 halted Level 3 reset Link number out of range Protocol driver not attached No CSI structure available Level 2 halted Invalid exchange Invalid request descriptor Exchange full No anode Invalid request code Invalid slot (same as EDEADLK) Bad font file format Device not a stream

Successful People in life seem to like LINUX

Page 11 of 15

Directory File System in Linux and Error Codes 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 ENODATA ETIME ENOSR ENONET ENOPKG EREMOTE ENOLINK EADV ESRMNT ECOMM EPROTO EMULTIHOP EDOTDOT EBADMSG EOVERFLOW ENOTUNIQ EBADFD EREMCHG ELIBACC ELIBBAD ELIBSCN ELIBMAX ELIBEXEC EILSEQ ERESTART ESTRPIPE EUSERS ENOTSOCK EDESTADDRREQ EMSGSIZE EPROTOTYPE ENOPROTOOPT No data available Timer expired Out of streams resources Machine is not on the network Package not installed Object is remote Link has been severed Advertise error Srmount error Communication error on send Protocol error Multihop attempted RFS specific error Bad message Value too large for defined data type Name not unique on network File descriptor in bad state Remote address changed Can not access a needed shared library Accessing a corrupted shared library .lib section in a.out corrupted Attempting to link in too many shared libraries Cannot exec a shared library directly Invalid or incomplete or multibyte or wide char Interrupted system call should be restarted Streams pipe error Too many users Socket operation on non-socket Destination address required Message too long Protocol wrong type for socket Protocol not available

Successful People in life seem to like LINUX

Page 12 of 15

Directory File System in Linux and Error Codes 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 EPROTONOSUPPORT Protocol not supported ESOCKTNOSUPPORT Socket type not supported EOPNOTSUPP EPFNOSUPPORT EAFNOSUPPORT EADDRINUSE EADDRNOTAVAIL ENETDOWN ENETUNREACH ENETRESET ECONNABORTED ECONNRESET ENOBUFS EISCONN ENOTCONN ESHUTDOWN ETOOMANYREFS ETIMEDOUT ECONNREFUSED EHOSTDOWN EHOSTUNREACH EALREADY EINPROGRESS ESTALE EUCLEAN ENOTNAM ENAVAIL EISNAM EREMOTEIO EDQUOT ENOMEDIUM EMEDIUMTYPE Operation not supported Protocol family not supported Address family not supported by protocol Address already in use Cannot assign requested address Network is down Network is unreachable Network dropped connection on reset Software caused connection abort Connection reset by peer No buffer space available Transport endpoint is already connected Transport endpoint is not connected Cant send after transport endpoint shutdown Too many references: cannot splice Connection timed out Connection refused Host is down No route to host Operation already in progress Operation now in progress Stale NFS file handle Structure needs cleaning Not a XENIX named type file No XENIX semaphores available Is a named type file Remote I/O error Disk quota exceeded No medium found Wrong medium type

Successful People in life seem to like LINUX

Page 13 of 15

Directory File System in Linux and Error Codes LINUX File System: Linux operating system everything is a file. To manage all these files Linux have a tree like directory structure. File system may little vary from distro to disro.

: Root directory, which contains all other directories.

/dev : Contains device files. /etc : Contains configuration files. /root : Root users home directory. /sbin : Contains system binaries. /tmp : Contains temporary files. /var : Contains variable data files. /opt : Contains add-on/optional packages. /home : Contains users home directories. /media : Mount point for removable media. /mnt : Mount point for temporary mounted file-system. Successful People in life seem to like LINUX
Page 14 of 15

Directory File System in Linux and Error Codes /lib : Essential shared libraries and kernel modules. /proc : Contains kernel and process information /bin : Contains commands that may be used by both system administrator and by users, but which are require when no other file-systems are mounted. /boot : This directory contains everything which required for the boot process, like kernel, GRUB, Initrd, etc. In Linux operating system there is a pre-defined location to store different files. So above mentioned file system is common for Red hat distributions.

Successful People in life seem to like LINUX

Page 15 of 15

You might also like