Showing posts with label os. Show all posts
Showing posts with label os. Show all posts

Thursday, November 13, 2014

LINUX BASIC COMMON COMMANDS

Filter result:


grep

ex: filter all processes and ports of java

ps -e | grep java
netstat -tunap | grep java

Process and infomation :


Information about process
$ls -l /proc/$PID/exe
OR
$ps -p PID -o comm=
OR
$cat /proc/PID/cmdline

Kill process
sudo kill -9 PID

User and Group:


Login
#su - {user-name}

Login as root
#su -

check username
#whoami

logout
#logout

Extract & Compress file:


Extract
#tar -zxvf {file.tar.gz}
#tar -xf {file.tar.gz} -C /target/directory
#tar -xzf backup.tar.gz -C /target/directory
#unzip file.zip -d destination_folder

Download
#wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz  -P /target/directory

Restating the network service:


To restart the network service under RHEL / CentOS based systems, enter:
service network restart
OR
/etc/init.d/network restart

Check linux kernel version number :


Open a shell prompt (or a terminal) and type the following command to see your current Linux kernel version:

uname -r

Or type the following command
uname -mrs

To print all information, enter

uname -a

Type the following command to see Linux version info

cat /proc/version

Find Distribution Version :


Type the following command

cat /etc/*release

OR
lsb_release -a

Port & Firewall :


Port and process command
netstat -tunap

If you want to open a single port

open iptables file
vi /etc/sysconfig/iptables

Add below line to open port.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT

For multiple, you can use the following instead (or repeat the above line multiple times):

-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 22,80,143 -j ACCEPT

service iptables save

Disable / Turn off Linux Firewall (Red hat/CentOS/Fedora Core)

Type the following two commands (you must login as the root user)

/etc/init.d/iptables save

/etc/init.d/iptables stop

Turn off firewall on boot

chkconfig iptables off

Enable / Turn on Linux Firewall (Red hat/CentOS/Fedora Core)

Type the following command to turn on iptables firewall

/etc/init.d/iptables start 

Turn on firewall on boot

chkconfig iptables on 

Linux / Unix - Checking Free Disk Space:


df command examples - to check free disk space

Type df -h or df -k to list free disk space

df -h

OR
df -k

Find Files and Folders in Linux :


find / -name "java" 

/: meaning is the root folder. hold systems
-name "java": all files have name is java.

Saturday, October 18, 2014

Restore grub2 after install windows

The problem is after you install linux and then you install a windows 

For example after install Ubuntu 9.10 and then I install Windows operating system along with Ubuntu. The windows will override Master Boot Record on Hard driver , so from now when your computer boot up, you only can see Windows.

To solve the problem:

We need to have a CD version of Ubuntu 9.10. Boot our PC with live mode of Ubuntu 9.10
.Open Terminal ( Applications  > Accessories > Terminal)

(We suppose that the Ubuntu already installed on  partition sda3 of sda)

sudo -i (change user to  root user).

mount /dev/sda3 /mnt

grub-install --root-directory=/mnt/ /dev/sda

mount --bind /proc /mnt/proc

mount --bind /dev /mnt/dev

mount --bind /sys /mnt/sys

chroot /mnt update-grub

umount /mnt/sys

umount /mnt/dev

umount /mnt/proc

exit

Reboot your computer and enjoy !

Setting Global Environment Variables in LINUX

The easiest way to set an environment variable in CentOS is to use export as in :

vanduc@VGN-FZ290E:~/Downloads$export JAVA_HOME=/usr/lib/java/jdk1.7.0_71

vanduc@VGN-FZ290E:~/Downloads$export PATH=$PATH:$JAVA_HOME

However, variables set in such a manner are transient i.e. they will disappear the moment you exit the shell. Obviously this is not helpful when setting environment variables that need to persist even when the system reboots.

In such cases, you need to set the variables within the system wide profile

In CentOS (I’m using v5.2), the folder /etc/profile.d/ is the recommended place to add customizations to the system profile.

For example, when installing the Sun JDK, you might need to set the JAVA_HOME and JRE_HOME environment variables. In this case:
Create a new file called java.sh

vanduc@VGN-FZ290E:~/Downloads$ sudo vi /etc/profile.d/java.sh

Within this file, initialize the necessary environment variables

export JAVA_HOME=/usr/lib/java/jdk1.7.0_71

export JRE_HOME=$JAVA_HOME/jre

export PATH=$PATH:$JRE_HOME/bin

export PATH=$PATH:$JAVA_HOME/bin


Now when you restart your machine, the environment variables within java.sh will be automatically initialized (checkout /etc/profile if you are curious how the files in /etc/profile.d/ are loaded) .

If you want to load the environment variables within java.sh without having to restart the machine, you can use the source command as in:

vanduc@VGN-FZ290E:~/Downloads$ source /etc/profile.d/java.sh


Test command:

vanduc@VGN-FZ290E:~/Downloads$ java -version

java version "1.7.0_71"

Java(TM) SE Runtime Environment (build 1.7.0_71-b14)

Java HotSpot(TM) Server VM (build 24.71-b01, mixed mode)

vanduc@VGN-FZ290E:~/Downloads$

P/S : some common commands use to setup java environment

vanduc@VGN-FZ290E:~/Downloads$ cd Downloads/
vanduc@VGN-FZ290E:~/Downloads$ ls
google-chrome-stable_current_i386.deb jdk-7u71-linux-i586.tar.gz sublime-text_build-3065_i386.deb
vanduc@VGN-FZ290E:~/Downloads$ tar -zxvf jdk-7u71-linux-i586.tar.gz
vanduc@VGN-FZ290E:~/Downloads$ sudo mkdir /usr/lib/java
vanduc@VGN-FZ290E:~/Downloads$ mv jdk1.7.0_71/ /usr/lib/java/


Tuesday, January 15, 2013

SET ENVIRONMENT COMMAND LINE WINDOW


Procedure for Building and Deploying the Application
The build files are present in the tutorial folders, so the steps you need to follow to build
and deploy the application are quite simple.
Note:
These instructions assume particular folder locations for Ant, Nexaweb
Platform, and the Java Developers Kit. On your PC, the locations may be
different.

  1. Open a command window.
  2. Make sure that the bin folder of the Ant installation is in your PATH.
    set PATH=%PATH%;C:\apache-ant-1.6.2\bin
  3. Make sure the .jar file containing the nexawebify Ant task is in your CLASSPATH.
    set CLASSPATH=%CLASSPATH%;C:\Program Files\Nexaweb\Nexaweb
    Platform 4.0\bin\nexaweb-platform-installer.jar
  4. Make sure the location of your Java Development Kit is specified in JAVA_HOME.
    set JAVA_HOME=C:\jdk1.3.1_09
  5. Navigate to the folder:
    cd C:\Program Files\Nexaweb\Nexaweb Platform 4.0\samples\tutorial1
  6. Run Ant specifying the target: dist.
    ant dist
    Ant will read through and process the instructions in build.xml and display progress
    messages for each step. In the final step, Ant will build the WAR file. If everything is
    OK, the final message is “BUILD SUCCESSFUL”.
  7. Copy the WAR file from tutorial1/dist to your servlet container.
  8. Follow the procedure for your servlet container to deploy a WAR file.

Note:
You can get a list of build targets and the default target by running:
ant -projecthelp

Tuesday, December 18, 2012

Cài đặt XAMMP trên LINUX với NOMAL USER

Bước 1 : Sau khi cài đặt chúng ta chuyển đến folder chứa LAMMP :

#cd /opt/lampp/

Liệt kê danh sách file trong thư mục gốc của LAMMP :


Nhiệm vụ được đặt ra là đổi nobody thành tên username của chúng ta :

Bước 2 : Cần phải xác định được username mà chúng ta đang sử dụng là gì :

#whoami

Xác định user-name đang sử dụng thuộc group nào :

#goups



như hình trên ta có user-name : vanduc1102 thuộc về 2 group là rootdb2iadm1

Bước 3: Cấp quyền sử dụng cho thư mục  htdocs


Bước 4 :

mở file httpd.conf trong /opt/lammp/etc/


# gedit /opt/lampp/etc/httpd.conf 



xem đoạn

User nobody

Group nogroup

</IfModule>

</IfModule>


Và đổi thành

User vanduc1102

Group nogroup

</IfModule>

</IfModule>




Khởi động lại lammp là ok .
#/opt/lammp/lammp start

Sunday, September 23, 2012

Best Torrent On Linux.


There is my opinions :this wrote by java.

This is VUZE :

here is link of VUZE : http://www.vuze.com/

just download Linux version , look like : Vuze_Installer.tar.bz2

uncompress it .and you got.



Remember . It is java program. So run it . You must installed java run time. JRE.
Hope this help.