Howto Format Hard Disk on Linux Console

Filed in Linux System Leave a comment

1. Use “fdisk /dev/path-to-your-device” to create new partition
2. “mkfs.ext4 /dev/cciss/c0d1p1″ to create new file system
3. “blkid” to find hard disk UUID
4. Edit “/etc/fstab” to permanently add your new partition
5. Restart server

Grub2 in Ubuntu Server

Filed in Network and Server Leave a comment

Do not user “vga=” parameter, it is deprecated. Edit /etc/default/grub, and uncomment:

GRUB_GFXMODE=640x480

Edit /etc/grub.d/00_header search for:

set gfxmode=${GRUB_GFXMODE}

on the next line, insert:

set gfxpayload=keep

verify that the new line is before insmod gfxterm

# update-grub2
# reboot

PHP 5.3.x Deprecated Function

Filed in Web Development Leave a comment

Error log: Assigning the return value of new by reference is deprecated in ….
Deprecated: $_VERSION =& new version();
Suggestion: $_VERSION =& new version();

Process Management

Filed in Linux System Leave a comment

Check certain process:
ps aux | grep <keyword>

Check what files are being used by a process:
lsof -p

Kill a process
kill -9 <pid>

File Management (Move, Delete, Copy, Find)

Filed in Information Technology Leave a comment

Find any big files:
Do you maintain web server, and you worry if users trying to use your server to download movie file?
find . -size +60M

Find multiple filetypes:
find . -iname *.jpg -o -iname *.gif -o -iname *.pdf -o -iname *.png

Find then execute:
You want to search all .php files and then chmod to make them unreadable by other users?
find . -iname *.php -exec chmod 700 {} \;

Package Management

Filed in Linux System Leave a comment

Prevent a package to be installed, upgraded, or removed:
aptitude install <package>=

Reconfigure broken package configuration:
It’s a handy tool if you have libapache2-mod-suphp and libapache2-mod-php installed, but you want to remove one of them, because sometimes Apache doesn’t know what you prefer; PHP or SuPHP.
dpkg-reconfigure <package>

Download a package without install:
apt-get -d install <packageName>

Make A New Partition with FDisk

Filed in Linux System Leave a comment

Assume we have /dev/sda:
1. fdisk /dev/sda
2. Create a new partition: type ‘n’
3. Choose logical or primary partition: type ‘l’ or ‘p’
4. Set the size you want,
5. Write the changes you have made: type ‘w’
6. Exit from fdisk, then make a new file system, for example: mkfs -t ext4 /dev/sda3

suPHP

Filed in Network and Server Leave a comment

How to override php.ini:
1. If you allow user to override php.ini, then edit /home/user/public_html/.htacces :

suPHP_ConfigPath /home/user

Or if you don’t want user freely edit their php.ini file, then add these directive in virtual host configuration /etc/apache2/sites-enabled/:

<VirtualHost *:80>

…………………

IfModule mod_suphp.c
suPHP_ConfigPath /home/perpus
</IfModule>
</VirtualHost>

2. Copy /etc/php5/cgi/php.ini into /home/user/php.ini, then edit accordingly. Warning, if you just create a new php.ini and add a few options in it, then the other options (max upload, disabled function, etc) will be resetted in to default php configuration. So, it will be better if you copy from the main php configuration.

Secure Shell – SSH

Filed in Linux System Leave a comment

Dynamic Port Forwarding :

ssh -D 1080 aji@proxy2.bpk.go.id

Date and Time

Filed in Linux System Leave a comment

Set localtime:
#ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime

Check timezone:
#cat /etc/timezone

Check date and timezone:
#date -R

TOP