22 февр. 2012 г.

Установка C, C++ в Ubuntu

Если вы разработчик и программируете на C или C++, то необходимо установить компилятор с помощью build-essentials:
# sudo aptitude install build-essential Установятся все необходимые пакеты для C и C++ компиляторов.

Проверим компилятор С:
# vi first.c #include <stdio.h>
int main ()
{
   printf("Hello, world\n");
   return 0;
}
Скомпилируем код с помощью следующей комманды: # cc -c first.c Это создаст объект, который вы можете добывить в библиотеку.
Затем создадим исполняемый файл: # cc -o first first.c Что бы запустить программу запишем следующее: # ./first Результатом должно быть: Hello, world
Проверим C++ компилятор:
Если вы хотите запустить программу C++, то необходимо использовать компилятор g++. Расширение должно быть .cpp.
Создадим файл: # vi first.cpp #include <iostream>
int main ()
{
   std::cout << "Hello world!" << std::endl;
   return 0;
}
Создадим исполняемый файл: # g++ first.cpp -o test Запускается программа точно так же как и в случае с С: # ./test Результат должен выглядеть так: Hello World!
Оба компилятоа установлены и работают.

9 февр. 2012 г.

Apache, php, mysql на CentOS

Задача:
Есть сервер CentOS с доступом по ssh. Необходимо установить apache, php, mysql со всеми обновлениями.
Для решения задачи используется только putty для подключения через ssh.

Вступление и подготовка
Для проверки работы apache и php установим консольный браузер lynx
# yum install lynx Если в системе нету файла hosts:
добавить его в /etc со следующим содержимым:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

8 февр. 2012 г.

Dropbox console for CentOS

How to install dropbox on your linux server (console mode)

1. Download http://www.getdropbox.com/download?plat=lnx.x86 or http://www.getdropbox.com/download?plat=lnx.x86_64

2. Extract tar.gz file downloaded and leave in root home folder

3. Run
~/.dropbox-dist/dropboxd to get Dropbox to provide a URL to go to in your browser to link this computer to your Dropbox account

4. After visiting the URL in a browser to which you've logged into dropbox.com, you'll see message smth like: Successfully linked etc.

4 февр. 2012 г.

Grub Customizer

Grub Customizer software is for editing the boot loader menu GRUB2


Grub Customizer - this is a new settings manager for GRUB2 on the GUI. At the moment it can: rename, reorder, remove, add or hide the menu items select the bootloader.
More interesting is the fact that even after reinstalling the crudest your changes do not disappear.

Grub Customizer is available through the Ubuntu PPA (Lucid and Maverick) # sudo add-apt-repository ppa: danielrichter2007/grub-customizer
# sudo apt-get update
# sudo apt-get
# install grub-customizer
It also supports BURG.

ERROR "sudo: sorry, you must have a tty to run sudo"

The reason for this is an update along the way with sudo locked it down further by adding the below line to /etc/sudoers configuration file. 1 Defaults requiretty To allow a remote script to login and run a command via sudo simply comment out that line as shown below. 1   # Commented out so remote script can login and run a command without a tty
2   # Defaults requiretty
If requiretty is set, sudo will only run when the user is logged in to a real tty. This will disallow things like 'rsh somehost sudo ls' since rsh does not allocate a tty; because it is not possible to turn off echo when there is no tty present.

Simple samba config

# vi /etc/samba/smb.conf

interfaces = lo eth1
bind interfaces only = true

security = share
...
...
guest account = nobody

[Guest Share]
& nbsp;       comment = Guest access share
        path = /path/to/dir/to/share
        browseable = yes
        read only = yes
        guest ok = yes

$ testparm

VSFTP Limit users to their home directory

Open vsftpd configuration file – /etc/vsftpd/vsftpd.conf # vi /etc/vsftpd/vsftpd.conf Made the Following changing in the File chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
chroot_local_user=YES
Save and close the file. Restart vsftpd. # /etc/init.d/vsftpd restart Now all users of VSFTPD/FTP will be limited to accessing only files in their own home directory.

They will not able to see /, /etc, /root and /tmp and all other directories.
This is an essential security feature.

HDD test speed

# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 3134 MB in 2.00 seconds = 1569.12 MB/sec
Timing buffered disk reads: 242 MB in 3.00 seconds = 80.55 MB/sec

