Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, November 7, 2013

How to remove a Raid Interface

If you are unsure about your raid volumes:
# mdadm --detail /dev/md1
 
or to get your different md's
# cat /proc/mdstat
 
To remove an existing RAID device, first deactivate it by running the following command as root:
# mdadm --stop raid_device  
 
Once deactivated, remove the RAID device itself: 
# mdadm --remove raid_device
 
Finally, zero superblocks on all devices that were associated with the particular array: 
# mdadm --zero-superblock component_device
 
Example Removing a RAID device
Assume the system has an active RAID device, /dev/md3, with the following layout:
# mdadm --detail /dev/md3 | tail -n 4
    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       2       8       33        2      active sync   /dev/sdc1
In order to remove this device, first stop it by typing the following at a shell prompt:
# mdadm --stop /dev/md3
mdadm: stopped /dev/md3
Once stopped, you can remove the /dev/md3 device by running the following command:
# mdadm --remove /dev/md3
Finally, to remove the superblocks from all associated devices, type: 
# mdadm --zero-superblock /dev/sda1 /dev/sdb1 /dev/sdc1

Sunday, June 30, 2013

Centos 6.4 and Google Chrome 28 update

Centos seeems not to support the new updates from Google Chrome. The Problem is libstdc++.so.6 which isn't available on centos 6.

There are some options for this issue:

Just keep running the old version until centos 7 is ready and disable update issue:

go to /etc/yum.repos.d/google-chrome.repo set enabled=0 will disable it and stop the failures.

Install Chromium Browser (with Pepper Flash plugin and Chrome PDF viewer plugin) on CentOS 6 / Red Hat (RHEL) 6.

1.Change root user 

2. Install/enable hughesjr Chromium EL 6 repository
cd /etc/yum.repos.d
wget http://people.centos.org/hughesjr/chromium/6/chromium-el6.repo

3. Install Chromium Browser on CentOS 6 / RHEL 6
yum install chromium

4. Install Pepper Flash Player on Chromium Note: this is optional step and you will need 200-250 Mb temporary disk space.
4.1 Get hughesjr Helper Script
cd /tmp wget https://raw.github.com/hughesjr/chromium_el_builder/master/chrome_pepperflash_copy.sh
4.2 Make chrome_pepperflash_copy.sh Executable
chmod +x chrome_pepperflash_copy.sh
4.3 Install Pepper Flash on Chromium
./chrome_pepperflash_copy.sh
This will take a while, it downloads Google Chrome and extracts Pepper Flash plugin to /opt/chromium and modify Chromium launcher.

5. Install Google Chrome PDF Viewer Plugin on Chromium Note: this is optional step and you will need 200-250 Mb temporary disk space.
5.1 Get hughesjr Helper Script
cd /tmp
wget https://raw.github.com/hughesjr/chromium_el_builder/master/chrome_libpdf_copy.sh
5.2 Make chrome_libpdf_copy.sh Executable
chmod +x chrome_libpdf_copy.sh
5.3 Install Google Chrome PDF Viewer Plugin on Chromium ./chrome_libpdf_copy.sh  

Tuesday, November 13, 2012

Centos - Installing graphical X Window System (Boot Options, startx from command line)

Installing GUI

Installing the Graphical Window System (X.org-X11) and the Default Desktop Environment on CentOS 6

Performing the default "Minimal" install of CentOS 6 does not install the graphical subsystem (the X.org server) and the desktop environment (e.g. GNOME or KDE). Such OS install is nice for building an optimal system from scratch, setting up a headless server (no monitor, keyboard and mouse) and other purposes; but for one reason or another, you may still require a graphical user interface (GUI). This tutorial will show you how to install and start the graphical window system and the desktop environment of your choice.

To achieve the task, you will need to install the following package groups (groups of packages combined for a common purpose): "X Window System", "Desktop", "Fonts" and "General Purpose Desktop" (last two are optional). This will install about 500 additional packages on your system (~250MB download, or you may use the available OS installation DVD to retrieve packages).

Code:
yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
(Please enter this as is - package group names as well as package names are case sensitive).

