Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

10 July 2011

Linux comand for Network troubleshooting

Sometimes the admins and network engineers have to deal with a variety of problems on the network. I will share my experience about troubleshooting on the network by using 5 standard tool commonly used for troubleshooting the

    
ping
    
traceroute
    
netstat
    
telnet
    
tcpdump
Ping. I'm sure most of the network admin and network engineer must know the ping command. ping is used to check network connectivity. Ping uses ICMP protocol. The format of the ping command:
ping nama_host / ip_address option
For example: ping 192.168.100.1-c 10 it will be to ping the ip 192.168.100.1 10 times.
Traceroute Traceroute is used to check or trace the route network. Suppose we try to ping www.yahoo.com and the result turned out to request time out To mnegetahui rupture in our network or network provider, then we use the traceroute command.
example traceroute: traceroute www.yahoo.com
Netstat Netstat is used to check the connection happen and open ports and can also be used to view the routing table. So with netstat we can know that we use computers or servers that we are setting the connections and open ports where port whatever
example netstat: netstat-an To see the connection in any direction
netstat-tpnl To view an open TCP port
Telnet. Telnet is used to check whether the port is accessible from any clien. eg port 25 and 110 checks For example telnet: telnet 10.2.86.75 25 25 to check smtp
telnet 10.2.86.75 25 110 to check pop3
Tcpdump. Tcpdump is used to extract data packets. By knowing the data packets that pass, we can identify whether there is something wrong such as a broadcast ip or ip who try to do activities that are not allowed
tcpdump examples: tcpdump-vv to perform packet sniffing tcpdump-i eth0 for sniffing packets on interface eth0 tcpdump host alinuxnews for sniffing host alinuxnews

07 June 2011

Securing SSH server in Linux

Restrict ssh access to the server is a must because it involves security issues. Now I will share how to limit ssh into our server. Let's assume our server is a server D

1. Changing the ssh port for only us who know the server D
2. Prohibiting root login via ssh for security
3. Restrict ip addresses which can do ssh to the server D

To do the numbers 1 and 2 we can do it by editing the files in sshd_config.

To change the ssh port, change the number 22 to another number in the Port parameter 22. 22 is the default port for ssh service, and therefore replace it with another number such as 40

Port 40

To disallow root login, change the following parameter from NO to YES

PermitRootLogin yes

To limit the IP addresses that may access the server D then we should use / etc / host.allow and / etc / host.deny
in / etc / hosts.allow we must enter the ip address that are allowed to remotely

# pico / etc / hosts.allow

and enter the following parameters
sshd: 192.168.13.0/24 # # # if we want to allow network 192.168.13.0 to our server remotely via ssh D

if it is finished, save and edit the file / etc / host.deny

# pico / etc / hosts.deny

then edit and enter the following parameters

sshd: ALL # # # This will refuse all connections other than that you enter in / etc / hosts.allow

then save and exit

after that please restart your ssh sevice for configuration number 1 and 2 runs

06 May 2011

Screen : shell command for making daemon process in Linux

Those who like to use terminal in Linux, usually already know how to make a process into a daemon. Some of us usually using the characters '&' after the command. Anyway that way has as weaknesess.  The weaknesses of the daemon by using the character is the difficulty in monitoring the log process or see the current process. Sometime we must create a program to produce a log file. It will be simple if the program is mad by your self, but if not? You will get dificulties and takes long time.

For that I now prefer to use a screen, a small program that really helped me. The way is simple, just type "screen", you will move to shadow of the console and press the space bar. In the new console you can type various another Linux commands. So, how do I return to the old terminal. Quite simple as well, press Ctrl A and D. Remember Ctrl A and D at the same time. Do not only press Ctrl D alone because Ctrl + D means that you turn off the screen of the terminal. If we have exit the screen, we can see a list of screen that we created with the command bellow :

screen-list

