Today i am going to talk about Swap Space, not going to explain (for now) how to make the Swap Space but i will talk about what it is.
Many people don't know what is Swap Space, but in fact it is an important thing in Linux, so let's go ahead with it.
If you don't know, Linux uses pagination to change memory blocks(pages) between the main memory (RAM) and hard drive, this way the programs that are not running at the moment can place parts of their memory on the hard drive, giving the new process's more memory to run. So it's in this step that Swap Space comes in action, Swap is the name of the space on the disk given to the Linux kernel to do the pagination. Normally the Swap size it's 2x your Physical Memory size, if you have 1GB RAM your Swap will be of 2GB, since disk space it's cheap this is no problem, the problem is as you may know RAM access is made in nanoseconds while disk access is done in milliseconds, if you have a big Swap size it will slow down your programs, because the overhead of pagination will be bigger.
Exists two ways of making a Swap Space the Swap Partition and the Swap File. Swap Partition it's the best way and the more used since it creates a partition on the disk dedicated to the Swap, while Swap File creates a file of the size you want your Swap size to have and it will consume disk space.
Swap size plus the Physical size it's called the Virtual Memory, this way you can run programs that use more memory than you have physically, without receive the message "Error allocating memory: out of memory".
In the new kernels there's a new configuration related to the Swap it's called Swappiness.
Swappiness can have a value of 0 to 100 and the default is 60, this consists in the times that kernel do the pagination, higher the number, more times kernel will do pagination, smaller the number, less times kernel will change memory pages to disk.
Conclusion
Swap Space is important on Linux and you always should use it as a partition.
You can use a Linux without Swap, but if your machine runs out of memory your system will crash.
The rule to choose the size of the Swap size it's 2x your physical memory size.
This was my first article and i am sorry about my english.
Hope you enjoy, if you have any comments or doubt leave a comment
Search
segunda-feira, 4 de julho de 2011
domingo, 3 de julho de 2011
How to: Disable IPTables
If you need to disable your iptables (not recommended) this is the way to do it.
Difficult: easy
Avg Time: 5min
You need to be logged as root to disable iptables.
Disable iptables on Ubuntu/Debian.
1º - Save your current iptables config, to restore later if needed.
Disable iptables Centos/RedHat/Fedora.
Disable iptables on Centos/RedHat/Fedora it's much simple!
1º - Save current config and Stop
If you have any problem leave a comment
Difficult: easy
Avg Time: 5min
You need to be logged as root to disable iptables.
Disable iptables on Ubuntu/Debian.
1º - Save your current iptables config, to restore later if needed.
iptables-save > /root/iptables.backup2º - Make this commands
iptables -X3º - Now if you would like to restore your old config, do this
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables-restore < /root/iptables.backup
Disable iptables Centos/RedHat/Fedora.
Disable iptables on Centos/RedHat/Fedora it's much simple!
1º - Save current config and Stop
/etc/init.d/iptables save2º - Start iptables again
/etc/init.d/iptables stop
/etc/init.d/iptables start
If you have any problem leave a comment
How to: Add a new user
Hello, in my first post i will explain how to add a new user to your system.
Difficult: easy
Avg Time: 1 min
Linux have a built in command called "useradd" that help people to add new user to the system.
To add a new user you must be logged as root or you will need to use sudo.
I will give some of the must useful examples.
Syntax: useradd options name
Example 1: Add new user to the system
If you would like to set a password for the user i recommend you to use the passwd command instead of the -p option of useradd command.
Example 8: Create new user and set the password
That's the way i use to add new user and set user password, if you have any other suggestion please post it as comment
Difficult: easy
Avg Time: 1 min
Linux have a built in command called "useradd" that help people to add new user to the system.
To add a new user you must be logged as root or you will need to use sudo.
I will give some of the must useful examples.
Syntax: useradd options name
Example 1: Add new user to the system
useradd -r ricardoExample 2: Add new user and do not create home directory (/home)
useradd -rM ricardoExample 3: Add new user and create home directory in /home
useradd -rm ricardoExample 4: Add new user and specify the home directory
useradd -rd /somedir/somedir ricardoExample 5: Add a user and create a group with the same name
useradd -rn /somedir/somedir ricardoExample 6: Add a user and add user to existent group
useradd -r -g groupname ricardoExample 7: Add a user, create home directory and a group with same name
useradd -rmn ricardo
If you would like to set a password for the user i recommend you to use the passwd command instead of the -p option of useradd command.
Example 8: Create new user and set the password
useradd -rm ricardo
passwd ricardo
That's the way i use to add new user and set user password, if you have any other suggestion please post it as comment
Subscrever:
Mensagens (Atom)