Yum Cache Clear command

When a package is downloaded, installed and is removed there is a chance that the package may still be saved/stored in the yum’s cache. So to clean all the cached packages from the enabled repository cache directory, login as root and execute the following:

yum clean packages

To purge the old package information completely, execute the following command:

yum clean headers

To clean any cached xml metadata from any enabled repository, execute the following

yum clean metadata

If you wish to clean all the cached files from any enabled repository at once, execute the Following command:

yum clean all

Share

Set date/time permanently on Virtualbox Guest

First you need to ssh to the server and be root and then do these step by step:

1. Set the date/time as following format

date -s “2 OCT 2013 18:00:00″

2. Set the proper Timezone for your area-

# cd /etc
# ln -sf /usr/share/zoneinfo/EST localtime

3. Set it to the BIOS for permanent stamp-

# /sbin/hwclock –systohc

On Debian/Ubuntu sytem:

dpkg-reconfigure tzdata

BDST NTP Server:

bsti1.time.gov.bd
bsti2.time.gov.bd

Use tzdata on Centos System:

To use it first download the tzdata package from the repo.

$ sudo yum -y install tzdata
$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none – I want to specify the time zone using the Posix TZ format.
#?

Select a value and press the return key to proceed.

You will now be asked a country to select from the list provided.

Please select a country.
1) Aaland Islands 18) Greece 35) Norway
2) Albania 19) Guernsey 36) Poland
3) Andorra 20) Hungary 37) Portugal
4) Austria 21) Ireland 38) Romania
5) Belarus 22) Isle of Man 39) Russia
6) Belgium 23) Italy 40) San Marino
7) Bosnia & Herzegovina 24) Jersey 41) Serbia
8) Britain (UK) 25) Latvia 42) Slovakia
9) Bulgaria 26) Liechtenstein 43) Slovenia
10) Croatia 27) Lithuania 44) Spain
11) Czech Republic 28) Luxembourg 45) Sweden
12) Denmark 29) Macedonia 46) Switzerland
13) Estonia 30) Malta 47) Turkey
14) Finland 31) Moldova 48) Ukraine
15) France 32) Monaco 49) Vatican City
16) Germany 33) Montenegro
17) Gibraltar 34) Netherlands

Select and confirm the selection with 1 for Yes.

This completes the setup but to make it permanent you should add the following line to your ~/.bashrc file.

TZ=’Europe/London’; export TZ

Then log out and back in again.

The user can now log in and run the date command

$ date

Fri Jul 19 14:56:53 BST 20

On Centos 7

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to America/Toronto:

sudo timedatectl set-timezone America/Toronto

Run the timedatectl command to verify the changes:

timedatectl
Local time: Wed 2019-02-06 17:47:10 EST
Universal time: Wed 2019-02-06 22:47:10 UTC
RTC time: Wed 2019-02-06 22:47:10
Time zone: America/Toronto (EST, -0500)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2018-11-04 01:59:59 EDT
Sun 2018-11-04 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2019-03-10 01:59:59 EST
Sun 2019-03-10 03:00:00 EDT
Share

LAMP on CentOS

Installing MySQL 5

To install MySQL, we do this:

yum -y install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Set passwords for the MySQL root account:

Read more

Share

Reset root password in Centos/Redhat/SL linux

1. Boot the system and when you see the following message “Press any key to enter the menu”, press any key. (You will see the list of available kernel versions.)

2. Press e in order to edit commands before booting.

3. Highlight the list item with vmlinuz in it by using the arrow keys and press e.

4. Now type single or init 1 at the end of the line.

Read more

Share

Importing Big mysqldump with Progress Bar PV

I am using CentOS 6.4 box, so it requires me to install EPEL repo at the first place:

$ rpm -Uhv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install pv using yum:

$ yum install -y pv

Installation done. Let the importing begin!

$ pv /home/user/my_big_dump.sql | mysql -uroot -p

For Ubuntu/Debian distribution intall PV using-

apt-get install pv

 

Share

Installing Apache2, PHP5, MySQL and PHPMyadmin On Debian

First we install MySQL 5 like this:

apt-get install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user – this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <– yourrootsqlpassword
Repeat password for the MySQL "root" user: <– yourrootsqlpassword

3 Installing Apache2
Apache2 is available as a Debian package, therefore we can install it like this:

apt-get install apache2

Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page (It works!):

Read more

Share

Install VNCServer on Centos 5

Install VNC Server to operate CentOS with GUI remotely from Windows client. VNC is already installed if you already build Desktop Environment. If it's not installed, Install by a command 'yum -y install vnc-server'.

[root@ns ~]# yum -y install vnc-server

[root@ns ~]# vi /etc/sysconfig/vncservers

# line 20: make valid and set as '(diplay number):(user name)' like follwing example
VNCSERVERS="1:cent"

# line 21: uncomment and remove '-localhost' like below
# And set any screen resolution you like
VNCSERVERARGS[1]="-geometry 1024×768 -nolisten tcp -nohttpd"

[root@ns ~]# su – cent
[cent@ns ~]$ vncpasswd# set VNC password
Password:# input
Verify:# verify
[cent@ns ~]$ su –
Password:
[root@ns ~]# /etc/rc.d/init.d/vncserver start
Starting VNC server: 1:cent
New 'ns.server-linux.info:1 (cent)' desktop is ns.server-linux.info:1

Creating default startup script /home/cent/.vnc/xstartup
Starting applications specified in /home/cent/.vnc/xstartup
Log file is /home/cent/.vnc/ns.server-linux.info:1.log
[ OK ]
[root@ns ~]# vi /home/cent/.vnc/xstartup

# at the bottom: make it comment
#twm &

# run Ghome
exec gnome-session &

[root@ns ~]# /etc/rc.d/init.d/vncserver restart
Shutting down VNC server: 1:cent[ OK ]
Starting VNC server: 1:cent
New 'ns.server-linux.info:1 (cent)' desktop is ns.server-linux.info:1

Starting applications specified in /home/cent/.vnc/xstartup
Log file is /home/cent/.vnc/ns.server-linux.info:1.log

Read more

Share

.htaccess URL redirect

# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/

# This allows you to redirect your entire website to any other domain
Redirect 302 / http://mt-example.com/

# This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/

# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html

# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html

Share