<ul>LINUX <li>Linux is a Unix-like operating system that was designed to provide personal computer users a free or very low-cost operating system comparable to traditional and usually more expensive Unix systems.
Linux has a reputation as a very efficient and fast-performing system.
Linux was developed by Linux Torvalds at the University of Helsinki in Finland. He started his work in 1991. The effort expanded with volunteers contributing code and documentation over the internet. It is currently developed under the GNU public license and is freely available in source and binary form. </li></ul>
LINUX COMMANDS <ul>1) pwd -“Print Working Directory”. Shows the current location in the directory tree. <ul>Eg:fp088@pbs088:~$ pwd </ul>/home/fp088 2) cd -“Change Directory”. When typed all by itself, it returns you to your home directory. <ul>Eg:fp088@pbs088:~$ cd </ul>fp088@pbs088:~$ 3) cd directory -Change into the specified directory name. <ul>Eg: cd /usr/src/linux </ul></ul>
4) ls -List all files in the current directory, in column format. Eg:fp088@pbs088:~$ ls Desktop Downloads Music Public Videos Documents examples.desktop Pictures Templates 5) clear -Clear the terminal screen 6) touch -Create empty file of zero byte Eg: fp088@pbs088:~$ touch aa 7) rm -Delete a file. Eg: fp088@pbs088:~$ rm aa 8) which -Shows the full path of shell commands found in our path Eg:fp088@pbs088:~$ which grep /bin/grep
9) locate -A quick way to search for files anywhere on the filesystem. 10) ps -Lists currently running process (programs). Eg: fp088@pbs088:~$ ps PID TTY TIME CMD 1797 pts/0 00:00:00 bash 2336 pts/0 00:00:00 ps 11) w -Show who is logged on and what they are doing. Eg: fp088@pbs088:~$ w 11:05:22 up 1:32, 2 users, load average: 0.01, 0.02, 0.01 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT fp088 tty7 :0 09:33 ? 3:58 0.19s gnome-session fp088 pts/0 :0.0 09:35 0.00s 0.27s 0.01s w 12) id -Print your user-id and group id's Eg:$ id uid=1000(fp088) gid=1000(fp088) groups=4(adm),20(dialout),24(cdrom),46(plugdev),104(lpadmin),115(admin),120(sambashare),1000(fp088)
13)df-Report filesystem disk space usage. Eg:~$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 73742752 2729736 67267064 4% / udev 997964 208 997756 1% /dev none 997964 1540 996424 1% /dev/shm none 997964 88 997876 1% /var/run none 997964 0 997964 0% /var/lock none 997964 0 997964 0% /lib/init/rw 14)echo-Display text on the screen. Eg:echo "hello World" hello World 15)date-date to set your server's date and time 16)finger-Use finger to see who's on the system Eg:~$ finger Login Name Tty Idle Login Time Office Office Phone fp088 fp088 tty7 May 20 09:33 (:0) fp088 fp088 pts/0 May 20 09:35 (:0.0)
17)cal-displays a calendar Eg:$ cal May 2010 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 18)ls -al List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp 19)more-Allows file contents or piped output to be sent to the screen one page at a time. <ls -al |more> 20)mv-Move or rename files mv -i myfile yourfile Move the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile". 21)shutdown -Shuts the system down. <shutdown -h now> Shuts the system down to halt immediately.
22)whereis-Show where the binary, source and manual page files are for a command <whereis ls> Locates binaries and manual pages for the ls command. Eg:~$ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz 23)who-show who is logged on Eg:~$ who fp088 tty7 2010-05-20 13:36 (:0) fp088 pts/0 2010-05-20 13:37 (:0.0) 24)which-Find Command path 25)chmod-change file permissions
<ul><li>cooledit - a pretty powerful GUI text editor
jed - has pretty good emacs emulation (it can even read mail like emacs!). It does simple syntax highlighting for TeX files, including giving positioning of parentheses.
It would seem to be pretty configurable and takes up much less disk space than emacs, although more than joe and muemacs. It works well in console mode, and still manages to use colors for menu bars and syntax highlighting.
The program xjed which comes with some versions starts up its own X terminal when invoked. </li></ul>Editors
<ul><li>joe - "Joe's Own Editor", a fairly powerful editor with a compact binary and an ability to emulate Wordstar, Emacs, Pico, and a few other editors.
jove - "Joe's Own Version of Emacs". I tried this out a couple of times and managed to crash it when making some minor errors in command syntax.
microemacs (JASSPA) - spinoff of muemacs. Pretty powerful and configurable, while not taking up too much disk space or memory.
muemacs - a fairly powerful emacs clone whose binary is actually smaller than that of the Joe editor.
emacs - powerful text editor that includes modules for reading and sending mail and postings to newsgroups, and a browser module. For editing TEX and LATEX files, the AucTEX addon package is invaluable, and makes emacs pretty hard to beat as an editor with LATEX. </li></ul>
nedit - an X Window based text editor. Of all text editors for Linux , it has commands which are closest to Windows text editors, for cursor movement, highlighting, marking text, etc. It has very good syntax highlighting for both LATEX and HTML. pico - simple text editor. It often comes packaged with the Pine mail user agent. vi - included with most Linux distributions. If you're not used to the syntax, it can be pretty hard to understand. vim - improved version of vi xedit - simple text editor included with many Linux distributions
/ Root |---root The home directory for the root user |---home Contains the user's home directories | |----ftp Users include many services as listed here | |----httpd | |----samba | |----user1 | |----user2 |---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. Exists in the kernels imagination (virtual). This directory | | Holds information about kernel parameters and system configuration. | |----1 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 for various packages | |----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 for devices such as disk drives, serial ports, etc. |---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 networking, keyboard, time, and more. |---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, | | logouts, and other system messages. | |----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.
My SQL # MySQL is a relational database management system (RDBMS). # A relational database management system which runs a server, providing multi-user access to a number of databases. # SQL (Structured Query Language) is a standard interactive and programming language for getting information from and updating a database. # MySQL is currently the most popular open source database server in existence.
# Structured Query Langauge is cross between a math-like language and an English-like language that allows us to ask a database questions or tell it do do things. There is a structure to this language: it uses English phrases to define an action, but uses math-like symbols to make comparisons. For example: SELECT * FROM table; Where 'SELECT', 'FROM' and 'table' are in English, but '*' is a symbol that means all . USES: Many web applications use MySQL as the database component of a LAMP software stack. Its popularity for use with web applications is closely tied to the popularity of PHP , which is often combined with MySQL. Several high-traffic web sites including Flickr, Facebook, Wikipedia, Google, Nokia and YouTube use MySQL for data storage and logging of user data.
BASIC QUERIES Some basic Query commands in MySQL. This includes <ul><li>CREATE Command - is used to create a database/table.
SELECT Command - is used to retrieve data from the database.
DELETE Command - is used to delete data from the database.
INSERT Command - is used to insert data into a database.
UPDATE Command - is used to update the data in a table.
DROP Command - is used to delete or drop the database/table. </li></ul>.
CREATE Command : The Create command is used to create a table by specifying the tablename, fieldnames and constraints. Syntax: $createSQL=("CREATE TABLE tblName"); Example: $createSQL=("CREATE TABLE tblstudent(fldstudid int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,fldstudName VARCHAR(250) NOTNULL,fldstudentmark int(4) DEFAULT '0' "); SELECT Command: The Select command is used to select the records from a table using its field names. To select all the fields in a table, '*' is used in the command. The result is assigned to a variable name as shown below: Syntax: $selectSQL=("SELECT field_names FROM tablename"); Example: $selectSQL=("SELECT * FROM tblstudent");
DELETE Comman d: The Delete command is used to delete the records from a table using conditions as shown below: Syntax: $deleteSQL=("DELETE * FROM tablename WHERE condition"); Example: $deleteSQL=("DELETE * FROM tblstudent WHERE fldstudid=2"); INSERT Command: The Insert command is used to insert records into a table. The values are assigned to the field names as shown below: Syntax : $insertSQL=("INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) "); Example: $insertSQL=("INSERT INTO Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) ");
UPDATE Command: The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them. Syntax: $updateSQL=("UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber"); Example : $updateSQL=("UPDATE Tblstudent SET (fldstudName=siva,fldstudmark=100) WHERE fldstudid=2"); DROP Command: The Drop command is used to delete all the records in a table using the table name as shown below: Syntax: $dropSQL=("DROP tblName"); Example : $dropSQL=("DROP tblstudent");
Advanced functions and queries that can be useful when building more complex applications. INNER JOIN: INNER JOIN is used to retrieve the data from all tables listed based on condition listed after keyword ON. If the condition is not meet, nothing is returned. For Eg: We have employees table and offices table. Two tables are linked together by the column officeCode. To find out who is in which country and state we can use INNER JOIN to join these tables. Here is the SQL code: SELECT employees.firstname, employees.lastname, offices.country, offices.state FROM employees INNER JOIN offices ON offices.officeCode = employees.officeCode ADVANCED QUERIES
REPLACE: The REPLACE function searches a character string and replaces characters found in a search string with characters listed in a replacement string. Syntax : REPLACE(character_string, search_string, replacement_string) * character_string ->the string to be searched. * search_string -> the string of one or more characters to be found in chr String. * replacement_string ->the string that replaces any occurrences of search_string that are found in character_string. Example: R eplaces hyphens (dashes) found in a person’s phone number with periods. SELECT PERSON_PHONE, REPLACE(PERSON_PHONE,'-','.') AS DISPLAY_PHONE FROM PERSON; PERSON_PHONE DISPLAY_PHONE --------------- --------------- 230-229-8976 230.229.8976 401-617-7297 401.617.7297
LTRIM The LTRIM function removes any leading (left-hand) spaces in a character string.Only leading spaces are removed—embedded and trailing spaces are left in the string. Eg: LTRIM (' String with spaces ') Returns this string: 'String with spaces ' RTRIM The RTRIM function works like LTRIM, but it removes trailing spaces. If we need to remove both leading and trailing spaces, you can nest LTRIM and RTRIM like this: Eg:RTRIM(LTRIM (' String with spaces ')) Returns this string: 'String with spaces'
SIGN The SIGN function takes in a numeric expression and returns one of the following values based on the sign of the input number: Return Value Meaning − 1 Input number is negative 0 Input number is zero 1 Input number is positive Null Input number is null Eg :SELECT LATE_OR_LOSS_FEE, SIGN(LATE_OR_LOSS_FEE) AS FEE_SIGN FROM MOVIE_RENTAL WHERE LATE_OR_LOSS_FEE IS NOT NULL; LATE_OR_LOSS_FEE FEE_SIGN 29.99 1 4 1 4 1 29.98 1
SQRT The SQRT function takes in a single numeric expression and returns its square root. The general syntax is SQRT (numeric_expression) The result is a bit meaningless, but let’s take the square root of the non-null Late or Loss Fees we just looked at: SELECT LATE_OR_LOSS_FEE, SQRT(LATE_OR_LOSS_FEE) AS FEE_SQRT FROM MOVIE_RENTAL WHERE LATE_OR_LOSS_FEE IS NOT NULL; LATE_OR_LOSS_FEE FEE_SQRT ---------------- ---------- 29.99 5.47631263 4 2 4 2 29.98 5.47539953
CEILING (CEIL) The CEILING function returns the smallest integer that is greater than or equal to the value of the numeric expression provided as an input parameter. In other words, it rounds up to the next nearest whole number. As an example, SELECT LATE_OR_LOSS_FEE, CEILING(LATE_OR_LOSS_FEE) AS FEE_CEILING FROM MOVIE_RENTAL WHERE LATE_OR_LOSS_FEE IS NOT NULL; LATE_OR_LOSS_FEE FEE_CEILING ---------------- ----------- 4.00 4 4.00 4 29.99 30 29.98 30
FLOOR The FLOOR function is the logical opposite of the CEILING function —it returns the integer that is less than or equal to the value of the numeric expression provided as an input parameter. In other words, it rounds down to the next nearest whole number. Here is an example showing FLOOR applied to Late or Loss Fees: SELECT LATE_OR_LOSS_FEE, FLOOR(LATE_OR_LOSS_FEE) AS FEE_FLOOR FROM MOVIE_RENTAL WHERE LATE_OR_LOSS_FEE IS NOT NULL; LATE_OR_LOSS_FEE FEE_FLOOR ---------------- --------- 4.00 4 4.00 4 29.99 29 29.98 29
Date and Time: Function Purpose Input Parameters ADD_MONTHS Adds the supplied number of months to the supplied date date, number ofmonths (positive or negative value) CURRENT_DATE Returns the current date in the time zone set for the None database session EXTRACT Extracts the specified datetime field from the supplied date datetime field keyword, date LAST_DAY Returns the supplied date with the day shifted to the last day date of the month
<ul><li>A stored procedure is a procedure (like a subprogram in a regular computing language) that is stored (in the database).
MySQL supports "routines" and there are two kinds of routines: stored procedures or functions whose return values we use in other SQL statements.
A stored procedure has a name, a parameter list, and an SQL statement, which can contain many more SQL statements. </li></ul>CREATE PROCEDURE Syntax: The general syntax of Creating a Stored Procedure is : CREATE PROCEDURE proc_name ([proc_parameter[......]]) routine_body <ul><li>proc_name : procedure name
proc_parameter : [ IN | OUT | INOUT ] param_name type
An IN parameter is used to pass the value into a procedure.
An INOUT parameter is initialized by the caller and it can be modified by the procedure, and any change made by the procedure is visible to the caller. </li></ul>PROCEDURES
<ul><li>Functions can return string, integer, or real values and can accept arguments of those same types.
We can define simple functions that operate on a single row at a time, or aggregate functions that operate on groups of rows.
Information is provided to functions that enables them to check the number, types, and names of the arguments passed to them. </li></ul>CREATE FUNCTION Syntax: The general syntax of Creating a Function is : CREATE FUNCTION func_name ([func_parameter[,...]]) RETURNS type routine_body <ul><li>func_name : Function name
routine_body : Valid SQL procedure statement </li></ul>The RETURN clause is mandatory for FUNCTION. It used to indicate the return type of function. FUNCTIONS
Here is the list of all important MySQL functions. Each function has been explained along with suitable example. <ul><li>MySQL Group By Clause - It means of grouping the result dataset by certain database table column(s).
MySQL IN Clause - This is a clause which can be used alongwith any MySQL query to specify a condition.
MySQL BETWEEN Clause - This is a clause which can be used to specify a condition.
MySQL UNION Keyword - Use a UNION operation to combine multiple result sets into one.
MySQL COUNT Function - The MySQL COUNT aggregate function is used to count the number of rows in a database table.
MySQL MAX Function - The MySQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.
MySQL MIN Function - The MySQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.
MySQL AVG Function - The MySQL AVG aggregate function selects the average value for certain table column.
MySQL SUM Function - The MySQL SUM aggregate function allows selecting the total for a numeric column.
MySQL SQRT Functions - This is used to generate a square root of a given number.
MySQL RAND Function - This is used to generate a random number using MySQL command.
MySQL CONCAT Function - This is used to concatenate any string inside any MySQL command.
MySQL DATE and Time Functions - Complete list of MySQL Date and Time related functions. </li></ul>
What's the Difference Between a Stored Procedure and a Stored Function? The difference between a stored procedures and stored functions is the same as the difference between a subroutine and a function: * a stored procedure runs some code * a stored function runs some code and then returns a result Why Use Stored Procedures and Stored Functions? The real advantage to using stored procedures and stored functions is that they provide functionality which is platform and application independant.
It can be used to back up a database or to move database information from one server to another. 1.Export A MySQL Database: This example shows how to export a database. It is a good idea to export the data often as a backup. # mysqldump -u username -ppassword database_name > FILE.sql Replace username, password and database_name with your MySQL username, password and database name. File FILE.sql now holds a backup of your database, download it to your computer. 2. Import A MySQL Database: Here, we import a database. Using this to restore data from a backup or to import from another MySQL server. Start by uploading the FILE.sql file to the server where we will be running this command. # mysql -u username -ppassword database_name < FILE.sql IMPORT AND EXPORT
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.