Category Archives: Linux
Restrict SSH access by IP
The best way to restrict SSH access by IP is by using the server’s hosts.allow and hosts.deny file. First open the /etc/hosts.allow file and add the IP’s you would like to allow: Format – one IP per line: SSHD: $IP #Reason Example: SSHD: 1.1.1.1 #Client 1 The hosts.allow file will have to be updated in …
Linux version
Try logging into the server via SSH and then running: cat /etc/issue
Linux set hostname
First login to the server via SSH. Then run: hostname $servername Update the hosts file – Look for the primary IP of the server. Follow the same format and replace the old hostname with the new hostname on the same line as the primary IP. vi /etc/hosts Update your network file with the new hostname: …
Argument list too long
In Linux there is a maximum number of files that can be removed from a folder using: rm -rf /home/$foldername/* Instead, you can use the find command which will find each file in a specific folder and then remove it. This is extremely helpful when you have to remove thousands of files from a mail …
Get CPU speed in Linux
cat /proc/cpuinfo This will show you the number of processors/cores and the speed/memory capabilities of them.
Make a file read only
To make a file on a Linux system read only use the following: #add protection chattr +i filename This will ensure nothing can change the file unless it removes the chattr bit prior to writing to the file. If you need to update the file run: #remove protection chattr -i filename This will enable editing …
disable selinux
selinux often breaks applications or scripts and it’s necessary to disable selinux. To disable selinux: echo 0 > /selinux/enforce
sed string replacement
Here’s how you can replace a string in a file with sed: perl -pi -e ‘s/replaceme/reoplacewith/g’ filename.txt This is a VERY basic replacement without and special characters. Be VERY careful if you have special characters that you’re trying to replace. If you have characters like: / you will have to proceed them with a to …
Create a cron job
Check for Bad Blocks
check for bad blocks on a hard drive: badblocks -vv /dev/sda3 > badblocks.log & The command above will check for badblocks on the partition /dev/sda3 and save the results to the log file badblocks.log checks for badblocks and it writes the results to: badblocks.log If you want to check a specific drive or partition you …
- English Support
- 24/7 x 365
- Branded Support
- Reduced Overhead
- Linux Experts
- Friendly Staff