Wednesday, February 10, 2010

How to copy files with SCP

Copy a file to another host: 
scp sourcefile user@host:/directory/TargetFile

Copying file from host:  
scp user@host:/directory/sourcefile TargetFile

Note that if the remote host uses a port other than the default of 22, you can specify it in the command.
For example, copying a file from host:
scp -P 2222 user@host:/directory/SourceFile TargetFile

Friday, February 5, 2010

Virtual Box How to change screen resolution in a Ubuntu 9.10 guest system

Two days ago I installed a ubuntu 9.10 virtual machine.The process of installation went great except for the video driver.I have a  Sapphire ATI HD 4850 HD 512 DDR3 with an  and a Samsung SyncMaster T240HD monitor 1920x1200 maximum resolution.And yet the secreen maximum resolution was 800x600.
So after some reading of Virtual Box manual i found the answer.

You must install the Guest Drivers in the Ubuntu guest machine and create a xorg.conf file.

Step 1 - Start the virtual machine and mout the VBoxAdditions.iso
 If you can't find it on the menu you will have to find the image and mount it .If your on a windows host you will find it in your VirtualBox instalation folder mine is on d:\VirtualBox\.If you are on linux host you will find it in /usr/share/Virtual Box/ folder.




Step 2 - install the guest adition drivers
Open a shell and type:

cd /media/cdrom0/
ls -ltr 
If you are on 32 bit machine you must install  VBoxLinuxAdditios-x86.run like this:
sudo sh VBoxLinuxAdditios-x86.run
After the install completes reboot the sistem
Step 3 - create a xorg.conf file
Open a shell and type:
sudo  gedit /etc/X11/xorg.conf
Now copy this lines bellow in the xorg.conf file you just created and save the file.

Section "Device"
   Identifier   "Configured Video Device"
   Driver    "vboxvideo"

EndSection

Section "Screen"
   Identifier    "Default Screen"
   Device    "VirtualBox graphics card"
   Monitor    "Generic Monitor"
   DefaultDepth    24
   SubSection "Display"
     Depth    24
     Modes      "1920x1200"
   EndSubSection
EndSection



Under modes put your own monitor resolution.Log out and after that you will be able to change the screen resolution using Sistem-->Preferences-->Display


Thursday, February 4, 2010

Xinetd the super server

Xinetd performs the same function as inetd: it starts programs that provide Internet services. Instead of having such servers started at system initialization time, and be dormant until a connection request arrives, xinetd is the only daemon process started and it listens on all service ports for the services listed in its configuration file. When a request comes in, xinetd starts the appropriate server. Because of the way it operates, xinetd (as well as inetd) is also referred to as a super-server.The only reason for the existence of a super-server was to conserve system resources by avoiding to fork a lot of processes which might be dormant for most of their lifetime. While fulfilling this function, xinetd takes advantage of the idea of a super-server to provide features such as access control and logging. Furthermore, xinetd is not limited to services listed in /etc/services. Therefore, anybody can use xinetd to start special-purpose servers.

CONTROLLING XINETD
SIGHUP causes a hard reconfiguration, which means that xinetd re-reads the configuration file and terminates the servers for services that are no longer available. Access control is performed again on running servers by checking the remote location, access times and server instances. If the number of server instances is lowered, some arbitrarily picked servers will be killed to satisfy the limit; this will happen after any servers are terminated because of failing the remote location or access time checks. Also, if the INTERCEPT flag was clear and is set, any running servers for that service will be terminated; the purpose of this is to ensure that after a hard reconfiguration there will be no running servers that can accept packets from addresses that do not meet the access control criteria. SIGQUIT causes program termination. SIGTERM terminates all running servers before terminating xinetd. SIGUSR1 causes an internal state dump (the default dump file is /var/run/xinetd.dump; to change the filename, edit config.h and recompile). SIGABRT causes an internal consistency check to verify that the data structures used by the program have not been corrupted. When the check is completed xinetd will generate a message that says if the check was successful or not.
xinetd.conf is the configuration file that determines the services provided by xinetd. Any line whose first non-white-space character is a ’#’ is considered a comment line. Empty lines are ignored.You can find it in /etc/xinetd.conf. The file contains entries of the form: service { ... ... }
The necessary attributes for a service in xinetd.conf are: 


socket_type 
user (non-internal services only) 
server (non-internal services only) 
wait protocol (RPC and unlisted services only)
rpc_version (RPC services only) 
rpc_number (unlisted RPC services only)
port (unlisted non-RPC services only)

EXAMPLE

# # Sample configuration file for xinetd

defaults
{
log_type = FILE /var/log/servicelog
log_on_success = PID
log_on_failure = HOST
only_from = 128.138.193.0 128.138.204.0
only_from = 128.138.252.1
instances = 10
disabled = rstatd

}


service ftp