# hdparm -tT /dev/sda
/dev/hda:
Timing cached reads: 176 MB in 2.00 seconds = 87.87 MB/sec
Timing buffered disk reads: 86 MB in 3.05 seconds = 28.16 MB/sec

# hdparm -tT /dev/sda
/dev/hdb:
Timing cached reads: 844 MB in 2.00 seconds = 421.50 MB/sec
Timing buffered disk reads: 116 MB in 3.01 seconds = 38.55 MB/sec

Installing phpMyAdmin

# cd /var/www/html
# wget http://files.directadmin.com/services/all/phpMyAdmin/phpMyAdmin-3.3.8.1-all-languages.tar.gz
# tar zxvf phpMyAdmin-3.3.8.1-all-languages.tar.gz
# rm -r -f phpMyAdmin-3.3.8.1-all-languages.tar.gz
# mv phpMyAdmin-3.3.8.1-all-languages phpmyadmin
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php
# vi config.inc.php

Recording Skype Calls in Linux

It wasn't so long ago that recording a Skype conversation in Linux was difficult, if not impossible. That's all changed, thanks to a great piece of Open Source software called Skype Call Recorder.

Skype Call Recorder is an open source tool that allows you to record your Skype calls on Linux. 

Current features include:

- Record calls to MP3, Ogg Vorbis or WAV files
- Automatic and manual recording
- Configure automatic recording on per-caller basis
- Split stereo recording
- Completely free (free as in free beer)
- Completely free (free as in freedom), released under the GNU GPL


Web Site: http://atdot.ch/scr/

SSH Port Forwarding (SSH Tunneling)

Syntax: # ssh -L localport:host:hostport user@ssh_server -N where:
-L - port forwarding parameters (see below)
localport - local port (chose a port that is not in use by other service)
host - server that has the port (hostport) that you want to forward
hostport - remote port
-N - do not execute a remote command, (you will not have the shell, see below)
user - user that have ssh access to the ssh server (computer)
ssh_server - the ssh server that will be used for forwarding/tunneling

Without the -N option you will have not only the forwardig port but also the remote shell. Try with and without it to see the difference.

How to setup a Linux VNC Server with KDE or Gnome

The default desktop for the VNC Server is "TWM", though most people are used to KDE or Gnome instead. Here is how to change it:

1. Edit ~/.vnc/xstartup
2. For KDE, replace "twm &" with "startkde &"
3. For Gnome, replace "twm &" with "exec gnome-session &"
4. Kill any existing VNC servers with "vncserver -kill :1" where 1 is the display number.
5. Start a new server.

How to export NFS share on Linux

To export a directory/NFS share from Linux you need to have nfs server installed and have nfs services running on your linux (Fedora/CentOS/RHEL) machine.

Checking NFS server status:
Check to see if you have NFS services running on your Linux machine: # ps -aef | grep nfsd
# root 13397 7 0 08:21 ? 00:00:00 [nfsd4]
# root 13398 1 0 08:21 ? 00:00:00 [nfsd]
# root 13399 1 0 08:21 ? 00:00:00 [nfsd]
# root 13400 1 0 08:21 ? 00:00:00 [nfsd]
# root 13401 1 0 08:21 ? 00:00:00 [nfsd]
# root 13402 1 0 08:21 ? 00:00:00 [nfsd]
# root 13403 1 0 08:21 ? 00:00:00 [nfsd]
# root 13404 1 0 08:21 ? 00:00:00 [nfsd]
# root 13405 1 0 08:21 ? 00:00:00 [nfsd]

Installing Webmin on CentOs 5

I just installed the latest version of webmin on my CentOs 5 server.
I have not used webmin in about 2 years, I can not believe how much the interface has improved.

Webmin is a GUI control panel that lets you administer a Linux box.

Here is all you need to do to get it installed:
This will install some dependencies. # yum -y install perl-Net-SSLeay Install the system: # cd /usr/src
# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.510-1.noarch.rpm
# rpm -i webmin-1.510-1.noarch.rpm

Restore GRUB

Boot a cd with rescue linux.
Issue this:
as root
grub (enter)
root (hd0,?) (? being where your controlling distro is, in my case it was 5)
setup (hd0)
quite


Done!