Tag Archives: Linux

Configure FTP server on Linux and create user to access only his home directory

Now i’ll show you how to configure ftp server on oracle linux 5.5 and create user, which can access only his home directory for using ftp, let start.
first we need to install rpm package which is on linux disc. you can mount disk and install package
vsftpd-2.0.5-16.el5_4.1 with command:

rpm -Uvh vsftpd-2.0.5-16.el5_4.1.rpm

after that we need to start ftp server with command:

service vsftpd start

now our ftp server is running.
let’s create user ftpdump which can access only his home directory for file transfer.

mkdir -p /ftp
groupadd ftpdump
useradd –s /bin/bash –d /ftp –g ftpdump ftpdump
passwd ftpdump
chown -R ftpdump:ftpdump /ftp
chmod -R 777 /ftp 

for limit user ftpdump to access only his home directory open vsftpd.conf and add next parameters:

vi /etc/vsftpd/vsftpd.conf


Then add each user you want to lock to their home directory to the chroot.
I want that ftpdump user access only his home dir, hence i added it in chroot.list

vi /etc/vsftpd/chroot.list


now we can make test, connect ftp with user ftpdump and try to change directory.

C:\Users\user>ftp #.#.#.#
Connected to #.#.#.#.
220 (vsFTPd 2.0.5)
User (#.#.#.#:(none)): ftpdump
331 Please specify the password.
230 Login successful.
ftp> pwd
257 "/"
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
ftp: 111 bytes received in 0.00Seconds 111000.00Kbytes/sec.
ftp> pwd
257 "/"
ftp> cd /u01
550 Failed to change directory.

that’s all, good luck.

Automatically start oracle database on linux after server reboot

Here i show you how to configure system for automatically start oracle database after server reboot.
oracle database 11g — Oracle Linux 6.3
First of all, you need to make sure that any database instances you want to auto start are set to “Y” in the /etc/oratab file

# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
# Entries are of the form:
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
# Multiple entries with the same $ORACLE_SID are not allowed.

Oracle 11g includes 2 scripts which can be used to start or shut down Oracle databases on Linux. Both scripts are in $ORACLE_HOME/bin and called dbstart and dbshut. We can add some more actions for example start enterprise manager if we create our scripts. Let’s make two scripts db_start.sh and db_stop.sh
vi /u0/app/oracle/db_start.sh

# script to start the Oracle database, listener and dbconsole
. ~/.bash_profile
# start the listener and the database
# start the Enterprise Manager db console
$ORACLE_HOME/bin/emctl start dbconsole
exit 0

vi /u0/app/oracle/db_stop.sh

# script to stop the Oracle database, listener and dbconsole
. ~/.bash_profile
# stop the Enterprise Manager db console
$ORACLE_HOME/bin/emctl stop dbconsole
# stop the listener and the database
exit 0

inside script we are calling the .bash_profile file of the user “oracle” for export environment variables, we need it for $ORACLE_HOME.
give execute right:
chmod u+x db_start.sh db_stop.sh
With user root, create a file called “oracle” under /etc/init.d
vi /etc/init.d/oracle

case "$1" in
        # Start the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/db_start.sh"
        touch /var/lock/subsys/oracle
        # Stop the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/db_stop.sh"
        rm -f /var/lock/subsys/oracle
        echo $"Usage: $0 {start|stop}"
exit $RETVAL

change permission for /etc/init.d/oracle file:
chmod 750 /etc/init.d/oracle
to create service of this script:

chkconfig --add oracle

and now we can start and stop database with:

service oracle stop
service oracle stop

Now it’s time to test our automatically startup procedure, for this reboot your server and check if your database starts automatically after reboot.

Change network device name from eth1 back to eth0 in RHEL6

The interface name of a network device increases if the mac address of the physical or virtual network card changes. A common case is if you made a clone of a virtual machine for example via VMware or replaced a physical network card in a non virtualized server.

If it’s a RHEL 6 machine you need to change 2 files to rename the interface for example from eth1 back to eth0.

One file is the udev rule for network devices which is located here:


Copy the new mac address to the line of your eth0 rule and delete the new rule for eth1.

    # PCI device 0x15ad:0x07b0 (vmxnet3)
    SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:b2:23:e0″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

Modify the network configuration located under:


and replace the old ip with the new one and the old mac address with the new mac address, after that restart network service.

# service network restart

To be sure everything works fine reboot your machine.

How to Change the Hostname of a Linux System

Normally we will set the hostname of a system during the installation process. but if we need to change hostname what can we do?

On any Linux system you can change its hostname with the command
hostname new_name.

[oracle@oel6 ~]$ hostname
[oracle@oel6 ~]$ hostname aaa
hostname: you must be root to change the host name
[oracle@oel6 ~]$ su - 
[root@oel6 ~]# hostname aaa
[root@oel6 ~]# hostname

This new name will be until the system rebooted. To permanent change in Red Hat base systems we need to change hostname in /etc/sysconfig/network file.

[root@oel6 ~]# vi /etc/sysconfig/network


and change hostname in file.

that’s all.

Bug: /dev/shm does not use /etc/fstab attributes after reboot in RHEL 6

There is a bug in Red Hat Linux 6 and Oracle Enterprise Linux 6 (UEK and RHEL-kernel).
When you need more memory for SGA/PGA when using MEMORY_MAX_TARGET, you need to resize /dev/shm. By default this is 50% of total memory and Oracle tells you to add the following to /etc/fstab:

tmpfs    /dev/shm     tmpfs   defaults,size=3G  0 0

This works after a remount:

mount -o remount /dev/shm

but it doesn’t work after a reboot.

mount -o remount /dev/shm

in /etc/rc.d/rc.sysinit file and /dev/shm has attributes from /etc/fstab after reboot.

ORA-00845: MEMORY_TARGET not supported on this system

SQL> startup nomount;
ORA-00845: MEMORY_TARGET not supported on this system

This error comes up because we tried to use the Automatic Memory Management (AMM) feature of Oracle 11g R2. But it seems that your shared memory filesystem (shmfs) is not big enough.

[oracle@oel6 ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
                       43G   15G   26G  37% /
tmpfs                1001M  212M  789M  22% /dev/shm
/dev/sda1             485M   55M  405M  12% /boot
.host:/               245G  126G  119G  52% /mnt/hgfs

We can change the size of that filesystem by issuing the following command:

mount -t tmpfs shmfs -o size=2g /dev/shm

The shared memory file system should be big enough to accommodate the MEMORY_TARGET and MEMORY_MAX_TARGET values, or Oracle will throw the ORA-00845 error. Note that when changing something with the mount command, the changes are not permanent.
To make the change persistent, edit your /etc/fstab file

tmpfs                   /dev/shm                tmpfs   defaults,size=2G         0 0

Now go and enjoy your automatically managed memory configuration!

increase disk size in oracle linux on vmware

Here is video of these procedures

First of all our vmware guest operating system must be in shutdown mode.
we need to add hard disk to our box.
go to settings—>
click add, then choose hard disk.
check option use an existing virtual disk
then choose file which will expand.
add a new hard disk, go to settings and choose our disk, click utilities–expand and write new size.
power on virtual machine.

our guest system doesn’t see a new size
but fdisk shows  the new size

solution :
create new partition on /dev/sda

[root@oel6 ~]# pvcreate /dev/sda3
  Writing physical volume data to disk "/dev/sda3"
  Physical volume "/dev/sda3" successfully created
[root@oel6 ~]# vgextend vg_oel6 /dev/sda3
  Volume group "vg_oel6" successfully extended
[root@oel6 ~]# lvextend -L +18G /dev/vg_oel6/lv_root /dev/sda3  
  Extending logical volume lv_root to 43.60 GiB
  Logical volume lv_root successfully resized
[root@oel6 ~]# resize2fs /dev/mapper/vg_oel6-lv_root 43G
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_oel6-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/vg_oel6-lv_root to 11272192 (4k) blocks.
The filesystem on /dev/mapper/vg_oel6-lv_root is now 11272192 blocks long.

check size :

it’s all, enjoy with new size 🙂

How To Resize /dev/shm Filesystem In Linux?

1) Open /etc/fstab with vi or any text editor of your choice
2) Locate the line of /dev/shm and use the tmpfs size option to specify your expected size

tmpfs /dev/shm tmpfs defaults,size=1500m 0 0



tmpfs /dev/shm tmpfs defaults,size=2g 0 0

3) To make change effective immediately, run this mount command to remount the /dev/shm filesystem:

mount -o remount /dev/shm

that’s all.

Scheduling tasks in linux for automating with crontab

Cron is the time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration.
crontab commands:

crontab -e      Edit your crontab file, or create one if it doesn’t already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file. 
                (This option is only available on a few systems.)

A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)


min 	hour 	day/month    month    day/week  Execution time
30 	0 	1 	    1,6,12 	* 	– 00:30 Hrs  on 1st of Jan, June & Dec.
0 	20 	* 	      10       1-5 	– 8.00 PM every weekday (Mon-Fri) only in Oct.
0 	0 	1,10,15       * 	* 	– midnight on 1st ,10th & 15th of month
5,10 	0 	10 	      * 	1 	– At 12.05,12.10 every Monday & on 10th of every month

create a cron job:

su - oracle
crontab -e
--add the following line :
00 13 * * * /u01/scripts/Incr0.sh

this script will run at 1:00 PM everyday.

after edit crontab file reload cron service

su - 
service crond reload

that’s all. 🙂