Using SED command line to delete line from a file.
d Delete pattern space. Start next cycle.
You can use the following one liner to remove one line (line 3) from a file.
$ sed -i 3d ~/.ssh/known_hosts
This will remove line 3 form the file ~/.ssh/known_hosts
How to Disable IPv6 in Apache Server
If there is no reason to run Apache with IPv6 then disabling it is wasy. We need to make quick changes to the Listen directive.
By default, Apache will listen on all IPs, both IPv6 and IPv4. (Assuming your system has IPv6 support). This is controlled by the Listen directive:
Turn off IPv6 in Apache
To turn off IPv6 in Apache, just change the Listen directive to:
This will limit Apache to listening only to IPv4 connections. We can repeat this for port 443 if you want to stop Apache from listening for HTTPS on IPv6.
Finding help content for MySQL databases administration.
Run ‘help contents’ for a list of all accessible topics
mysql>
help contents
You asked for help about help category: “Contents” For more information, type ‘help [item]‘, where [item] is one of the following categories:
Account Management
Administration
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Language Structure
Table Maintenance
Transactions
User-Defined Functions
Utility
To go to the individual catefories run the following example command.
mysql>
help Account Management
You asked for help about help category: “Account Management” For more information, type ‘help [item]‘, where [item] is one of the following topics:
CREATE USER
DROP USER
GRANT
RENAME USER
REVOKE
SET PASSWORD
Creating and editing users in MySQL from shell prompt.
First we need to login into MySQL server as root.
Will be prompted for your MySQL root password (note this is not the same as the server root password).
mysql> create user ‘buddy@localhost’ identified by ‘new-password’;
Query OK, 0 rows affected (0.12 sec)
Next we need to flush the privileges which reloads the ‘user’ table in MySQL - do this each time you add or edit users.
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
To give the user buddy select permission on all the databases, this allows the user to read, but not edit and delete.
mysql> grant select on *.* to ‘buddy’@'localhost’;
Query OK, 0 rows affected (0.00 sec)
The GRANT statement enables system administrators to create MySQL user accounts and to grant rights to accounts. To use GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting. The REVOKE statement is related and enables administrators to remove account privileges.
Backup using the dd command
`dd’: Convert and copy a file
`dd’ copies a file (from standard input to standard output, by default)with a changeable I/O block size, while optionally performing conversions on it. Synopses:
dd [OPERAND]…
dd OPTION
The only options are `–help’ and `–version’.
For instance, to make an exact clone of the /boot partition to a backup file, you could use:
# dd if=/dev/sda1 of=/srv/boot-linux.img
We can also use bzip2 to compresses files and then bunzip2 (or bzip2 -d) decompresses all specified files.
To clone one hard disk to another first use fdisk to recreate the appropriately-sized partitions, on the new disk and then use dd to do the actual cloning.
dd –help
Usage: dd [OPERAND]…
or: dd OPTION
Copy a file, converting and formatting according to the operands.
bs=BYTES force ibs=BYTES and obs=BYTES
cbs=BYTES convert BYTES bytes at a time
conv=CONVS convert the file as per the comma separated symbol list
count=BLOCKS copy only BLOCKS input blocks
ibs=BYTES read BYTES bytes at a time
if=FILE read from FILE instead of stdin
iflag=FLAGS read as per the comma separated symbol list
obs=BYTES write BYTES bytes at a time
of=FILE write to FILE instead of stdout
oflag=FLAGS write as per the comma separated symbol list
seek=BLOCKS skip BLOCKS obs-sized blocks at start of output
skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input
status=noxfer suppress transfer statistics