Previous versions of RHEL and its derivatives provided a package group called "GNOME Desktop Environment", that was sufficient for a general purpose GNOME desktop. Currently, package group "Desktop" installs all critical components of GNOME, including gdm (the GNOME Display Manager), plus a few additional packages; enough to provide a minimalist GNOME desktop with mouse support, a graphical file manager, copy/paste functionality and the luxurious GNOME Terminal emulator - maybe just what you need. Thus, installing the "General Purpose Desktop" package group is optional, but will help you mimic the system you would probably get if you where to include the default graphical desktop during OS install. Alternatively, you can chose a single package group "KDE Desktop", for a general purpose KDE Software Compilation.

It is generally recommended to install the "Fonts" package group to improve usability of the GUI, no matter what desktop environment you choose to install.

You may view the complete list of available package groups by issuing:



Code:
yum grouplist
You may review the contents of each package group by entering:

Code:
yum groupinfo "Name of the Package Group"


Enabling booting into GUI - start GUI from command line

To boot directly into GUI, you will need to manually change the runlevel of the system from 3 (full multiuser environment with networking) to 5 (the same as mode 3 + X11), by changing the line "id:3:initdefault:" to "id:5:initdefault:" in /etc/inittab file. Or you can manually start X.org from console, by entering "startx" (without quotes).

Upon installation and subsequent reboot, you will be presented with the "Setup Agent" interface (even if you choose to stay in runlevel 3, you will see the text user interface of this tool - hence, the options provided will be different from the graphical variant). This is due to package "firstboot" being automatically installed by the "X Window System" package group and can be a handy way to setup a freshly installed system. All steps in "Setup Agent" are optional, so you can just skim through them, skipping any. Though, creating a new normal user on a freshly installed system is done best through this graphical tool, as it helps automatically create the new user and associate it with groups (such as the "video" group) appropriate for everyday use in a GUI environment . 


If you have installed the X Window System but are not seeing a graphical desktop environment once you log into your Red Hat Enterprise Linux system, you can start the X Window System graphical interface using the command startx.
Once you enter this command and press Enter, the graphical desktop environment is displayed.
Note, however, that this is just a one-time fix and does not change the log in process for future log ins.
To set up your system so that you can log in at a graphical login screen, you must edit one file,/etc/inittab, by changing just one number in the runlevel section. When you are finished, reboot the computer. The next time you log in, you are presented with a graphical login prompt.
Open a shell prompt. If you are in your user account, become root by typing the su command.
Now, type gedit /etc/inittab to edit the file with gedit. The file /etc/inittab opens. Within the first screen, a section of the file which looks like the following appears:
# Default runlevel. The runlevels used by RHS are: 
#   0 - halt (Do NOT set initdefault to this) 
#   1 - Single user mode 
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking) 
#   3 - Full multiuser mode 
#   4 - unused 
#   5 - X11 
#   6 - reboot (Do NOT set initdefault to this) 
#  id:3:initdefault:
To change from a console to a graphical login, you should change the number in the lineid:3:initdefault: from a 3 to a 5.

Warning

Change only the number of the default runlevel from 3 to 5.
Your changed line should look like the following:
  id:5:initdefault: 
When you are satisfied with your change, save and exit the file using the Ctrl-Q keys. A window appears and asks if you would like to save the changes. Click Save.

Sunday, August 19, 2012

Install and run NTP on Centos

Having an accurate clock on your system is usually important. It ensures the time stamps in emails sent from the machine are correct, and it is especially helpful when you need to look at the logs from a particular time of day.

Network time protocol

That's where the network time protocol (NTP) comes in. NTP lets you automatically sync your system time with a remote server. Setting up an NTP server to regularly adjust your machine's clock is pretty easy by default. It's also possible to make it a bit more complicated if you need your clock accurate down to the millisecond instead of just to the second.

Install

The first thing to do is install the NTP server.
Grab the package by running:
sudo yum install ntp

Once it's installed you can ensure the service will run at boot time by running:
sudo /sbin/chkconfig ntpd on

Start the service
To make sure the NTP service starts after installing it, run:
sudo /etc/init.d/ntpd start