There are screens on:
     28694.pts-0.test (03/05/11 11:28:02) (detached)
     28479.pts-0.test (03/05/11 11:26:31) (detached)
     26057.pts-4.test (02/05/11 14:34:46) (detached)

If we want to return to the screen that we just created can we type the command bellow

screen-r numberscreen

example:
screen-r 28694

so from now on you can make the process as much as possible with the "screen" command.

24 March 2011

Create Wallpaper slideshow in Linux

Wallpaper slideshow is one of the interesting features in the GNOME Desktop. We can enjoy the turn of the desktop within a certain timeframe. By default, Ubuntu has wallpaper slideshow with titles cosmos. Try it.

Now I will teach you how to make wallpaper slideshow manually, although it could just use a wallpaper slideshow application, which unfortunately is not my concern.

Well, prepare a few images as wallpaper and place it in a folder, for example, I put it in the folder / home / alinuxnews / Pictures / slidepaper of contents:
- 1.png
- 2.svg
- 3.jpg
- 4.jpg
- 5.jpg
- Slidepaper.xml

Let's open the file slidepaper.xml or you can open gedit, click new and save with slidepaper.xml name in the folder.
Copas my own code and modification of files / usr/share/background/cosmos/background-1.xml

Contents:

<background>
  <starttime>
    <year> 2011 </ year>
    <month> 01 </ month>
    <day> 01 </ day>
    <hour> 00 </ hour>
    <minute> 00 </ minute>
    <second> 00 </ second>
  </ Starttime>
<! - This animation will from the start at midnight. ->
  <static>
    <duration> 1795.0 </ duration>
    <file> / home/alinuxnews/Pictures/slidepaper/1.png </ file>
  </ Static>
  <transition>
    <duration> 5.0 </ duration>
    <from> / home/alinuxnews/Pictures/slidepaper/1.png </ from>
    <to> / home/alinuxnews/Pictures/slidepaper/2.svg </ to>
  </ Transition>
  <static>
    <duration> 1795.0 </ duration>
    <file> / home/alinuxnews/Pictures/slidepaper/2.svg </ file>
  </ Static>
  <transition>
    <duration> 5.0 </ duration>
    <from> / home/alinuxnews/Pictures/slidepaper/2.svg </ from>
    <to> / home/alinuxnews/Pictures/slidepaper/3.jpg </ to>
  </ Transition>
  <static>
    <duration> 1795.0 </ duration>
    <file> / home/alinuxnews/Pictures/slidepaper/3.jpg </ file>
  </ Static>
  <transition>
    <duration> 5.0 </ duration>
    <from> / home/alinuxnews/Pictures/slidepaper/3.jpg </ from>
    <to> / home/alinuxnews/Pictures/slidepaper/4.jpg </ to>
  </ Transition>
  <static>
    <duration> 1795.0 </ duration>
    <file> / home/alinuxnews/Pictures/slidepaper/4.jpg </ file>
  </ Static>
  <transition>
    <duration> 5.0 </ duration>
    <from> / home/alinuxnews/Pictures/slidepaper/4.jpg </ from>
    <to> / home/alinuxnews/Pictures/slidepaper/5.jpg </ to>
  </ Transition>
  <static>
    <duration> 1795.0 </ duration>
    <file> / home/alinuxnews/Pictures/slidepaper/5.jpg </ file>
  </ Static>
  <transition>
    <duration> 5.0 </ duration>
    <from> / home/alinuxnews/Pictures/slidepaper/5.jpg </ from>
    <to> / home/alinuxnews/Pictures/slidepaper/1.png </ to>
  </ Transition>
</ Background>

Then edit the file / home/alinuxnews/.gnome2/backgrounds.xml
If no, copy it from / usr / share / gnome-background-properties / backgrounds.xml

If at me for wearing my mint copy of linuxmint.xml 8 in the same folder.

Add the following lines before the last line:

