Linux is one of the most popular operating systems that are used by many organizations and many system administrators could find these tips very handy.
- When in doubt check your logs- As everything gets logged within Linux, the first thing you must take care of when dealing with a nagging issue is to check your logs. In many systems, this can be located in /var/log/. /var/log/syslog. This logs all the system messages and this is where you will be faced with most common error messages.
- Using the Tail command - You can use this command to see the last ten lines of a file. By using the f flag, or tail -f /var/log/syslog you can view the most recent lines append to the log file. It is a great tool to make use of while looking out for error messages.
- Monitoring server resources- Based on your disk and partition size, there are times you may run out of space or your log files may consume most of your root partition. By using the df command, you can monitor the size of the partitions. Two things to keep in mind at the time of starting are the -h and -m flag. The -h flag puts information in human readable form like 5g. The -m flag puts information in megabyte form and displays only in megabytes.
- Don’t Ever Use Root To Login- Many common hacks are performed by port scanners and random password generators who try to break into your system using root as their username. You must disable root login on your system. You can do this by going into /etc/ssh and edit sshd_config. You need to amend this line PermitRootLogin yes to PermitRootLogin no. Once you have done this you must restart ssh /etc/init.d/ssh restart.
- Becoming aware of chown and chmod – In case of hosting websites, permissions security and file ownership are quite crucial. A wrong permission can lead your being open to exploitation or hacking.
- Using SFTP in place of FTP - SFTP encrypts passwords via the tunnel whereas port 21 ftp permits password information to be transmitted via clear text. Hackers can listen to and grab your passwords while using port 21.
- ls -al – LS lists the directory contents. The -a flag informs the ls command to list all files, along with those beginning with a . (dot). The -l flag informs LS to list the contents and displays the date files were modified.
- Top – This command displays your highest use processes on your system. In the event of your processor running high, it will assist you in locating the process and fixing the problem.
- Using grep for searching files for a specific word/expression- Grep is vast and that’s the reason it is among the best tools for searching files. For eg, grep -r pinehead.tv /etc/* will search the /etc/ directory and all the directors under it that have the word pinehead.tv.
- Redirecting the results of a grep search into a new file- This can be easily done. You can obtain the search results from the command above and write them to a file instead of reading them in the shell. Just type grep -r pinehead.tv /etc/* > test.test.
No comments:
Post a Comment