1.42k likes | 1.88k Views
LINUX. Linux is a generic term referring to the family of Unix-like computer operating systems that use the Linux kernel.
E N D
LINUX Linux is a generic term referring to the family of Unix-like computer operating systems that use the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed, both commercially and non-commercially, by anyone under licenses such as the GNU General Public License.
Linux can be installed on a wide variety of computer hardware , ranging from embedded devices such as mobile phones, smartphones and wristwatches to mainframes and supercomputers. • Linux is predominantly known for its use in servers; in 2007 Linux's overall share of the server market was estimated at 12.7%, while a 2008 estimate suggested that 60% of all web servers ran Linux. • Most desktop computers run either Mac OS X or Microsoft Windows, with Linux having only 1–2% of the desktop market. • However, desktop use of Linux has become increasingly popular in recent years, partly owing to the popular Mandriva Linux, Fedora, Debian or Ubuntu distributions and the emergence of netbooks and smartbooks.
Linux installation • To install Red Hat, you will need to download the ISO images (CD Images) of the installation CD-ROMs from http://fedora.redhat.com • Download the i386 images for 32 Intel Processors, PPC images for for Apple Macintosh and x86_64 for for 64 bit AMD Processors • Burn the iso CD images on CDs and use these CDs as Installation CDs (typically 4)
Linux file structure In the Linux file structure files are grouped according to purpose. Ex: commands, data files, documentation. Parts of a Unix directory tree are listed below. All directories are grouped under the root entry "/". That part of the directory tree is left out of the below diagram. See the FSSTND standard (Filesystem standard) * root - The home directory for the root user * home - Contains the user's home directories along with directories for services o ftp o HTTP o samba o george
bin -Commands needed during bootup that might be needed by normal users • sbin- Like bin but commands are not intended for normal users. Commands run by LINUX. • proc-This filesystem is not on a disk. It is a virtual filesystem that exists in the kernels imagination which is memory. A directory with info about process number 1. Each process has a directory below proc. • usr- Contains all commands, libraries, man pages, games and static files for normal operation. • bin - Almost all user commands. some commands are in /bin or /usr/local/bin. • sbin - System admin commands not needed on the root filesystem. e.g., most server programs. • include - Header files for the C programming language. Should be below /user/lib for consistency. • lib - Unchanging data files for programs and subsystems
local - The place for locally installed software and other files. • man - Manual pages • info - Info documents • doc - Documentation • tmp • X11R6 - The X windows system files. There is a directory similar to usr below this directory. • X386 - Like X11R6 but for X11 release 5 • boot - Files used by the bootstrap loader, LILO. Kernel images are often kept here. • lib - Shared libraries needed by the programs on the root filesystem • modules - Loadable kernel modules, especially those needed to boot the system after disasters. • dev - Device files • etc - Configuration files specific to the machine.
skel - When a home directory is created it is initialized with files from this directory • sysconfig - Files that configure the linux system for devices. • var - Contains files that change for mail, news, printers log files, man pages, temp files • file • lib - Files that change while the system is running normally • local - Variable data for programs installed in /usr/local. • lock - Lock files. Used by a program to indicate it is using a particular device or file
log- Log files from programs such as login and syslog which logs all logins and logouts. run - Files that contain information about the system that is valid until the system is next booted spool- Directories for mail, printer spools, news and other spooled work. tmp - Temporary files that are large or need to exist for longer than they should in /tmp. catman - A cache for man pages that are formatted on demand mnt - Mount points for temporary mounts by the system administrator. Tmp - Temporary files. Programs running after bootup should use /var/tmp.
Basic commands in linux 1.Cat: Sends file contents to standard output. This is a way to list the contents of short files to the screen. Example: cat .bashrc Description: It works well with piping. Sends the contents of the ".bashrc" file to the screen.
2.Cd: Change directory Example: cd /home Description: Change the current working directory to /home. The '/' indicates relative to root, and no matter what directory you are in when you execute this command, the directory will be changed to "/home". Example: cd httpd Description: Change the current working directory to httpd, relative to the current location which is "/home". The full path of the new working directory is "/home/httpd".
3. Cp : Copy files Example: cp myfile yourfile Description: Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists. Example: cp -dpr srcdir destdir Description: Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.
4.Dd : Disk duplicate Example: dd if=/dev/hdb1 of=/backup/ Description: The man page says this command is to "Convert and copy a file", but although used by more advanced users, it can be a very handy command. The "if" means input file, "of" means output file. 5.Df: Show the amount of disk space used on each mounted filesystem.
6. ls:List files Example: ls Description: List files in the current working directory except those starting with . and only show the file name. Example : ls -al Description: List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp
7.mv:Move or rename files Example: mv -i myfile yourfile Description: Move the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile". Example: mv -i /data/myfile . Description: Move the file from "myfile" from the directory "/data" to the current working directory.
8. pwd:Show the name of the current working directory Example: more /etc/profile Description: Lists the contents of the "/etc/profile" file to the screen one page at a time.
Apache The Apache is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million web site milestone. Apache was the first viable alternative to the Netscape Communications Corporation web server (currently known as Sun Java System Web Server), and has since evolved to rival other Unix-based web servers in terms of functionality and performance. The majority of web servers using Apache run a Unix-like operating system.[citation needed]
Configuration ServerRoot: The top of the directory tree under which the server's configuration, error, and log files are kept. Example: ServerRoot "/opt/lampp" Listen: Allows you to bind Apache to specific IP addresses and/or ports, instead of the default. See also the <VirtualHost>directive. Example: Listen 12.34.56.78:80 Listen 80
ServerAdmin: Your address, where problems with the server should be e-mailed. This address appears on some server-generated pages, such as error documents. e.g. admin@your-domain.com Example: ServerAdmin you@example.com
DocumentRoot: The directory out of which you will serve your documents. By default, all requests are taken from this directory, but symbolic links and aliases may be used to point to other locations. Example: DocumentRoot "/opt/lampp/htdocs"
User/Group: The name (or #number) of the user/group to run httpd as. It is usually good practice to create a dedicated user and group for running httpd, as with most system services. DirectoryIndex: sets the file that Apache will serve if a directory is requested. <IfModule dir_module> #DirectoryIndex index.html # XAMPP DirectoryIndex index.html index.html.var index.php index.php3 index.php4 </IfModule>
ErrorLog: The location of the error log file. If you do not specify an ErrorLog directive within a <VirtualHost> container, error messages relating to that virtual host will be logged here. If you *do* define an error logfile for a <VirtualHost> container, that host's errors will be logged there and not here. Example: ErrorLog logs/error_log LogLevel: Control the number of messages logged to the error_log. Possible values include: debug, info, notice, warn, error, crit, alert, emerg. Example: LogLevel warn
Installing Apache Three methods of installing Apache under Linux. The three methods are: •Binary installation •Using an RPM (Red Hat Package Manager) – recommended for people running Red Hat Linux •Building from source
Download the Software You can download Apache from the Apache Software Foundation web site located at http://www.apache.org, in source and binary forms. While your downloading Apache, you may want to browse over the documentation. What you need: To install Apache, you will need the following things: 1.A computer running Linux 2.Root access on this computer 3.For binary and source installations, the tar and gunzip Unix utilities
Binary Installation: A binary is pre-configured, which means someone else has gone to the trouble of configuring and building the software for you. There are, however, a few things you should keep in mind: •Binaries are compiled for a particular operating system. In other words, you must use a binary built specifically for FreeBSD on your FreeBSD machine and a Linux binary on your Linux machine. You need to be sure to grab the correct binary; if you don't see a binary for your particular operating system, you must choose a different method of installation. •Apache binaries are usually a version or two behind the current source distribution. This means you don't reap the benefits of the latest bug fixes and feature enhancements.
•Because binaries are pre-configured, you don't have much opportunity to alter the way the software works. If you're a newcomer, you may not care about this loss of flexibility.Fortunately most Apache binaries include a full source distribution, providing you with the best of both worlds -- play now, learn later. • Point your browser at http://www.apache.org/dist/httpd/binaries/ and download the binary for your operating system (in our case, Linux). You'll most likely be presented with a directory containing multiple versions of Apache in various compressed forms.
RPM Installation • Those of you running Red Hat Linux may want to take advantage of Red Hat's RPM ("RedHat Package Manager") system. • Almost identical to a binary, an RPM is further customized to play nicely with other RPMs and provide a consistent interface to installing, updating, and removingbinaries. • For Linux newcomers or when installing a small standard component, RPMs are simple and reliable. • Bear in mind that an Apache RPM may already be installed on your system depending on how Linux was originally installed on your computer. • To find out, at the shell prompt, type: rpm -qa | grep apache
Basic commands: User Commands : Commands useful for users of a hadoop cluster. archive: Creates a hadoop archive. More information can be found at Hadoop Archives. Usage: hadoop archive -archiveName NAME <src>* <dest>
distcp : Copy file or directories recursively. More information can be found at Hadoop DistCp Guide. Usage: hadoop distcp <srcurl> <desturl> fs: Usage: hadoop fs [GENERIC_OPTIONS] [COMMAND_OPTIONS] Runs a generic filesystem user client. The various COMMAND_OPTIONS can be found at Hadoop FS Shell Guide.
jar Runs a jar file. Users can bundle their Map Reduce code in a jar file and execute it using this command. Usage: hadoop jar <jar> [mainClass] args... The streaming jobs are run via this command. Examples can be referred from Streaming examples Word count example is also run using jar command. It can be referred from Wordcount example fsck : Runs a HDFS filesystem checking utility. See Fsck for more info. Usage: hadoop fsck [GENERIC_OPTIONS] <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]
fsck :Runs a HDFS filesystem checking utility. Usage: hadoop fsck [GENERIC_OPTIONS] <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]
Starting Apache: • Let's take your new Apache installation out for a spin. • f you installed Apache using a binary or from scratch, as root, type: /usr/local/apache/bin/apachectl start • If you used an RPM, as root, type: /sbin/service httpd start • Point your browser at your brand new Web server, http://localhost/. If everything worked you should see the default home page.
Customize: • Apache uses some rather easy to understand text files for configuration. • On a Red Hat system,you'll find them in /etc/httpd/conf. • Quite a few Linux distributions place them in this same place,but if you can't find such a directory, do a search for "httpd.conf". • Once you find these, you've found the main config files. If you're new to Linux, and need help finding this file, here's how you can find it.
Now you should see where the file is located. When you move into the directory containing httpd.conf, you should see these three files: •httpd.conf – This has the settings for the overall configuration for the server. •access.conf – This file contains all the security settings for Apache. •srm.conf – This file contains the MIME definitions and default document names for files on the server.
Restarting Apache: • Whevever you make changes to the server configuration files, such as httpd.conf, they won't take effect until the server is restarted. • In Linux, Apache can be restarted depending on how you installed it. • If you installed Apache using a binary or from scratch, as root, type: /usr/local/apache/bin/apachectl start • If you used an RPM, as root, type: /sbin/service httpd start After being restarted the changes will have taken effect.
Mysql • MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases • The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. • MySQL is owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Sun Microsystems, a subsidiary of Oracle Corporation. • Members of the MySQL community have created several forks such as Drizzle and MariaDB. Both forks were in progress before the Oracle acquisition (Drizzle was announced 8 months before the Sun acquisition).
Installing MySQL on Linux It's simple to install MySQL on Linux using the RPM file. 1. Become the superuser if you are working in your account. (Type "su" and the prompt and give the root password). 2. Change to the directory that has the RPM download. 3. Type the following command at the prompt: rpm -ivh "mysql_file_name.rpm" Similarly you can also install the MySQL client and MySQL development RPMs if you've downloaded them. Alternatively, you can install the RPMs through GnoRPM (found under System). 4. Now we'll set a password for the root user. Issue the following at the prompt. mysqladmin -u root password mysqldata where mysqldata is the password for the root. (Change this to anything you like).
5. It is now time to test the programs. Typing the following at the prompt starts the mysql client program. • mysql -u root -p • The system asks for the the password. Type the root password (mysqldata). • If you don't get the prompt for password, it might be because MySQL Server is not running. To start the server, change to /etc/rc.d/init.d/ directory and issue the command ./mysql start (or mysql start depending on the value of the PATH variable on your system). Now invoke mysql client program. 6. Once MySQL client is running, you should get the mysql> prompt. Type the following at this prompt: show databases;
7. You should now get a display similar to: +----------------+ | Database | +----------------+ | mysql | | test | +----------------+ 2 rows in set (0.00 sec)
Configuration The MySQL server configuration normally started during installation process . MySQL server configuration wizard window The MySQL configuration wizard can be launched by clicking the MySQL server instance configuration wizard entry in the MySQL section of the window start menu. Another way to launch the configuration wizard, you can launch the MySQLInstanceConfig.exe file directly from bin directory of your MySQL installation. The MySQL server configuration wizard sets configuration variables values in my.ini file in the installation directory for the MySQL server. --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini"
Path "C:\Program Files\MySQL\MySQL Server 5.0" is installation directory of MySQL server . • The --defaults-file option instructs the MySQL server to read the specified file for configuration options when it starts. • The MySQL client and utilities like mysql and mysqldump command-line client are unable to locate the my.ini file locate in the server installation directory. • The MySQL use window server 2003, window server 2000 and window XP, MySQL server configuration wizard will configure MySQL to work as a windows services.
The MySQL Server configuration wizard on Linux: • If you want to install the MySQL server configuration on Linux then you have to run the mysqlsetup command. • For displaying MySQL server configuration wizard interface on a different machine, then you have to set the value of the DISPLAY variable on the command line. Example: shell> DISPLAY=remote:0.0 mysqlsetup
Basic commands: • To login (from unix shell) use -h only if needed. # [mysql dir]/bin/mysql -h hostname -u root -p • Create a database on the sql server. mysql> create database [databasename]; • List all databases on the sql server. mysql> show databases; • Switch to a database. mysql> use [db name];
To see all the tables in the db. mysql> show tables; • To see database's field formats. mysql> describe [table name]; • To delete a db. mysql> drop database [database name]; • To delete a table. mysql> drop table [table name];
Show all data in a table. mysql> SELECT * FROM [table name]; • Returns the columns and column information pertaining to the designated table. mysql> show columns from [table name]; • Show certain selected rows with the value "whatever". mysql> SELECT * FROM [table name] WHERE [field name] = "whatever"; • Show all records containing the name "Bob" AND the phone number '3444444'. mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
Show unique records. mysql> SELECT DISTINCT [column name] FROM [table name]; • Show selected records sorted in an ascending (asc) or descending (desc). mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC; • Return number of rows. mysql> SELECT COUNT(*) FROM [table name]; • Sum column. mysql> SELECT SUM(*) FROM [table name];