The following shell script splits an IP into separate Octets into its own variables. This method can be used for any script which needs to take each octet into account, such as generating firewall rules etc. Read More
Category: Linux
Example syntax for Secure Copy (scp) Linux
SCP allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.
Examples
Copy the file “foobar.txt” from a remote host to the local host
$ scp [email protected]:foobar.txt /some/local/directory
Read More
Install mod_pagespeed (Website Optimizer) for Apache in CentOS
mod_pagespeed is an open source module for Apache web server that automatically optimize Web Pages to improve better performance while serving web pages using Apache HTTP Server. It has several filters that automatically optimize files like HTML, CSS, JavaScript, JPEG, PNG and other resources.
Step 1: Enabling Google’s mod_pagespeed Repository
Create a file called /etc/yum.repos.d/mod-pagespeed.repo with the help of your favourite editor and add the following lines of code to it based on your OS bit. Read More
Unzip command
Unzip files in particular directory or folder under Linux.
Syntax:
unzip {.zip-file-name} -d {/path/to/extract}
Read More
Use a Different Color for the Root Shell Prompt
Linux only: This is an excellent tip that changes the prompt to red when using the root account from the terminal—as a reminder to be more careful. Using the tip is relatively simple—just edit the /root/.bashrc file and add in the following, preferably commenting out the existing lines that set the color, though you can simply add this line to the end of the file.
Read More
How to Back Up MySQL Databases
While automated backups are important, sometimes you just want to take a quick and dirty snapshot before making a change to your data.
Creating A Backup
The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch. The process is quick and easy.
If you want to back up a single database, you merely create the dump and send the output into a file, like so:
mysqldump database_name > database_name.sql
Multiple databases can be backed up at the same time: Read More
How to add a JVM option to glassfish 4.0
How do I find out whether the options have been added or not:
asadmin list-jvm-options
You have to delete the JVM option with asadmin delete-jvm-options
:
asadmin delete-jvm-options '-XX\:MaxPermSize=192m'
How to generate UUID for network interface on RHEL/CentOS
UUIDs (Universal Unique Identifier) for network interface card can be generated using the following command (CommandShell):
uuidgen [device]
Safer Linux administration with sudo
The root account is all powerful in Linux. As humans make mistakes it is very dangerous to use root on a regular basis. By using sudo you can limit the risk of human error and prevent mistakes from happening. Read More
Number of open connections per remote host (netstat)
The following command can be used to find out the number of connections per remote hosts (which is useful to identify denial-of-service attacks):
# netstat -n | grep 'tcp\|udp' | awk '{ print $5; }' | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -n
is just faster than without the -n
parameter since it shows numerical addresses instead of trying to determine symbolic host, port or user names.
grep 'tcp\|udp'
only shows tcp and udp connections (thus removing unix sockets and headers). Read More