socket_type = stream 
wait = no 
nice = 10
user = root
server = /usr/etc/in.ftpd
server_args = -l 
instances = 4
log_on_success += DURATION HOST USERID
access_times = 2:00-9:00 12:00-24:00
}

For more details see http://manpages.ubuntu.com/manpages/lucid/en/man5/xinetd.conf.5.html

How to run a software with *.sh or *.run extension

Open a shell and go to the folder where the executable aplication is then type:

1. sudo  sh soft_name.sh
or like this
2. sudo ./soft_name.sh

For a software with *.run extension is done the same.

Wednesday, February 3, 2010

TCP Wrappers

If you want to set up a very good security you must build a layerd security.Tcp Wrappers is like a basic firewall that protects your network services.


A basic security before you set up ipfilters firewall   looks like this:
xinetd -->TCPWrappers-->network service (layerd security)
To create the TCP Wrappers rules edit these two files:


hosts.allow and hosts.deny


These two files, located in your /etc/ folder, allow you to limit or permit connections from specific hosts or ips. Using these two files you could setup a whitelisting basic firewall or blacklist.

Here is the format:

daemon_list : client_list [ : shell command]



daemon_list - is a list of one or more daemon process names (argv[0] values) or server port numbers or wildcards.
client_list - is a list of one or more host names, host addresses, patterns or wildcards that will be matched against the client host name or address.
shell command is optional
List elements should be separated by blanks and/or commas.


Wildcards


Here are lists of wildcards support by tcp wrappers:


ALL The universal wildcard, always matches. 
LOCAL Matches any host whose name does not contain a dot character.
UNKNOWN Matches any user whose name is unknown, and matches any host whose name or address are unknown. 
KNOWN Matches any user whose name is known, and matches any host whose name and address are known.  
PARANOID Matches any host whose name does not match its address.

Shell commands


I never used theese but you can open a shell type man hosts.allow to find out more


Example of editing rules for TCP Wrappers:

Open your favorite editor and open the hosts.allow file

sudo nano /etc/hosts.allow

ALL: 127.0. (the 127.0. range is allowed)

telnetd : 192.168.0.2 (specific IP) 192.168.0. (specific range) EXCEPT 192.168.0.10 (range exceptions)


sudo nano  /etc/hosts.deny


ALL : ALL (denying all services to all hosts)


How to test if tcpwrappers is working:

1.Open a shell and type:
tcpdchk -v   (tcpdchk examines your tcp wrapper configuration and reports all potential and real problems it can find. The program examines the tcpd access control files (by default, these are /etc/hosts.allow and /etc/hosts.deny), and compares the entries in these files against entries in the inetd(xinetd) network configuration file.)
2.Open a shell and type:
tcpdmatch in.telnetd 192.168.0.2 (tcpdmatch predicts how the tcp wrapper would handle a specific request for a service.The program examines the tcpd access control tables (default /etc/hosts.allow and /etc/hosts.deny) and prints its conclusion. For maximal accuracy, it extracts additional information from your inetd(xinetd) network configuration file.When tcpdmatch finds a match in the access control tables, it identifies the matched rule. In addition, it displays the optional shell commands or options in a pretty-printed format; this makes it easier for you to spot any discrepancies between what you want and what the program understands.)
 How to check if a service is compatible with tcpwrappers:
  
1. Not all the services are compatible with TCP Wrappers , so to see which services are compatible open a shell and type:


ldd /usr/sbin/telnetd | grep libwrap (this example tests the telnet service)


In the example above we see that the telnetd (telnet server) is referring to the libwrap.so, so we can tell that any restrictions in hosts.allow and hosts.deny are applicable to that service.

Thursday, January 21, 2010

How to verify if a service is running

1.Type this command to see all the services status:
sudo service --status-all
2.To verify the status of one service type:
sudo service cups status
2.The service command can be used to start or stop a service if you know the service name :
sudo service cups stop (stops the printing service)
sudo service cups start (starts the printing service)

Hot to manage Services in Ubuntu the easy way

If you are tiered to start or stop a service running /etc/init.d/apache2 start  {start|stop|restart} you can do this:

Step 1 :
Install the service manager utility sysv-rc-conf like this:
sudo apt-get install sysv-rc-conf
Step 2:
Run the application :
sudo sysv-rc-conf
= - start a service from the list
-   - stop a service from the list
SPACE key - to stop automatic start of a service in diffrent runlevels
q - exit application
h - help

Done.

Thursday, January 14, 2010

What should I do if I can't remove or reinstall Microsoft Office ?

For Office XP or Office 2003

1. Insert the first disk of your Office CD set in the CD-ROM drive.
2.Right click and open the cd. DO NOT RUN THE INSTALLER.
3. Search for the file : Offcln.exe.(you can use the search from explorer).Run it.

