Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, October 13, 2011

Linux Bash Shell cheat sheet for beginners

Here I am sharing a Bash shell script sheet useful for Linux users who are not familiar with bash script/ Terminal commands. Script contain a list of commands and keyboard shortcuts with description, more relevant if you are an avid Ubuntu/Debian user.

Download Linux Bash Shell Cheet Sheet PDF file

Friday, May 6, 2011

WinSCP alternative in Ubuntu.

WinSCP is the most popular file transfer application in Windows Operating systems like filezilla. It helps to copy files from remote system to local system and wise versa. In Linux, filezilla is use for this purpose. But we can simulate WinSCP in Linux/Ubuntu by using Nautilus.


To simulate this we need to install Nautilus elementary, which is a nice addition to Nautilus to enable split view in the file browser. The steps for installing Nautilus elementary in Ubuntu are here.

Type the following in console

sudo add-apt-repository ppa:am-monkeyd/nautilus-elementary-ppa
The above line will add the repository from where you can download the Nautilus elementary

sudo apt-get update && sudo apt-get upgrade
will update the local repositories and update all the software.

nautilus -q   
Now open Nautilus and press F3. You should able to see the split windows.


Access Remote system

Access the remote system by connecting to remote system in one pane. Select the right side pane and go to File->Connect to Server

Fill up the details of the remote system and then press connect. Now the right hand panel will have the files of remote system.
The left hand panel will have the files of local system. To drag and drop the files form one pane to other for copying the files. Also you can use SSH, FTP, SFTP etc protocols to connect the remote system.

Wednesday, March 2, 2011

Important Linux commands

Linux is one of the most used, free open source operating system. Most of the web servers uses linux as the OS. So web developers should aware of basic linux commands for the easy installation and development. The main Linux commands and syntaxes are explained here.




Copy -cp
cp- copy files and directories

Syntax
  cp [options] SOURCE DEST
  cp [options] SOURCE DIRECTORY
 
  Options
-a, --archivesame as -dpR
--backup[=CONTROL]make a backup of each existing destination file
-blike --backup but does not accept an argument
--copy-contentscopy contents of special files when recursive
-dsame as --no-dereference --preserve=link
-f, --forceif an existing destination file cannot be opened, remove it and try again (redundant if the -n option is used)
-i, --interactiveprompt before overwrite (overrides a previous -n option)
-Hprompt before overwrite (overrides a previous -n option)
-l, --linklink files instead of copying
-L, --dereferencealways follow symbolic links
-psame as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST]preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: links, all
--no-preserve=ATTR_LISTdon't preserve the specified attributes
--parentsappend source path to DIRECTORY
-Psame as '--no-dereference'
-R, -r, --recursivecopy directories recursively
--remove-destinationremove each existing destination file before attempting to open it (contrast with --force)
--reply={yes,no,query}specify how to handle the prompt about an existing destination file
--sparse=WHENcontrol creation of sparse files
--strip-trailing-slashesremove any trailing slashes from each SOURCE argument
-s, --symbolic-linkmake symbolic links instead of copying
-S, --suffix=SUFFIXoverride the usual backup suffix
--target-directory=DIRECTORYmove all SOURCE arguments into DIRECTORY
-u, --updatecopy only when the SOURCE file is newer than the destination file or when the destination file is missing
-v, --verboseexplain what is being done
-x, --one-file-systemstay on this file system

Secure copy - scp
scp- secure copy (remote file copy program)

scp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1).  Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
File names may contain a user and host specification to indicate that the file is to be copied to/from that host.  Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers.  Copies between two remote hosts are also permitted.

Syntax
scp [options] [[user@]host1:]file1[[user@]host2:]file2
Options
-1Forces scp to use protocol 1.
-2Forces scp to use protocol 2.
-4Forces scp to use IPv4 addresses only.
-6Forces scp to use IPv6 addresses only.
-BSelects batch mode (prevents asking for passwords or passphrases).
-CSelects batch mode (prevents asking for passwords or passphrases).
-F ssh_configSelects batch mode (prevents asking for passwords or passphrases).
-pPreserves modification times, access times, and modes from the original file.
-qQuiet mode: disables the progress meter as well as warning and diagnostic messages from ssh(1).
-rRecursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.
-vVerbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.


SSH

ssh - OpenSSH SSH client (remote login program)
ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.  X11 connections and arbitrary  TCP ports can also be forwarded over the secure channel.

Syntax
ssh [user@]hostname [command]


Move - mv

mv - move (rename) files
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory  arguments  to  long  options are mandatory for short options too.
Syntax
mv [options] [-T] SOURCE DEST
mv [options] SOURCE DIRECTORY

Options
--backup[=CONTROL]make a backup of each existing destination file
-f, --forcedo not prompt before overwriting
-T, --no-target-directorytreat DEST as a normal file
-v, --verboseexplain what is being done


Remove - rm
rm - remove files or directories

Syntax
rm [options] FILE
Options
-f, --forceignore nonexistent files, never prompt
-iprompt before every removal
-Iprompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving protection against most mistakes
--interactive[=WHEN]prompt according to WHEN: never, once(-I), or always(-i). Without WHEN, prompt always
-r, -R, --recursiveremove directories and their contents recursively
-v, --verboseexplain what is being done
--versionoutput version information and exit


Sunday, February 20, 2011

Installing Apache, MySQL and PHP in Linux-Ubuntu

Apache is the most commonly used web server. It is a free open source web server. PHP is an open source server scripting language. It has a lot of advantages. MySQL is also an open source database used for small and medium data storage. It can also used for large data storage also.

We can install apache, PHP and MySQL in two ways. 1. Download source code from their site and install. 2 the easiest way install it from synaptic package manager. If you use this method apt-get automatically manage all dependencies. So I explain the second method here.

1. Open the Terminal from Applications -> Accessories -> Terminal

2. Install apache2 copy paste command to terminal
sudo apt-get install apache2

3. Install PHP5
sudo apt-get install php5 libapache2-mod-php5

4. Restart apache
sudo /etc/init.d/apache2 restart

Now the PHP was installed. To test it create a php page in /var/www/ - the webroot and run it
Example sudo gedit /var/www/hello.php
write a basic php code in it

to run this script type http://localhost/hello.php in your browser and you can see "Hello World" in it.

5. Install mySQL
sudo apt-get install mysql-client mysql-server mysql-query-browser mysql-admin mysql-navigator php5-mysql php5-gd

6. Restart apache
sudo /etc/init.d/apache2 restart 

7. If you need phpmyadmin follow this step. If you like to use MySQL GUI then skip this step
sudo apt-get install phpmyadmin 

Restart apache
sudo /etc/init.d/apache2 restart 

Add following lines in httpd.conf
# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf

To access httpd.conf copy paste following line to terminal

sudo gedit /etc/apache2/httpd.conf

Restart apache
8. If you need to access your url as http://localhost/~username, enable userdir module in apache2. enable mod_rewrite to allow clean url
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/userdir.load
sudo ln -s ../mods-available/userdir.conf
sudo ln -s ../mods-available/rewrite.load
sudo /etc/init.d/apache2 reload

9. Create folder /home/<username>/public_html -- > this is the folder which we are going to use as the document root for local development. So you will be accessing your local websites as http://localhost/~username/sitename

10. Edit /etc/apache2/mods-available/userdir.conf and change the AllowOverride line to just read AllowOverride All
Now you can use public_html as user document root

Enjoy scripting

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Maintained by Web Themes