I have a large text file (its a log file actually) and I need to truncate each line to about 16 characters.
cut -c1-16 /path/to/filename > /path/to/output_filename
output_filename will contain the result.
Tuesday, August 2, 2011
Some useful sed commands
to remove the first line of a file from our output stream
$ sed -e '1d' filename | more
to delete lines 1-10 of the output
$ sed -e '1,10d' filename | more
to delete lines that start with a "#" from files
$ sed -e '/^#/d' filename | more
to print only virtualHosts in apache conf
$ sed -n '/^ /path/to/httpd.conf
$ sed -e '1d' filename | more
to delete lines 1-10 of the output
$ sed -e '1,10d' filename | more
to delete lines that start with a "#" from files
$ sed -e '/^#/d' filename | more
to print only virtualHosts in apache conf
$ sed -n '/^ /path/to/httpd.conf
Tuesday, July 26, 2011
Delete a file using Inode number
You can delete a file using it's inode number as follows.
find . -inum 88 -exec rm -i {} \;
This will find the file with inum 88 in the present directory and delete it.
find . -inum 88 -exec rm -i {} \;
This will find the file with inum 88 in the present directory and delete it.
Kernel Compilation
Kernel Compilation
KERNEL DOWNLOAD: Download the latest one
http://www.kernel.org/pub/linux/kernel/v2.6/
linux-2.6.20.tar.bz2
tar jxf linux-2.6.20.tar.bz2
http://www.linuxelectrons.com/News/HowTO/20040315152255759
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.4.27-grsec/kernel/ -iname ${i}.o ; done | wc
lsmod | wc
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.4.28-grsec/kernel/ -iname ${i}.o ; done |wc
In 2.6 kernel
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.6.20/kernel/ -iname ${i}.ko ; done
cd /usr/src/linux-2.6.24
make clean
make mrproper
make menuconfig
in general tab
==> Processor Type and Features
==> High Memory support
==> select 64 bit
go to general
==> Power management
==> Disable Cpu Scaling
go to general
==> Networking
==> Networking option
==> network packet filtering framework -> netfilter
==> enable network packet filtering debugging
==> core net filtering
==> select all as modules
come back
==> IP net filter
==> select All
go to general
==> Decice Drivers
==> Serail ATA LibATA or Serial ATA Parallel ATA
==> Select all INTEL as modules
==> select libata
==> Select Intel ESB|IDH|PIIX3|PATA
go to genral
==> FileSystem
==> make sure ext2/ext3 enabled
go back to general
==> Quota support On
make
make modules_install
make install
To boot once with the currently compiled kernel use below. Further reboots will be done on the existing kernel.
echo "savedefault --default=2 --once" | grub --batch
reboot
Remember to replace "2" to match your own config!
KERNEL DOWNLOAD: Download the latest one
http://www.kernel.org/pub/linux/kernel/v2.6/
linux-2.6.20.tar.bz2
tar jxf linux-2.6.20.tar.bz2
http://www.linuxelectrons.com/News/HowTO/20040315152255759
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.4.27-grsec/kernel/ -iname ${i}.o ; done | wc
lsmod | wc
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.4.28-grsec/kernel/ -iname ${i}.o ; done |wc
In 2.6 kernel
for i in `lsmod | awk {'print $1'}`; do find /lib/modules/2.6.20/kernel/ -iname ${i}.ko ; done
cd /usr/src/linux-2.6.24
make clean
make mrproper
make menuconfig
in general tab
==> Processor Type and Features
==> High Memory support
==> select 64 bit
go to general
==> Power management
==> Disable Cpu Scaling
go to general
==> Networking
==> Networking option
==> network packet filtering framework -> netfilter
==> enable network packet filtering debugging
==> core net filtering
==> select all as modules
come back
==> IP net filter
==> select All
go to general
==> Decice Drivers
==> Serail ATA LibATA or Serial ATA Parallel ATA
==> Select all INTEL as modules
==> select libata
==> Select Intel ESB|IDH|PIIX3|PATA
go to genral
==> FileSystem
==> make sure ext2/ext3 enabled
go back to general
==> Quota support On
make
make modules_install
make install
To boot once with the currently compiled kernel use below. Further reboots will be done on the existing kernel.
echo "savedefault --default=2 --once" | grub --batch
reboot
Remember to replace "2" to match your own config!
Wednesday, July 6, 2011
remote mysqll connection
1. remote mysqll connection
mysql -u username -h iP
2. Remote mysql dump
mysqldump -u root -h 192.168.28.179 stol3_site > stol3_site.sql
3. remote mysql restore
mysql -u root -h 192.168.28.179 steinbac_site < stol3_site.sql
mysql -u username -h iP
2. Remote mysql dump
mysqldump -u root -h 192.168.28.179 stol3_site > stol3_site.sql
3. remote mysql restore
mysql -u root -h 192.168.28.179 steinbac_site < stol3_site.sql
Unable to delete database from cpanel
1) Edit /var/cpanel/databases/dbindex.db and /var/cpanel/databases/dbindex.db.org and remove lines referencing the databases to be removed
2) Edit /var/cpanel/databases/rasheedb.yaml and /var/cpanel/databases/rasheedb.yaml.org and remove lines referencing the databases to be removed
3) `/usr/local/cpanel/bin/setupdbmap`
4) `/scripts/update_db_cache`
2) Edit /var/cpanel/databases/rasheedb.yaml and /var/cpanel/databases/rasheedb.yaml.org and remove lines referencing the databases to be removed
3) `/usr/local/cpanel/bin/setupdbmap`
4) `/scripts/update_db_cache`
Maldet scan
maldet --scan-all /home?/?/public_html
root@server01 [/home/examisp/public_html] maldet --scan-all ./
root@server01 [/home/examisp/public_html] maldet --scan-all ./
Subscribe to:
Posts (Atom)