Wednesday, January 13, 2010

Hot to change the runlevel in Ubuntu 9.10

1.To change the runlevel you must edit this file rc-sysinit.conf.

Edit the file as administrator like this:

sudo gedit /etc/init/rc-sysinit.conf


Find the folowing line an put the runlevel number you want.

env DEFAULT_RUNLEVEL=2


Carefull do not let spaces between equal sign and the number.That is it.Reboot and done.

2.If you want to change runlevels just for this session do this:
sudo init 3         (runlevel  numbers 2-5)
runlevel            (this command will show you what runlevel you are running in now)

Grub 2 Bootloader File Structure

GRUB 2 incorporates a totally revised folder and file hierarchy. The menu.lst of GRUB legacy is no longer used.
To find out where GRUB 2 is installed, the user can run the following commands: sudo grub-probe -t device /boot/grub for the device and sudo grub-probe -t fs_uuid /boot/grub for the UUID.
The main folders and files used by GRUB 2 include:

/boot/grub/grub.cfg


This is the file most closely resembling GRUB's /boot/grub/menu.lst. This file contains the GRUB 2 menu information but unlike GRUB's menu.lst the grub.cfg file is not meant to be edited.

  • Each section is clearly delineated with "(### BEGIN)" and references the file in the /etc/grub.d folder from which the information was generated.


  • grub.cfg is updated by running the update-grub command as root. The update-grub command is a stub for sudo grub-mkconfig -o /boot/grub/grub.cfg. For standardization, the command update-grub will be employed, run as "root" with the sudo.

  • The file is automatically updated with kernel installations/removals or other updates which would affect its output.

  • By default, and whenever the update-grub command is executed, this file is made "read-only". This is in keeping with the intent that the file should not be edited manually.

The user will also see a multitude of *.mod files in the /boot/grub folder. These files relect the modular nature of GRUB 2 and are loaded as necessary by the GRUB 2 bootloader.

/etc/default/grub



  • This configuration file contains information formerly contained in the upper section of GRUB Legacy's menu.lst and items contained on the end of the kernel line. The entries in this file can be edited by a user with administrator (root) privileges and are incorporated into grub.cfg when it is updated. Specific configuration settings are detailed in the Configuring GRUB 2 later in this section.


/etc/grub.d/ (folder)



  • The files in this folder are read during execution of the update-grub command and their instructions are incorporated into /boot/grub/grub.cfg.


  • The placement of the menu items in the grub.cfg menu is determined by the order in which the files in this folder are run. Files with a leading numeral are executed first, beginning with the lowest number. 10_linux is run before 20_memtest, which would run before 40_custom. If files with alphabetic names exist, they are run after the numerically-named files.


  • Custom entries can be added to the 40_custom file or in a newly created file. Based on its name, 40_custom entries by default appear at the bottom of the menu. A custom file beginning with 06_ would appear at the top of the menu since its alphanumeric sorting would place it ahead of 10_ through 40_ files.


  • Only executable files generate output to grub.cfg during execution of update-grub.

  • The default files in this folder are:

    • 00_header Sets initial appearance items such as the graphics mode, default selection, timeout, etc. These settings are normally imported from information from /etc/default/grub. Users normally do not need to make changes to this file.


    • 05_debian_theme The settings in this file set splash image, text colors, selection highlighting and themes. In the absence of a splash image, this file sets a monochromatic theme for the initial menu display. How to set font renderings and splash images are discussed in detail in the Splash Images & Themes section.


    • 10_hurd Locates Hurd kernels. Not currently used.


    • 10_linux Locates kernels on the root device for the operating system currently in use. It takes this information and establishes the names displayed on the menu for these kernels.


    • 20_memtest86+ Searches for /boot/memtest86+.bin and includes it as an option on the GRUB 2 boot menu. There is currently no line option to remove this entry from the menu. The display of memtest86+ can be inhibited by removing the executable bit from this file: sudo chmod -x /etc/grub.d/20_memtest86+ and then running sudo update-grub.


    • 30_os-prober This file with os-prober, which searches for Linux and other operating systems. Results are placed in grub.cfg based on the scripts in this file. The file is divided into 4 sections, representing the types of operating systems handled by the scripts: Windows, Linux, OSX, and Hurd. Variables in this file determine the format of the displayed names in /boot/grub/grub.cfg and on the GRUB 2 menu. Users familiar with basic scripting can alter these variables to change the format of the displayed menu entries. Alternatively, the user can insert an entry into /etc/default/grub which disables this script. (See below)


    • 40_custom A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the update-grub2 command. The contents of this file, below the "exec tail -n +3 $0" line and the default comments, are imported directly into /boot/grub/grub.cfg without any changes.


    • Files in these folders must be executable to be used by update-grub. Files which are not executable will be ignored. To make a file executable, run sudo chmod +x /etc/grub.d/folder/filename


