Posts Tagged ‘linux’

We do so much technical and serious stuffs. Fun is equally important. Following are few cool stuffs I found, so sharing with yo guys…

Fork Bomb

Type the following in the terminal (at your own risk). This repeatedly creates the child process.

:(){ :|:& };:

This is same as the following in C.

while (true) {
fork();
}

Screenshot from 2013-09-23 01:34:30

yes command

This command prints the parameter passed repeatedly until interrupted (ctrl+c).

#yes print this line

Screenshot from 2013-09-23 01:15:08

espeak

Listen to the e-voice. Turn on your speakers before you execute this command. (To install espeak, #apt-get install espeak).

#espeak “Hello there, how are you”

Screenshot from 2013-09-23 02:19:17

cmatrix

How many have played with the batch file and were crazy about the matrix rain as the startup guys in windows? Why did we stop this in with Linux? Try cmatrix… (To install cmatrix, #apt-get install cmatrix).

#cmatrix
#cmatrix -b (this is cool.)

Screenshot from 2013-09-23 00:58:06

aafire

Like fire? (To install aafire, #apt-get install aafire).

#aafire

Screenshot from 2013-09-23 01:00:27

oneko

Love cute graphic? Try oneko (To install, #apt-get install oneko).

#oneko

Screenshot from 2013-09-23 00:59:14

toilet

I know, funny name… But this is used for graphical word art. (To install, #apt-get install toilet).

#toilet ginger

Screenshot from 2013-09-23 01:04:47

cowsay

ASCII cow art. Fans of cDc and people used to metasploit framework would be used to this cow… (To install, #apt-get install cowsay).

#cowsay Ahoy

Screenshot from 2013-09-23 01:07:00

xcowsay

Pure graphics implementation. (To install, #apt-get install xcowsay).

#xcowsay linux

Screenshot from 2013-09-23 01:10:35

funny manpages

This is damn funny!! Install this (#apt-get install funny-manpages). And try the following list…

baby
celibacy
condom
date
echo
flame
flog
gong
grope, egrope, fgrope 
party 
rescrog 
rm
rtfm
tm
uubp
xkill 
xlart 
sex 
strfry

#man celibacy

Here is the screenshot for #man celibacy
Try others, it is really funny!!

Screenshot from 2013-09-23 02:15:50

Complimentary :P

Screenshot from 2013-09-23 01:22:41

And also…, this :

Online Command line fm for geeks…, do check it out…

cmd.fm

Advertisements

To build a general purpose web server, we need few components… One such software-bundle is LAMP and is open source.

L -> Linux (operating system); A-> Apache (HTTP server); M -> MySQL (database software); P -> PHP/Perl/ Python (scripting languages, we will consider PHP).

One can install the complete bundle in a single command, or install each component separately. We will see both.

1. Install the entire bundle using Tasksel.

Tasksel is a Debian/Ubuntu tool that installs multiple related packages as a co-ordinated “task” onto your system.

If Tasksel is not installed, install using the command,

$sudo apt-get install tasksel

Screenshot from 2013-08-04 22:12:12

To install the LAMP stack, you can invoke tasksel and choose the LAMP server or directly install using your command line.

=>Run tasksel

#tasksel

Screenshot from 2013-08-04 21:41:58

When you hit enter, it gives you package configuration. select LAMP server using your arrow keys, tab to move to the next section, space to select, and enter to confirm.

Screenshot from 2013-08-04 03:11:22

=>Or use the command line to install your LAMP server using the command,

#tasksel install the_name_of_the_stack_or_stuff_you_want_to_install

#tasksel install lamp-server

Screenshot from 2013-08-04 21:42:55

Once done, your packages will be installed and your lamp-server is all set.

Screenshot from 2013-08-04 03:12:58

—————————————————————————————————————————————————————-

2. Install individual component and set up a LAMP server.

I personally prefer installing the individual component as this helps in understanding the stack better.

I use ubuntu-12.10, you can use any alternate Linux distro. On this Linux machine, let us install the remaining components.

=>Install Apache.

Install the Apache HTTP server, by running the following command,

$sudo apt-get install apache2

Screenshot from 2013-08-04 22:15:01 

Accept the license agreement. Again, use your tab key to move to the next section, space to select, and enter to confirm.

Screenshot from 2013-08-04 02:30:38

Once the installation is done, you can check your server’s ip by running the following command,

$ifconfig eth0 | grep inet | awk ‘{print $2}’

Screenshot from 2013-08-04 22:11:03

You can start your Apache server by running the command,

#/etc/init.d/apache2 start

And check the status using,

#/etc/init.d/apache2 status

Screenshot from 2013-08-04 22:09:17

And stop Apache using,

#/etc/init.d/apache2 stop

Screenshot from 2013-08-04 22:10:15

=>Install MySQL

Install MySQL by running the following command,

#apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

Screenshot from 2013-08-04 22:08:05

After the installation, lets activate it using the command,

#mysql_install_db

Screenshot from 2013-08-04 22:33:33

To see the contents, use the following commands,

#cd /usr/bin

#ls mysql*

Screenshot from 2013-08-04 23:16:33

Lets run MySQL set up script, and secure our server. Run the following command,

#mysql_secure_installation

This takes you through a number of steps, choose appropriately and move on.

Screenshot from 2013-08-04 03:34:25

Screenshot from 2013-08-04 03:36:15

Screenshot from 2013-08-04 03:37:40

This continues and finally a clean up is done, n your MySQL server is all set to go.

=>Install PHP

Install php5, by running the command,

#apt-get install php5 libapache2-mod-php5 php5-mcrypt

Screenshot from 2013-08-04 23:51:49

PHP Modules:

To see the available libraries, run,

#apt-cache search php5-

Screenshot from 2013-08-04 03:54:10

You can install a module using,

#apt-get install module_name

With this your LAMP server is all set to go…

——————————————————————————————————————————————————————-

=>Lets see some PHP on the server.

Lets create a php info page. Here I am using editor nano, you can go for you choice.

#nano /var/www/info.php

Screenshot from 2013-08-05 00:12:43

Enter these codes…

<?php

phpinfo();

?>

save and exit.

Screenshot from 2013-08-04 23:53:55

To see the changes, restart Apache using,

#service apache2 restart

Screenshot from 2013-08-05 00:25:06

Check it out in your browser… Go ahead and visit the info.php page.

Type in, http://127.0.1.1/info.php

Replace 127.0.1.1 with your server ip that has been returned.

Screenshot from 2013-08-04 04:01:21

Basic Unix/Linux

Posted: July 25, 2013 in LAMP, Linux, Unix/Linux
Tags: , ,

Linux is primarily used through a command line interface. Throughout we will use command line interface. Open a terminal shell.

Screenshot from 2013-07-25 23:05:22

Note:

$ -> indicates that you have logged in as a normal user.

# -> indicates that you have the root access or administrative privilege.

Commands

~ is your home directory.

. is the current director.

.. is the directory above the current directory.

man is an interface to the on-line reference manual.

$man command_name ; $man man #this gives the manual for the command man (anything after # is considered as comment.)

who Logs of users.

$who

whoami Current user who has been logged in.

$whoami

pstree Process tree.

$pstree

top CPU usage.

$top

ps Current running processes. ps -a, displays all the process that are running, including the system processes.

$ps ; $ps -a

kill Terminate the process using kill command.

$kill process_id ; $kill 1880

uptime How long the system has been running?

$uptime

last Login history

$last

cd Change directory.

$cd directory_name ; $cd /home/monsi/Desktop

mkdir Make a new directory.

$mkdir directory_name ; $mkdir new_dir

pwd Print working directory. Where am I?

$pwd

echo Print the given string.

$echo “string to be printed” ; $echo “Ahoy!”

which Gives the location of the command.

$which command_name ; $which pwd

type Tells whether the mentioned command is a shell built in or user defined.

$type command_name ; $type cd

env Prints current environment variables in the shell.

$env

ls List the files in the current directory. ls command with options are really useful. ls -a, ls  -l and ls -F.

$ls ; $ls -a ; $ls -l; $ls -F

mv Move the file. This command serves as rename. mv -i is useful for interactive, which prompts before overwriting another file.

$mv file_name new_file_name ; $mv foo foo1 #renames foo as foo1

rm Remove. rm -r, can be used to recursively remove files., in other words, remove a directory.

$rm file_name ; $rm foo

cp Copy the file/directory.

$cp file_name path ; $cp foo /home/monsi/Desktop/foo1

ln Create a link to another file. This is like shortcut in Windows. ln creates hard link, ln -s creates symbolic link.

$ln file_name link_name ; $ln foo foo2

df Disk free. This command indicates how much disk space is being used.

$df

du Disk usage. This command indicates how big are the files in the current directory.

$du

grep Meant for pattern matching., or find a pattern/string within a file. This is a powerful command.

$grep pattern file_name_in_which_pattern_needs_to_be_searched ; $grep monsi /etc/passwd

locate Find all files on the computer with names matching the given patter/string. This is similar to find command.

$locate foo

more, less Page through a file without using an editor. Example,

$locate config | more

uname Basic system description.

$uname

ifconfig Configure a network interface.

$ifconfig

netstat Prints network statistics (which includes, network connections, routing tables, interface statistics, masquerade connections and multicast memberships)

$netstat