As we saw in the last article TTY: What is? What’s the use? . If you think you do not need as many TTY as those available by default in your environment. I agree, and it affects a little performance of your linux .. but rather it. Certainly for those who need the full potential of a machine that will make a difference.
There are ways you can decrease the amount of TTY of their distribution here will decline to 3 the device files , if you want to you can change as you wish, just following the logic, and steps.
There are several ways of update date and time in linux , among which the simplest are:
Easier however, there is the need to have internet connection, and ntpdate installed.
If you do not have ntpdate installed you can install from source: http://www.ntp.org/downloads.html , or whether you have the aptitude:
aptitude install ntpdate
Continuing the previous topic .. the main Subversion commands.
I think anything more than a simple “help” to learn all the commands. The “help” of subversion, is cooler than the others because it provides help with svn commands. For example:
svn help update
Permissions on Linux, is the main "feature" of Unix-based systems. They are used in different ways and for different purposes. But mostly for safety and organization of a system.
Through the permissions, you can define who can access, write and execute a file. Any per group, or per-user. With permissions, Linux prevents a malicious program, for example, delete a file that should not send special files to someone else or provide network access for other users to invade the system.
Let us understand better, and learn how to change and check the permissions of certain directory or file.
To check the permissions of a file or directory, it is common to use the command ls with parameter -l , it’s will discover with the permissions and owners of files and directories .
ls -l /home/vinicius/tmp/
Returns me the result:
total 4 -Rw-r - r - 1 vinicius vinicius 0 Nov 22 12:59 index.html lrwxrwxrwx 1 vinicius vinicius 15 Nov 22 12:59 link -> / home / vinicius / drwxr-xr-x 2 vinicius vinicius 4096 Nov 22 24:59 test -Rwxrwxrwx 1 vinicius vinicius 0 Nov 22 13:00 test_777
Okay? Ta thinking this is a lot of loose letter right? Let us understand what each part of it means.
directory, link, file?
To know what each item is, just look at the first letter.
- l => means that this item is a link;
- d => That item is a directory;
- – => A file;
- b => block file;
- c => character special file;
- p => channel;
- s => socket;
rwx what’s this?
You noticed that these letters are being repeated throughout the list of ls, each has its meaning:
- r => read – indicates read permission;
- w => write – indicates writable;
- x => Execution – indicates execution permission
- – => indicates no permission
Ready now know the meaning of each letter, we can now interpret the results of ls command. We can divide the result into 3 parts, let's take the first line as an example:
rw- | r - | r -
Each group of 3 characters means this order, the permission for the owner, permissions for the group that owns the file owner and permissions to other users.
Reading data only allowed -rw-r – r – , we can identify that a file is that the file owner has read and write permission, and that the other ( group and others) allowed only read.
Each letter has its corresponding bit, which can be identified as follows:
|– x||001||1||Execute permission|
|wx||011||3||write and execute permission|
|r –||100||4||Read Permission|
|rx||101||5||Readable and execution|
|rw-||110||6||Permission reading and writing|
Using the above table if we can change the permission of files and directories with the chmod.
The syntax of the command chmod:
chmod 777 test.txt
chmod 444 test.txt
Permission reading and writing to the owner, read for others
chmod 644 test.txt
besides using chmod permissions with numbers , there is also possibility to use the most boring form of letters . Where we need to understand that
- u => user;
- g => group;
- O => other;
- a => all;
- + => add permission
- – => remove permission
- = => set the permission
With this we can use the chmod as follows :
Execute permission for the user
chmod u + x test.txt
Read permission for the group
chmod g+ r test.txt
The danger of allowing 777
As I said earlier , the permission 777 is the full permission to something , ie everyone can edit, delete , write . Imagine a file with permission 777 where everyone can edit it , someone with malicious intentions can edit your file , and run it , you can steal valuable information , run something on your operating system and erase data . So it is normal if you use permission 755 for directories and 644 for non-executable files such as php files on hosting servers .
Even this is something that some servers block with suPHP , whenever you have getting error 403 , first check the permissions of your files and folders , as in 90% of cases the problem is this .
You can understand more about it at:
We’ll cover some more advanced forms of improve the performance of linux.
Disabling than anything, or fiddling with the interface.
I separated the 3 things that I normally use to improve my servers, and virtual machines.
For those who do not know what is ramlog … can kill yourself now. Just kidding, read the rest. Then mate.
As the name says Rams – log means store the log in the ram, instead of pouring it on disk directly. How common is used by syslog.
Thus is avoided that there is always written to disk, which is a bottleneck of performance on any server. Exist only when the ramlog is restarted or stopped.
The use of ramlog, makes a big difference in performance
Ramlog – http://www.tremende.com/ramlog site you can find the installation tutorial for various distributions.
Access ssh without password, I think it’s one of the things, most useful for anyone who has to deal with multiple servers at the same time, especially for those who need to make copies of files between them.
To use this facility, simply installing the ssh-keygen , to generate the key machine. For this generation can use two types of encryption, namely, rsa and dsa
What is RSA?
RSA is an algorithm for data encryption, which owes its name to three professors from MIT Institute (founders of the current company RSA Data Security, Inc.), Ronald Rivest, Adi Shamir and Leonard Adleman, who invented this algorithm – to date (2008), the most successful systems implementation asymmetric keys, and is based on classical theories of numbers. It is considered the safest, since he sent away all attempts to break it. It was also the first algorithm to enable encryption and digital signature, and one of the great innovations in public-key cryptography.
RSA is the most commonly used, mainly because it is the default ssh-keygen.
What is DSA?
DSA is an acronym for Digital Signature Standard (Digital Signature Standart), created by NIST, and specifies the digital signature for DSA and SHA-1 for hashing. The DSA is an asymmetric algorithm and the private key operates on the hash SHA-1. To verify the signature piece of code calculates the hash piece and another uses the public key to decrypt the signature, and finally comparing the results of both ensuring the author of the message. The DSA works with keys of 512 to 1024 bits, but unlike the RSA which is multipurpose, DSA ??signs only and does not guarantee confidentiality. Another against DSA is that the generation of the signature is faster than RSA, but 10 to 40 times slower to check the signature. Blockquote>
How does ssh-keygen?
The ssh-keygen , raises public and private keys, so that from them if you can access the server. Which in our case will occur without typing the password, but this key usage is as a hint, to improve the security of access to the server, of course, if using with password.
Hands on mass
Open your terminal, call your grandmother, and the whole family to watch.
Generating the keys
It is up to you which encryption use, so I made the explanation of the two. Since you’re with your family, make a poll to decide which is the best. After the vote, follow the tutorial, I’ll use the rsa, if uses dsa, just change where rsa, dsa.
log in to terminal, with the user that you want to access the server without password. Because the key is specific to the user.ssh-keygen-t rsa
You will get the following response:Generating public/private rsa key pair. Enter file in which to save the key (/home/vinicius/.ssh/id_rsa):
My user is vinicius, I don’t know if you’ve noticed, but my name is that (see the url!).Finally, choose the folder in which to save the key. If ta with laziness only confirms.And you will receive another message.This step is very importantEnter passphrase (empty for no passphrase):
As you read above, enter the password (the password). As we want to access without password, only, confirm (press enter, ask your grandmother!) without typing anything.He will ask for confirmation, press “enter” again. Confirmation:Enter same passphrase again:
Ready, created the key.Your identification has been saved in/home/vinicius/.ssh/id_rsa. Your public key has been saved in/home/vinicius/.ssh/id_rsa.pub. The key fingerprint is ...
It generates a lot of cute character, that are not suitable to put in this post. Everything created, now we put the public key on the server, to which we want to access without password.
Putting the public key in the destination server.
There are a few different ways to do this step, even found a very interesting when writing this post. I will describe two, a simple, and another simpler still.
What must be done is to put the contents of the public key (id_rsa.pub) on the server, specifically the file authorized_keys in either user, the server, to which we have access.
Let’s assume that the user name is joao, on the server viniciusmuniz.com
First let’s copy the public key to the server/home/vinicius/.ssh/id_rsa.pub scp firstname.lastname@example.org:/home/joao/
enter their password, their penultimate time to type it. And then access the server, and place the public key in the authorized_keysssh email@example.com cat/home/joao/id_rsa.pub > >/home/joao/.ssh/authorized_keys
Ready! Now test the ssh access, that there will be no further need for password.
Super simple mode
This way I found writing this post. There is a facility that is the ssh-copy-id , which with just one command, he inserts the public key in the destination server.ssh-copy-id -i /home/vinicius/.ssh/id_rsa.pub firstname.lastname@example.org
Accessing ssh without password
Now just login, there will be no more need for password. Join the fun!ssh email@example.com
Hello, after a long time without writing, I finally found the time.
And in another tutorial, we’ll learn how discover open ports or closed on a server, computer …
For this task, we use the command nmap .
According to nmap’s own description, the application is:
Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to track (Scan) large networks quickly yet works well with a single host (host). Nmap uses raw IP packets in (raw) on new ways to determine what hosts (hosts) are available on the net …
For more details you can find in http://nmap.org/ . I like to use nmap, but it does not mean that this is the only way to accomplish this task.
Listing the main server ports
The simplest of commands, just run nmap to the server that you want to investigate
Listing the main server ports in more detail
nmap -s test.com
Verifying several machines on the network
Very useful for network administrators
Check certain ips
nmap 192.168.254.1 192.168.254.2 192.168.254.3
Verifying a track (one range) of IP’s
Verifying a range using wildcard
Verifying a specific port
nmap -p [port] test.com
Verifying a range of ports
nmap -p 80-400 test.com
Again, this is not the only method of doing this scan. And you can find more about nmap the link: http://www.cyberciti.biz/networking/nmap-command-examples-tutorials/
And alas! Let us understand more a Linux command, now the at . That also did not know until recently.
Imagine yourself in the following situation, you have to run a command now, so to come back from lunch (that’s damn silly example), but will only arrive at 14:30. and your boss wants the result of this command to 2 hours, or it will eat your … liver. Simple!! The command at will leave you with your … intact liver. Let’s practice, and stop bla bla.
The command behaves like a cron that will run, and then cease to exist. Much simpler than configuring a line in cron to run a command only once.
Assuming that the command that your boss wants to be shot tomorrow, and is the list of all users logged in at 14:00, by which it accesses a file on the network.
The command accepts multiple configuration variants of the date / time. For this example we use in this way
$ At 2pm tomorrow at> who> / var / www / list_users.html
When you enter the command at it will open a “sub-terminal” at the for you to enter your command, in our case who> / var / www / list_users. html , to save at the command, use ctrl + d .
Tips command at linux
List commands (jobs) configured at the
Use command atq , it will list the work to be performed, for your user, if you are the root of all the users.
Delete commands (jobs) configured at the
Use command atrm , it will remove a specific job, you should specify the work to be removed. For example:
$ Atq 5 Fri May 17 13:30:00 2013 vinicius 6 Fri May 17 13:31:00 2013 vinicius $ 5 atrm
Going deep in at
I advise to read the documentation at as there are many tips on the same
Running a command in 3 days at 4 o’clock
at 4pm + 3 days
Running a command on a specific day (18.10.2013) at 4 o’clock in the morning
Observer this example, the date is in standard MMDDCCYY
at 4am 10,182,013