Linux runlevels

There are six default runlevels in the Linux base system.

0 (zero) is basically the shutdown runlevel.

1 (one) is single user mode.

2 (two) is a multi-user mode, minus NFS support.

3 (three) is a multi-user, command line based mode.

4 (four) user-defined / undefined.

5 (five) multi-user, graphical mode. This is generally the default runlevel on desktop / laptop machines.

6 (six) is basically the reboot runlevel.

Tuesday, October 20, 2009

poza


Tuesday, August 11, 2009

How do I add more swap memory in ubuntu?

You entered the wrong swap size no problem I'll show you how to increase your swap
I will create a 512Mb swap file:
Enter in bash this line:

1. sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512
2. sudo mkswap /mnt/512Mb.swap
3. sudo swapon /mnt/512Mb.swap
4. gksudo gedit /etc/fstab
add this line in the fstab file you just launched:
/mnt/512Mb.swap none swap sw 0 0
5.Reboot

How to create a large file in Ubuntu

Use the dd command

Here is the syntax of the dd command to create the file.
I will fill the file with NULL characters.
dd if=/dev/zero of=test.tst bs=1k count=4700000
if = input file
of = output file
bs = block size
count = file size in kb
the file size is given by multiplying bs and count

Example create a 1 GB file:
dd if=/dev/zero of=file_1GB.txt bs=1m count=1k

How to create a large file in windows command line

To create a large file of 1MB do this:
Run->cmd
fsutil file createnew c:\myfile.txt 1000000

To create a large file of 100MB do this:
Run->cmd
fsutil file createnew c:\myfile.txt 100000000

and so on.The number at the end tels you how big the file will be

Saturday, July 25, 2009

How to compact files and folders at the Comman Line

COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [filename [...]]

/C Compresses the specified files. Directories will be marked
so that files added afterward will be compressed.
/U Uncompresses the specified files. Directories will be marked
so that files added afterward will not be compressed.
/S Performs the specified operation on files in the given
directory and all subdirectories. Default "dir" is the
current directory.
/A Displays files with the hidden or system attributes. These
files are omitted by default.
/I Continues performing the specified operation even after errors
have occurred. By default, COMPACT stops when an error is
encountered.
/F Forces the compress operation on all specified files, even
those which are already compressed. Already-compressed files
are skipped by default.
/Q Reports only the most essential information.
filename Specifies a pattern, file, or directory.

Used without parameters, COMPACT displays the compression state of
the current directory and any files it contains. You may use multiple
filenames and wildcards. You must put spaces between multiple
parameters.

Saturday, July 11, 2009

User State Migration Tool-How to migrate user accounts and user settings

  1. Log on to the source computer as an administrator, and specify:

    scanstate \\fileserver\migration\mystore /i:miguser.xml /i:migapp.xml /o

  2. Log on to the destination computer as an administrator.

  3. Do one of the following:

    • If you are migrating domain accounts, specify:

      loadstate \\fileserver\migration\mystore /i:miguser.xml /i:migapp.xml

    • If you are migrating local accounts along with domain accounts, specify:

      loadstate \\fileserver\migration\mystore /i:miguser.xml /i:migapp.xml /lac /lae

Saturday, July 4, 2009

Can't Creat a Performance log alerter

Start the Performance Logs and Alerts service by using the Local System account instead of the Network Service account:
  1. Click Start, click Run, type services.msc in the Open box, and then click OK.
  2. In the Name list, double-click Performance Logs and Alerts.
  3. Click the Log On tab, click Local System account, click Apply, and then click OK.
  4. Quit the Services dialog box, and then restart the ISA Server performance counter log.

Friday, July 3, 2009

Changing System Restore Options in the Windows Registry

In most situations, the default System Restore operation is satisfactory. However
there might be situations in which you need to change how System Restore functions. There are four settings that you can change in the Windows Registry tha affect the intervals System Restore uses when creating automatic restore point and the disk space it uses.
Each of these settings is located in the HKEY_LOCAL_MACHINE\SOFT
WARE\Microsoft\Windows NT\CurrentVersion\SystemRestore subkey.
These settings include the following:
1.RPSessionInterval This setting specifies the intervals, in seconds between scheduled restore-point creations during an active user session. The default value is 0 seconds (disabled).
2.RPGlobalInterval This setting specifies the time interval, in seconds, a which scheduled restore points are created (regardless of whether or no there is an active user session). The default value is 86,400 seconds (24 hours).
3.RPLifeInterval This setting specifies the time interval, in seconds, for which restore points are kept. System Restore deletes restore points older than the specified value. The default value is 7,776,000 seconds (90 days).
4.DiskPercent This setting specifies the maximum amount of disk space on each drive that System Restore can use. This value is specified as a percentage of the total drive space. The default value is 12 percent.