<wallpaper deleted="false">
   <name> SlidePaper </ name>
   <filename> / home / alinuxnews / Pictures / slidepaper / slidepaper.xml </ filename>
   <options> zoom </ options>
   <shade_type> solid </ shade_type>
   <pcolor> # 000000000000 </ pcolor>
   <scolor> # 000000000000 </ scolor>
</ Wallpaper>

Well, now look at the Preferences tab Appeareance Backgrounds (Right click on desktop> Change Desktop Background). Click to activate

09 March 2011

Enable SSH server in Linux Mint

Because it functioned as a desktop, LinuxMint by default does not enable SSH server. I want to activate it because it often uses SSH for the connection and data transfer via scp command.

Here is how to enable OpenSSH server on LinuxMint:

  1.     Open the main menu, select the Software Manager
  2.     Openssh Type in the search box
  3.     Click on the package openssh-server, then select install.
  4.     Finish install, enable ssh with the command: / etc / init.d / ssh start

Because LinuxMint based on Ubuntu, OpenSSH server installation command can also be done via the console / terminal with the command:

apt-get install openssh-server

For access security, such as changing the default SSH port from port 22 to another port can be done by making changes to the configuration file contained in the file / etc / ssh / sshd_config.

After making changes, do not forget to restart the OpenSSH Server service:

/etc/init.d/ssh restart

20 January 2011

Linux Distribution For Netbook

As you know that netbook have some limitation in hardware compared to notebook or desktop computer. Usually, Netbook can be used to surf the Web, compose e-mails, do light office tasks, and play music or videos. Due to that limitations, a linux distribution which optimized for that limitation are required in order the function and usage of netbook still can be used especially in screen resolution limitation and less processing power limitations. Here are some linux distribution / distro which optimized for netbook :

Ubuntu Netbook Edition
Ubuntu Netbook Edition was formely Ubuntu Netbook Remix is a Ubuntu distribution which optimized for netbook. Ubuntu Netbook Edition brings all the advantages of Ubuntu to netbook with the interface called Unity, an innovative user interface super-optimised for smaller screens. With Unity, the GUI is very nice and suitable for netbook screen.
You can find the detail of Ubuntu Netbook Edition here

MeeGo
MeeGo is distrubution which come from combination (merging) of Moblin and Maemo. MeeGo integrates the experience and skills of two significant development ecosystems, versed in communications and computing technologies. The MeeGo project believes these two pillars form the technical foundations for next generation platforms and usages in the mobile and device platforms space.
You can find the detail of Meego here
Jolicloud
Jolicloud is an Internet operating system which is designed to run on relatively low-powered netbook computers. Jolicloud transforms  netbook into a sophisticated web device that taps into the cloud to expand your computing possibilities. The web already hosts a significant part of our lives like mails, photos, videos, and friends are already somewhere online.
You can find the detail of Jolicloud here

25 May 2010

How to install LigHttpd which support PHP 5

How to run LigHttpd which support PHP5 and also MySQL in linux ubuntu based like Ubuntu or linux Mint?
Bellow please find the simple step to do that.
First, of course you must install the application. You can install it via shell command bellow :

sudo apt-get install lighttpd php5-cgi php5-mysql mysql-server phpmyadmin

After installation, your lighttpd will not automatically support to run *.php file. You still need to edit some configuration in file php.ini which can be found at /etc/php5/cgi/php.ini . Open that file and then add the script bellow :

cgi.fix_pathinfo=1

Then, activate cgi module in lighttpd via shell command bellow :

sudo lighthttpd-enable-mod fastcgi

The the last step is reload the lighttpd daemon via shell commadn bellow :

sudo /etc/init.d/lighttpd reload

By that reload script, the process of installing and configurating the lighttpd whcih support php5 is complete.
Now, you can check it by add some example of php file in folder /var/www .

07 March 2010

Running or Stopping Firewall in Linux

When setting up a system that has never been setup at the previous, I usually turn off the firewall to see if the setup without a firewall is running properly. If it goes well, then the firewall will be enabled. It is often I do to find out wheter there are problems associated with a firewall setup or not.