As is usual for Linux services, you can stop or restart the NTP service by running the above command with "stop" or "restart" sent as the argument instead of "start".
Your system time is now served by NTP.

Fine Tuning

The ntp.conf file.The NTP configuration file can be found at:

/etc/ntp.conf

There are a few settings that can be changed in there, but for most people the only settings of interest would be any "server" entries.
The default for CentOS looks like:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

With more than one "server" entry your NTP server will query all servers and only select a time that a majority of the polled servers will agree on. This basically means that with three or more servers your clock will be more accurate than if it just uses one. If you add the "iburst" option after the server address it can speed up the NTP time sync by a bit. It's usually a good idea to use it, but not essential.

Further Reading:
ntp.org

Wednesday, November 9, 2011

Creating a Virtual Host with Webmin

These instructions apply to Webmin version 1.570 and Ubuntu 10.04
  1. Create a folder where you wish to store your sites files. 
    • You can do this in the Others > File Manager section. 
    • In this example we use: /var/www/vhosts/domainname.com/http/
  2. Setup the vhost.
    • Click on Servers > Apache Web Server in the left hand menu.
    • Click the “create virtual host” tab.
    • You can leave most settings as their default values, but you should fill out the following:
      • Port: Generally, you’ll want to use port 80.
      • Document Root: This is folder where you site’s files will be stored. Pick the folder you created in step 1.
      • Server name: This is just your site’s domain name, e.g. domainname.com (leave out the www.)
    • Click “Create Now”
  3. Add a server alias for www.domainname.com 
    • Click on the “Existing Virtual Hosts” tab in Servers > Apache Web Server.
    • Click the virtual server you just created.
    • Click on “Networking and Addresses”
    • In the “Alternate Virtual Server Names” box, add any additional server aliases you want to use for this site, such as www.domainname.com
    • Press “Save”.
  4. Click “Apply Changes” to get Webmin to restart Apache.
  5. vi /etc/apache2/sites-enabled/000-default and add:   NameVirtualHost *

Sunday, October 23, 2011

How to generate an SSH key with Linux?


You can generate a SSH key in Linux using the ssh-keygen command. You should run it in the command line. You will be asked for a file in which the key should be saved to and for a passphrase (password) for the key:

user@localhost: ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_dsa.
Your public key has been saved in id_dsa.pub.
The key fingerprint is:
16:8e:e8:f2:1d:c9:b9:cf:43:9a:b3:3c:c1:1f:95:93 user@localhost

This will create a private key written to /home/user/.ssh/id_dsa and a public key written to/home/user/.ssh/id_dsa.pub. The passphrase is used to protect your key. You will be asked for it when you connect via SSH.

Sunday, September 4, 2011

yum update - skip broken

Skip broken:

Skip broken is a feature in yum to skip packages from the transaction there have dependecy problems or introduce problems to the installed packages

Usage:

add the '--skip-broken' option to the yum command line to activate the skip broken feature.

yum update --skip-broken

Tuesday, August 30, 2011

Update ubuntu via command line

sudo apt-get update
sudo apt-get dist-upgrade

Which Linux Version, which Kernel version i am running?

