Skip to content

Archive for

22
May

Mount a file sistem over ssh using fuse-sshfs

If you want to mount a resource via ssh from a remote machine to a directory on your CentOS server you can use sshfs.

First let’s install sshfs package:

yum install sshfs

Then mount the resource via ssh with the following command:

sshfs root@10.0.0.10:/ /mnt/hdd1

Where 10.0.0.10 is the remote machine.

If your ssh server runs on other port, then you must use the following command:

sshfs -p 2223 -C root@10.0.0.10:/ /mnt/hdd1

If you want your system to re-mount the resource is case the client is disconnected from the server, you can set reconnect flag when mounting the resource:

sshfs -o reconnect root@10.0.0.10:/ /mnt/hdd1
22
May

Change MAC of a network card on CentOS Linux

In order to change the MAC address of a network card on CentOS Linux edit the following file /etc/sysconfig/network-scripts/ifcfg-eth0 and add a line like this:

MACADDR=00:00:20:A0:00:11

Your complete ifcfg-eth0 file might look like this:

DEVICE=eth0
HWADDR=08:00:27:B0:66:26
MACADDR=00:00:20:A0:00:11
TYPE=Ethernet
UUID=d30c8443-148f-4f28-bdc2-4c49529c00f0
ONBOOT=YES
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=10.0.0.162
NETMASK=255.255.255.0
GATEWAY=10.0.0.1
DNS1=10.0.0.1
DEFROUTE=YES
IPV4_FAILURE_FATAL=no
IPV6INIT=NO

Then if you don’t want to reboot your CentOS machine, restart network services in order for your mac address to change:

service network restart

Note that you must have both HWADDR and MACADDR lines. Don’t change HWADDR to new MAC because it will not work.

21
May

Remove a Package from Ubuntu Linux

Let’s say we want to remove htop package from our Ubuntu machine. In order to do that we will use apt-get package manager:

apt-get purge htop

Of course this will work for apps installed using apt-get.

21
May

Sync CentOS Time periodically using ntpdate

If we want to sync time of a CentOS Server we can use ntp service or you can run ntpdate periodically using cron service.

In order to use cron service we will add the following line using cron -e command.

cron -e
 
*/15 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1

This will run ntpdate every 15 minutes. If you do not have ntpdate installed, just add it to your system using yum package manager:

yum install ntpdate
21
May

Configure NTP Service in CentOS Linux

In order to configure NTP service in CentOS Linux first we will install ntp package using yum:

yum install ntp
14
May

Change Timezon in CentOS 6 Linux

To change the timezone in CentOS 6.6 Linux choose a timezone from /usr/share/zoneinfo:

ls /usr/share/zoneinfo
ls /usr/share/zoneinfo/Europe

You will get something like this:

Amsterdam  Belgrade    Bucharest  Copenhagen  Helsinki     Kaliningrad  London      Mariehamn  Nicosia    Prague  San_Marino  Sofia      Tiraspol  Vienna     Zagreb
Andorra    Berlin      Budapest   Dublin      Isle_of_Man  Kiev         Luxembourg  Minsk      Oslo       Riga    Sarajevo    Stockholm  Uzhgorod  Vilnius    Zaporozhye
Athens     Bratislava  Busingen   Gibraltar   Istanbul     Lisbon       Madrid      Monaco     Paris      Rome    Simferopol  Tallinn    Vaduz     Volgograd  Zurich
Belfast    Brussels    Chisinau   Guernsey    Jersey       Ljubljana    Malta       Moscow     Podgorica  Samara  Skopje      Tirane     Vatican   Warsaw

Then we’ll remove old timezone file:

rm /etc/localtime

Create a symlink to the chosen zonefile:

ln -s /usr/share/zoneinfo/Europe/Madrid /etc/localtime
12
May

Install NTPDate Client in CentOS Linux

To install ntpdate client that is used to sync time in CentOS Linux just run:

yum install ntpdate

To sync time run:

ntpdate pool.ntp.org

You might also want to run ntpd service.

12
May

Search for a specific binary in CentOS packages

To see a list of packages that install a specific binary in CentOS we run yum provides:

yum provides "*/ntpd"

The output is:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.23media.de
 * epel: mirrors.n-ix.net
 * extras: ftp.plusline.de
 * updates: ftp.plusline.de
base/filelists_db                                                                                                                            | 6.1 MB     00:00
epel/filelists_db                                                                                                                            | 9.5 MB     00:00
extras/filelists_db                                                                                                                          |  31 kB     00:00
updates/filelists_db                                                                                                                         | 2.2 MB     00:00
ntp-4.2.6p5-1.el6.centos.x86_64 : The NTP daemon and utilities
Repo        : base
Matched from:
Filename    : /etc/sysconfig/ntpd
Filename    : /etc/rc.d/init.d/ntpd
Filename    : /usr/sbin/ntpd
 
 
 
ntp-4.2.6p5-2.el6.centos.x86_64 : The NTP daemon and utilities
Repo        : updates
Matched from:
Filename    : /etc/sysconfig/ntpd
Filename    : /etc/rc.d/init.d/ntpd
Filename    : /usr/sbin/ntpd
 
 
 
ntp-4.2.6p5-3.el6.centos.x86_64 : The NTP daemon and utilities
Repo        : updates
Matched from:
Filename    : /etc/sysconfig/ntpd
Filename    : /etc/rc.d/init.d/ntpd
Filename    : /usr/sbin/ntpd
6
May

Install a Package in Ubuntu Linux

To install a package on Ubuntu Linux we will use apt-get command. Let’s say we want to install package mc:

sudo apt-get install mc

If we want to install multiple package we will separate them by space:

sudo apt-get install mc htop
6
May

Search for a package in available packages to be install on Ubuntu Linux

Let’s say I want to install a package on Ubuntu Linux but I don’t know if it is available from Ubuntu’s repository.

To search for a package run:

apt-cache search nginx

Read more »