The firewall serves as a blockade of access from unwanted connections. This facility is an important and commonly used in server environments to restrict any ports that might be accessed, both internally and externally. To disable the firewall on Red Hat Linux system and its derivatives like Fedora, CentOS, or others derivatives, here are two magic commands:

service iptables save
service iptables stop

If you want the firewall does not automatically run at boot time, give the following command:

chkconfig iptables off

If the Linux system is used as server and accessible from the public IP addresses, the firewall should be activated again after the testing process is completed, by providing an exception or allow the service / port which related

05 November 2009

How to make Linux Debian based as Web Server

If you want to make your linux debian based as Web server, bellow is the way

Installing Apache 

apt-get install apache2

After that , do test HTTP Server:
Open a web browser and enter http://localhost or its IP Address http://ip-address.

Installing PHP

apt-get install php4
/etc/init.d/apache2 restart
vi /var/www/testphp.php

To test it, Insert this following line into testphp.php file.

<?php phpinfo(); ?>
Save this new file.
Open a web browser and enter http://IP-Address/testphp.php .

Install PostgreSQL

apt-get install libapache2-mod-auth-pgsql
apt-get install php4-pgsql
/etc/init.d/apache2 restart

Mapping URLs to folders outside /var/www/

vi /etc/apache2/conf.d/alias

Insert this following line into the new file.

 
Alias /URL-path /location_of_folder/

<directory /location_of_folder/>
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

Save a new file.

Restart Apache
/etc/init.d/apache2 restart

finished :)

28 October 2009

How to Flush DNS in Linux

In Linux, the nscd daemon manages the DNS cache. So if we want to flush the DNS cache, we do it via that nscd daemon.

To flush the DNS cache, restart the nscd daemon.

To restart the nscd daemon, use the command 
/etc/init.d/nscd restart

To restart the nscd daemon, we can also use the command

service nscd restart

15 August 2009

How to Install Virtual Box on Linux (Fedora)

This is how to get VirtualBox up and running on Linux Fedora 10.  Also, this tutorial is for the 32-Bit version of VirtualBox, so you’ll have to customize a little more to get the 64-bit version running. Everything in the “code” sections should be copy/pasted/typed into the terminal.
Right, let’s get to it:

PreStep.) Open the terminal and get into super user mode:

    su -

1.) Get the latest VirtualBox package (as of now, 2.0.6) from the VirtualBox website for Fedora 9 and install it (generally, after a few months, the Fedora 10 link will be available).

    wget http://download.virtualbox.org/virtualbox/2.0.6/VirtualBox-2.0.6_39765_fedora9-1.i386.rpm && rpm -ivh VirtualBox-2.0.6_39765_fedora9-1.i386.rpm

2.) Get the kernel-devel package:

    yum install make automake autoconf gcc kernel-devel dkms

3.) Run the setup file for VirtualBox:

    /etc/init.d/vboxdrv setup

4.) Add yourself to the “vboxusers” group and fix the SELinux Permissions:

    usermod -G vboxusers -a username
    chcon -t textrel_shlib_t /usr/lib/virtualbox/VirtualBox.so

5.) Run, and enjoy!

    VirtualBox

6.) To Get USB Support:

    1 – create a new group called “usb”;
    2 – locate file usbfs: in my case is /sys/bus/usb/drivers (I suggest to find the file with a usb device inserted;
    3 – modify file /etc/fstab inserting a line containing the right path and the number corresponding the “usb” group :
    none /sys/bus/usb/drivers usbfs devgid=503,devmode=664 0 0
    4 – command mount -a;
    5 – start VB and try…;

Source: Fedora Forums
7.) To Properly Backup the VirtualBox Machine (.vdi):
Please refer to my other page here:
How To: Properly Backup a VirtualBox Machine (.VDI)
8.) To Get Sound Working:
Highlight your virtual machine and click on the “Settings” button. Click on the “Sound” category, and then check the “Enable Sound” option. In the drop-down box, select “PulseAudio”. You should now have sound.
That’s it!

