Copy file to / from server via SCP command

SCP uses Secure Shell (SSH) to transfer data between client and remote server, it’s fast and secure. In this article, we will show you two common SCP copying examples : Copying data from your computer to remote server. Copying data from remote server to your computer. 1. Copying data to Remote Server Example 1.1 – …

Read more

Linux Search and Replace example

I was recently in a situation of having to change some text that appeared in a bunch of config files that were inside nested sub-directories. Not having time to dust off 10-year old perl skills, I was looking for some shell commands that would work. Surprisingly, there are many examples on the web that do …

Read more

How to find a file in linux

In *nix, you can use the find command to find a file easily. $find {directory-name} -name {filename} 1. Find a file in the root directory If you have no idea where the file is located, you can search the entire system via the “/” root directory. Below example shows you how to find a file, …

Read more

How to unzip a WAR file in Java

In J2EE web development, Web Application Archive(WAR) file is just a normal JAR file, which consists all of your web application components like, servlets, Java classes, libraries, resources and etc. Read Wiki for detail. Problem Current web application WAR file is generated via Ant or Maven tool, copy to *nix environment for deployment, but no …

Read more

How to restart apache services in unix?

Often times, as server administrator, have to telnet or SSH to their server to restart the Apache Http services. The Apache http services are usually located at the following location, 1) init.d start script folder. issue “./apache restart” to restart it debian:/etc/init.d# ./apache restart Forcing reload of web server (apache)… waiting . debian:/etc/init.d# 2) usr/local/apache/bin …

Read more

How to download a website in Linux (wget)

The wget is a useful command to download a website in Linux. For example , wget [url]. [mkyong@snake ~]$ wget -r -p -k -E http://www.google.com –2009-07-19 14:07:27– http://www.google.com/ Resolving www.google.com… 64.233.189.104 Connecting to www.google.com|64.233.189.104|:80… connected. HTTP request sent, awaiting response… 302 Found Location: http://www.google.com.my/ [following] –2009-07-19 14:07:27– http://www.google.com.my/ Resolving www.google.com.my… 64.233.189.147 Connecting to www.google.com.my|64.233.189.147|:80… connected. …

Read more

How to check reboots history in Linux

As Unix / Linux server administrator, we always need to know when is our last rebooted date and time. Actually, we are able to list out the system rebooted history by issue following command. last reboot Output mkyong@mkyong:~$ last reboot reboot system boot 2.6.28-11-generi Thu Jul 16 21:42 – 23:46 (02:04) reboot system boot 2.6.28-11-generi …

Read more

How to Limit the application CPU usage in Linux (CPUlimit)

CPULimit is a simple program to limit the CPU usage of certain application in Linux. It’s reside in the Ubuntu repositories by default. We can install it by issue the following command in Ubuntu sudo apt-get install cpulimit Output mkyong@mkyong:~$ sudo apt-get install cpulimit [sudo] password for mkyong: Reading package lists… Done Building dependency tree …

Read more

How to know the Hardware Details in Linux

The “dmidecode” is a handy tool in Linux to display the hardware specification detail. For example, memory, processor , BIOS and etc. man dmidecode DMI TYPES The SMBIOS specification defines the following DMI types: Type Information —————————————- 0 BIOS 1 System 2 Base Board 3 Chassis 4 Processor 5 Memory Controller 6 Memory Module 7 …

Read more

How to set static IP address on Unix

In Unix system like Debian, Ubuntu or Red Hat, It is possible to set a static IP address with ifconfig command. My current Debian system IP address is 10.70.0.61 mkyong:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:15:17:1D:CE:2F inet addr:10.70.0.61 Bcast:10.70.3.255 Mask:255.255.252.0 I want change it to 10.70.0.66, just issue following command to set a static IP …

Read more

How to check Linux / Unix distribution version

Today my boss ask me install a tomcat in linux machine. After i ssh into that machine, i wonder what is the Linux distribution version? Red Hat? Ubuntu? Fedora? Debian? However with a simple command, i can check what is linux distribution version mymachine:~# cat /proc/version Linux version 2.6.18-5-686-bigmem (Debian 2.6.18.dfsg.1-13etch3) ([email protected]) (gcc version 4.1.2 …

Read more

How to copy Entire Directory in Linux

Command is simple, here i provide two samples to show how to copy entire directory in linux. cp -r sourcedir targetdir for instance, 1) Copy anything from current directory to /usr/local/download cp -r * /usr/local/download 2) Copy whole directory (include content) /usr/local/fromdownload to target /usr/local/download cp -r /usr/local/fromdownload /usr/local/download

Open Browser in Java windows or Linux

A very useful Java code, to open a web browser from Java application in windows or Linux. package com.mkyong; public class StartBrowser { public static void main(String args[]) { String url = "http://www.google.com"; String os = System.getProperty("os.name").toLowerCase(); Runtime rt = Runtime.getRuntime(); try{ if (os.indexOf( "win" ) >= 0) { // this doesn’t support showing urls …

Read more

Fedora Password is Strong !!!

Fedora you are strong !!! Here i share a bit funny stuff, regarding when i reset my postgres user password in fedora core 8. Please view below picture. Actually i just want to set a easy remember password for user postgres. However i unable to do it. First i enter password as “password” Fedora : …

Read more

How to find large file size on linux

Often time, you may need to know which file contains large file size, and delete it to save space. Here’s a code pattern to show you how to find large file size on Linux : find {directory} -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 ": " $5 }’ …

Read more

How to install java jdk on fedora core (linux)

How to install java jdk on fedora core? here i provide few steps to demonstrate how it’s work. Installation Setup 1 ) Please visit sun java website to download any java jdk version you like. http://java.sun.com/javase/downloads/index.jsp 2 ) Click download, select Linux platform, language and accept license and continue. 3 ) Select “Linux RPM in …

Read more