Pages

Sunday, February 12, 2012

Linux Beginner Part-3 (Directory Layout)


The Linux Directory Layout

/            The nameless base of the filesystem. All other directories, files, drives, and devices are attached to this root. Commonly (but incorrectly) referred to as the “slash” or “/” directory. The “/” is just a directory separator, not a directory itself.

/bin Essential command binaries (programs) are stored here (bash, ls, mount, tar, etc.)

/boot Static files of the boot loader.

/dev Device files. In Linux, hardware devices are acceessd just like other files, and they are kept under this directory.

/etc Host-specific system configuration files.

/home Location of users' personal home directories (e.g. /home/susan).

/lib Essential shared libraries and kernel modules.

/proc Process information pseudo-filesystem.  An interface to kernel data structures.

/root The root (superuser) home directory.

/sbin Essential system binaries (fdisk, fsck, init, etc).

/tmp Temporary files.  All users have permission to place temporary files here.

/usr The base directory for most shareable, read-only data (programs, libraries, documentation, and much more).

/usr/bin Most user programs are kept here (cc, find, du, etc.).

/usr/lib Libraries for most binary programs.

/usr/local “Locally” installed files. This directory only really matters in environments where files are stored on the network. Locally-installed files go in /usr/local/bin, /usr/local/lib, etc.). Also often used for software packages installed from source, or software not officially shipped with the distribution.

/usr/sbin Non-vital system binaries (lpd, useradd, etc.)

/usr/share Architecture-independent data (icons, backgrounds, documentation, terminfo, man pages, etc.).

/usr/src Program source code.  E.g. The Linux Kernel, source RPMs, etc.

/var Variable data: mail and printer spools, log files, lock files, etc.

Linux Beginner Part-2 (Special Characters)


Special Characters
Before we continue to learn about Linux shell commands, it is important to know that there are
many symbols and characters that the shell interprets in special ways.


Character Description

/     Directory separator, used to separate a string of directory names.
Example: /usr/src/linux

.    Current directory.  Can also “hide” files when it is the first character in a filename.

..   Parent directory

~   User's home directory

*   Represents 0 or more characters in a filename, or by itself, all files in a directory.
Example: pic*2002 can represent the files pic2002, picJanuary2002, 
picFeb292002, etc.

?   Represents a single character in a filename.
Example: hello?.txt can represent hello1.txt, helloz.txt, but not 
hello22.txt 

|   “Pipe”.  Redirect the output of one command into another command.
Example: ls | more 

>   Redirect output of a command into a new file.  If the file already exists, over-write it.
Example: ls > myfiles.txt 

>>  Redirect the output of a command onto the end of an existing file.
Example: echo “Mary 555-1234” >> phonenumbers.txt 

<   Redirect a file as input to a program.
Example: more < phonenumbers.txt 

;   Command separator.  Allows you to execute multiple commands on a single line.
Example: cd /var/log ; less messages

&&  Command separator as above, but only runs the second command if the first one
finished without errors.
Example: cd /var/logs && less messages 


&   Execute a command in the background, and immediately get your shell back.
Example: find / -name core > /tmp/corefiles.txt & 

Linux Beginner Part -1 (Shell)


What is a command shell?
Answer:
A program that interprets commands
Allows a user to execute commands by typing them manually at a terminal, or automatically in programs called shell scripts.




What is BASH?
Answer: 
Bourne Again SHell
A shell written as a free replacement to the standard Bourne Shell (/bin/sh).
Originally written by Steve Bourne for UNIX systems.
All of the features of the original Bourne Shell, plus additions that make it easier to program with and use from the command line.
Since it is Free Software, it has been adopted as the default shell on most Linux systems.