24 May 2009

Commonly used Linux/Unix commands

Bellow are some of commonly used Linux shell command which usually used every day



Starting and Ending

login: `Logging in'
ssh: Connect to another machine
logout: `Logging out'

File Management


emacs: `Using the emacs text editor'
mkdir: `Creating a directory'
cd: `Changing your current working directory'
ls: `Finding out what files you have'
cp: `Making a copy of a file'
mv: `Changing the name of a file'
rm: `Getting rid of unwanted files'
chmod: `Controlling access to your files'
cmp: Comparing two files
wc: Word, line, and character count
compress: Compress a file

Communication


e-mail: `Sending and receiving electronic mail'
talk: Talk to another user
write: Write messages to another user
sftp: Secure file transfer protocol

Information


man: Manual pages
quota -v: Finding out your available disk space quota
ical: `Using the Ical personal organizer'
finger: Getting information about a user
passwd: Changing your password
who: Finding out who's logged on

Printing


lpr: `Printing'
lprm: Removing a print job
lpq: Checking the print queues

Job control


ps: `Finding your processes'
kill: `Killing a process'
nohup: Continuing a job after logout
nice: Changing the priority of a job
&: `What is a background process?'
Cntrl-z: Suspending a process
fg: `Resuming a suspended process

24 April 2009

How to Add DNS in Linux using shell script

If you want to add DNS server in linux. The fastest way is using shell script.
Here is fastest way to add DNS server in Linux

edit /etc/resolve.conf with your favorite editor (gedit,nano,vim, vi...etc)

for each name server add
nameserver <ip>

06 March 2009

How to make partition in Linux using Gparted

If you want to make partition in Linux, you can use Gparted for that.
Here is how to make partition using gparted

  1. Downloaded Gparted Live 0.3.1-1 Burned as ISO using K3B.
  2. Booted into XP and verified that I had all my music, videos, and documents backed up to the fat32 partition. Deleted all copies on ntfs partition. Opened add remove programs and uninstalled all the Windows versions of programs that I also have on Ubuntu and all programs that I rarely used. Retained all programs that I might use if I ever boot into XP again. Opened and ran disk cleanup wizard. Ran disk defragmenter about five times.
  3. Rebooted with Gparted Live disk. Wow! Amazing program. Only 85MB on the disk and loads linux to ram in less than two minutes! Resized ntfs from 97GB to 40GB.
  4. Decided to use some of that 50GB of free space to try Edgy Eft Knot3. Downloaded, burned as ISO (K3B again), and rebooted. Booted live Edgy disk, clicked the install icon, and ran into a little problem. My disk already had four primary partitions and the newly freed space was not in the extended partition. Was unable to proceed using installation partitioner.
  5. Rebooted with Gparted Live disk. First, I moved my second primary partition (/home) as far left as I could enlarging it by about 10GB as I did. This placed the free space next to my extended partition. Second, I enlarged the extended partition to encompass the free space.

05 February 2009

How to check IP In Linux

In Linux, you can use Shell Command to find or get IP address
It displays Ethernet IP address, Mac address, subnet mask and other information.
Type /sbin/ipconfig command to display IP address:

Code:

$ /sbin/ifconfig

Code:

$ /sbin/ifconfig | less


Under Solaris and other Unixish oses you may need to type ifconfig command with -a option as follows:

Code:

$ /sbin/ifconfig -a
Output sample

Code:

eth0     Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07
  inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
  inet6 addr: fe80::20f:eaff:fe91:407/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:31167 errors:0 dropped:0 overruns:0 frame:0
  TX packets:26404 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:38338591 (36.5 MiB)  TX bytes:3538152 (3.3 MiB)
  Interrupt:18 Base address:0xc000