To find out what version of Linux (distro) you are running, enter the following command at the shell prompt:
$ cat /etc/*-release
Sample output on RHEL 5:

Red Hat Enterprise Linux Server release 5 (Tikanga)

Sample outputs on Ubuntu v7.10:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"

lsb_release Command

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:
$ lsb_release -a

Sample outputs:

No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.1 (squeeze)
Release: 6.0.1
Codename: squeeze

How Do I Find Out My Kernel Version?

Type the following command:
$ uname -mrs

Sample outputs:

Linux 2.6.32-5-amd64 x86_64

Friday, July 15, 2011

Mobile internet bob.at and Linux

These are the network settings which should work for the austrian mobile internet provider bob.at:


profil name: data.bob
number: *99#
Benutzername: data@bob.at
password: ppp

APN: bob.at
authentication protocol: CHAP and/or PAP

DNS: dynamic
APN und erweiterte Einstellungen: static
IP: dynamic
WINS: dynamic 

Tuesday, June 7, 2011

AWS EC2 mail with SendGrid

mail is a beast. Sending email is easy but getting it pass spam filters when you’re a legitimate service is rather hard. Sending good email is especially hard when on EC2. The reason is due to spammers using and abusing elastic IPS. So, for startups your best bet of sending out a lot of email and getting it to the user is to use a service. You can pick Sendgrid. It’s cheap, fast, has good email tracking and builds all the appropriate email headers to get the mail white listed and into the destinations inbox. Sendgrid is the sender (think of them as an extension to sendmail).

New signups will usually get activated in less than four hours and then you simply add your username/password to the Postfix installation by editing the main.cf file.

First install postfix:

In Ubuntu, or any other apt using Linux distro, type in:

sudo apt-get install postfix

or if your system uses yum:

yum install postfix



Next choice your type of mail configuration: “Internet with Smarthost”.



From there, it’ll ask you questions that are entirely up to you.

It’s going to ask you for the smarthost address. Since we’re using SendGrid, use

smtp.sendgrid.net




Second edit the main.cf file:

Type in

sudo pico /etc/postfix/main.cf
or
sudo vi /etc/postfix/main.cf
to prepare the main.cf file

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:yourSendgridUsername:yourSendgridPassword
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

Replace yourSendgridUsername and yourSendgridPassword with your username and password.

sudo service postfix restart


Signup for SendGrid here

Tuesday, May 3, 2011

How to restart my-sql-Server


Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).
Login as root user. Now type the following command as per your Linux distro:

A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
/etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start
# service mysqld stop
# service mysqld restart

(B) If you are using mysql on Debian / Ubuntu Linux then use following command:

* To start mysql server:
/etc/init.d/mysql start
* To stop mysql server:
/etc/init.d/mysql stop
* To restart mysql server
/etc/init.d/mysql restart

Tuesday, April 19, 2011

Accessing SSH on a non-standard port via the command line

vento> ssh -p 6896 targetserver
 
or special directory: 
vento> ssh -p 6896 user@targetserver 

Sunday, April 17, 2011

Howto disable recursive DNS queries

Recursive DNS queries occur when a DNS client requests information from a DNS server that is set to query subsequent DNS servers until a definitive answer is returned to the client. The queries made to subsequent DNS servers from the first DNS server are iterative queries.
Thus keeping recursive query can lead to  unauthorized use of resources and DOS attacks.

To disable Recursive DNS follow the steps:
1) SSH server as root and edit file /etc/named.conf
root@server[~]#vi /etc/named.conf
2) add line recursion no; in options clause and it will look something like.
options {
directory “/var/named”;
dump-file “/var/named/data/cache_dump.db”;
statistics-file “/var/named/data/named_stats.txt”;
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below.  Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
recursion no;
};
3) Now restart or reload named service.
root@server[~]#/etc/init.d/named reload

Thursday, April 7, 2011

Install MySql on Centos 5.5

Install:
yum install mysql-server


Start:
service mysqld start OR /etc/init.d/mysqld start


Secure it:
/usr/bin/mysql_secure_installation

It is going to ask you handful of questions:

Current Root Password

You will be asked for your current root password. Because this is a new installation it is set to none. Press enter.

Set Root Password

If the above step worked correctly you should be prompted with a question asking you if you would like to set your root password. Please press Y and press Enter.

You will be asked for your root password twice. If it works you will see Success!

Removing Anonymous Users

You will be prompted to remove the MySQL anonymous users. For security reasons we want to do this. The text above the question explains this topic in more detail. Press Y and then Enter.

Disallow Root Login

You will be asked if you would like to disallow remote login for the root user and only allow connections from the server itself. To keep our server secure you want to say Y and press Enter.

Delete test Database

MySQL ships with a default database called test. This is not needed and can be deleted. Press Y and then Enter to delete the test database and it’s associated users.

Reload Privilege Tables

This step will reload the user settings (called privilege tables) so all user changes will take effect. Press Y and then Enter to continue.

Tuesday, April 5, 2011

httpd restart - start - stop

to restart:

/sbin/service httpd restart

to start:

/sbin/service httpd start

to stop:

/sbin/service httpd stop