Monday, April 29, 2013

Thursday, April 25, 2013

Ubuntu automatically mount partition at startup

Ubuntu automatically mount partition at startup

Pada pembahasan kali ini akan membahasa tentang membuat sebuah partisi di mount pada saat startup sesuai dengan judul kasusnya untuk linux ubuntu

pada kasus ini saya ingin membuat mount partisi pada :
/etc/sda5 mount ke /media/disk-1 dan
/etc/sda6 mount ke /media/disk-2

@tanya: pertanyaanya apakah penting untuk membuat mount partisi secara otomatis pada saat startup ? padahal ketika sudah masuk ke linux bisa kita mount secara manual..?

@jawab: untuk kasus yang saya alami saat ini sangat membutuhkan mount partisi secara otomatis  karena sy membuat aplikasi yang berjalan disaat startup sedangkan settingan konfigurasi dan file-file  yang dibutuhkan berada di partisi /etc/sda6 yang di mount ke /media/disk-2


contoh kasus :
Path aplikasi yang telah saya buat  mengarah pada /media/disk-2/aplikasi-web/  dan akan berjalan ketika startup. aplikasi ini tidak akan berjalan karena  /media/disk-2 hanyalah folder kosong yang akan ada isinya jika  /dev/sda6 sudah saya dimount ke  /media/disk-2  jadi, untuk menjalankan aplikasi ini harus mount secara manual terlebih dahulu setiap komputer dinyalakan. nah hal ini sangat menggangu karena kita harus melakukan mount secara manual setiap komputer pertama kali dinyalakan.


pertama-tama  kita liat isi file /etc/fstab kurang lebih seperti ini :

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#            
proc            /proc           proc    defaults        0       0
# / was on /dev/sda1 during installation
UUID=2c0f2b7a-ad48-4928-9b3b-0c04ff3fb683 /               ext3    relatime,errors=remount-ro 0       1
# swap was on /dev/sda7 during installation
UUID=8baa30c8-fa81-4cd9-bcd1-fa38b6ff8191 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

Agar partisi  bisa di mount pada saat startup kita harus menambahkan baris baru di /etc/fstab, ikuti petunjuk berikut ini


Gunakan perintah berikut  ini untuk melihat partisi yang ada

sudo fdisk -l

output dari perintah tersebut :

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd4e5d4e5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *       17849       19457    12924292+  83  Linux
/dev/sda2               1       17848   143364028+   f  W95 Ext'd (LBA)
/dev/sda5               1        2310    18554980+  83  Linux
/dev/sda6            2551       17848   122881153+  83  Linux
/dev/sda7            2311        2550     1927768+  82  Linux swap / Solaris

untuk selanjutnya kita membutuhkan Informasi tentang UUID dari setiap partisi dengan perintah berikut :

sudo blkid

output dari perintah tersebut :


/dev/sda1: UUID="2c0f2b7a-ad48-4928-9b3b-0c04ff3fb683" TYPE="ext3" 
/dev/sda5: UUID="a80af93f-6eea-4598-be06-c5570b0a4682" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda6: UUID="21bd5e82-29b4-4b8c-bb0e-7301994c7056" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda7: TYPE="swap" UUID="8baa30c8-fa81-4cd9-bcd1-fa38b6ff8191"


setelah kita tau UUID partisi yang akan kita mount , selanjutnya kita tambahkan baris perintah di /etc/fstab seperti berikut:

#sda5
UUID=a80af93f-6eea-4598-be06-c5570b0a4682 /media/disk-1 ext3 errors=remount-ro,auto,exec,rw,user 0       0

#sda6
UUID=21bd5e82-29b4-4b8c-bb0e-7301994c7056 /media/disk-2 ext3 errors=remount-ro,auto,exec,rw,user 0       0



untuk versi lengkapnya seperti ini :

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#            
proc            /proc           proc    defaults        0       0
# / was on /dev/sda1 during installation
UUID=2c0f2b7a-ad48-4928-9b3b-0c04ff3fb683 /               ext3    relatime,errors=remount-ro 0       1
# swap was on /dev/sda7 during installation
UUID=8baa30c8-fa81-4cd9-bcd1-fa38b6ff8191 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0


# partisi sda5 kita mount ke /media/disk-1 
#note : perintah dibawah ini jadi 1 baris tanpa enter 
UUID=a80af93f-6eea-4598-be06-c5570b0a4682 /media/disk-1 ext3 errors=remount-ro,auto,exec,rw,user 0       0

#
# partisi sda6 kita mount ke /media/disk-1


#note : perintah dibawah ini jadi 1 baris tanpa enter


UUID=21bd5e82-29b4-4b8c-bb0e-7301994c7056 /media/disk-2 ext3 errors=remount-ro,auto,exec,rw,user 0       0


nah selanjutnya kita restart komputer kita dengan perintah :reboot 
sim salabim abra kadabra (selesai) aplikasi yang telah sy buat berjalan otomatis ketika  komputer dinyalakan


Tuesday, April 16, 2013

MySQL Backup fails with mysqldump: Error 2013: Lost connection to MySQL server during query'

MySQL Backup fails with mysqldump: Error 2013: Lost connection to MySQL server during query'


MySQL Backup fails with mysqldump: Error 2013: Lost connection to MySQL server during query'

This error occurs mostly while backing up MySQL databases to tape devices. The reason for this is the MySQL Settingnet_write_timeout, which defaults to a value of 60 seconds.
The tape open can take longer than 60 seconds, as such, the MySQL database resets the connection during the backup process.
This problem can be solved by adding a higher value for the variable net_write_timeout in /etc/my.cnf.
[mysqld]
 ... other options ..
net_write_timeout = 180
after adding this setting, restart your mysql daemon. If a restart is not possible the setting can also be applied online, but is lost after next restart:
# mysql -u root -p -e "set global net_write_timeout=180;"
If 180 seconds are set and the backup is still failing with the same error message, try to use a higher value for the timeout.


Monday, April 15, 2013

Solusi memperbaiki flashdisk read-only di Linux Ubuntu

Solusi memperbaiki flashdisk read-only di Linux Ubuntu
Apakah anda mengalami flashdisk tiba-tiba menjadi read-only?? Solusi nya cukup mudah, berikut ini langkah-langkahnya :
1.Buka Aplications --> Accessories --> Terminal
2.Ketik df -h (Untuk mengetahui apakah flashdisk anda dibaca sebagai sdasdb, atau sdc)
3.Setelah mengetahui letak flashdisk anda ketikkan perintah sudo dosfsck -a -v /dev/sdb1
*sdb1 adalah letak flashdisk saya, mohon disesuaikan dengan letak flashdisk anda*
Setelah selesai, lakukan safely remove drive, kemudian colokkan kembali flashdisk anda :D

Semoga bermanfaat... 




sumber

Butuh Web Responsive Murah?
googlechromecastaudio 

Replace Short Open tag menjadi Full open php tag Menggunakan Regexxer

Pernah   punya masalah  menggunakan xampp terbaru aplikasi web kita jadi tidak mau jalan karena kita menggunakan short tag?. nah penulis mengalami permasalahan itu. sebenarnya sangat mudah cukup replace

software yang sy gunakan regexxer tersedia di ubuntu. untuk windows penulis belum tau.
1. Tentukan dulu folder yang berisi php kebetulan disini penulis punya folder melodia.
2. Pattern kita isi dengan *.php 
3. kemudian klik Find File sampai muncul daftar file dibawahnya
3. kemudian Search kita isi dengan (<\?)+(?!php)
4. Dibagian Replace kita isi dengan
5. kemudian klik Find untuk mencari yang menggunakan
6. Klik All Files untuk mereplace semua file yang menggunakan
7. Save All selesai

gambar regexxer 




referensi 

Perintah-perintah penting di Ubuntu

Perintah-perintah penting di Ubuntu
Clear Bash history
history -c

If you want to use colorful "ls", that is, use colors to distinguish types of files, you can add these lines in ~/.bashrc:

if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
fi

Display Linux distributor's ID
lsb_release -is

Display Linux release number
lsb_release -rs

Display Linux code name
lsb_release -cs

Display machine hardware name
uname -m

List all PCI devices, such as display card and ethernet card.
lspci


Reclaim memory which stores pagecache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches


Display a list of modules in the Linux Kernel
lsmod


List USB devices
lsusb -v


Display the status of ethernet card
sudo ethtool eth0


List hardware
sudo lshw


List harddisk partitions
sudo fdisk -l


Display SATA harddisk parameters
sudo hdparm -I /dev/sda


Display disk space usage
df -h


Display file/folder space usage
du -bsh FOLDER_NAME


Display amount of free and used memory
free


Display processes
ps -e
Display a tree of processes
pstree
Display processes dynamically
top


Terminate a process with a given process id
sudo kill -9 PROCESS_ID


Terminate all processes with a given name
sudo killall PROCESS_NAME


List files which are opened by a given process
lsof -p PROCESS_ID
lsof -c PROCESS_NAME


List processes which opened a given file
lsof FILE_NAME


List processes which are using port 80
lsof -i :80


Configure an ADSL connection
sudo pppoeconf


Starts up ADSL connections
sudo pon
Shuts down ADSL connections
sudo poff


Display MAC of a given IP address
arping IP_ADDRESS


Display NetBIOS name of a given IP address
nmblookup -A IP_ADDRESS


Display IP address and MAC
ifconfig -a


Display route
netstat -rn


Set MAC of ethernet interface
sudo ifconfig eth0 hw ether 00:11:22:33:44:55


Display information of a domain name
whois example.com


Display the network path to a given host
tracepath example.com


Request an IP address from DHCP server
sudo dhclient


Temporarily restart an init script
sudo /etc/init.d/SCRIPT_NAME restart
Temporarily stop an init script
sudo /etc/init.d/SCRIPT_NAME stop


Add a user
sudo adduser USER_NANE
Delete a user
sudo deluser USER_NAME


Change user password
sudo passwd USER_NAME


Changes user fullname, office number, office extension, and home phone number information.
sudo chfn USER_NAME
Display user information
finger USER_NAME


Temporarily prevent a user from logging in
sudo usermod -L USER_NAME
Revoke the operation above
sudo usermod -U USER_NAME


Add a user to admin group
sudo usermod -G admin -a USER_NAME


Set the HTTP proxy
export http_proxy=http://PROXY.DOMAIN.NAME:PORT


Modify the information displayed after logging in
sudo vim /etc/motd.tail


Choose the input method for X Window
im-switch -c


Convert the file name from GBK to UTF8
convmv -r -f gbk -t utf8 --notest FILE_NAME


Convert the file content from GBK to UTF8
iconv -f gbk -t utf8 FILE_NAME


Convert tags in '*.mp3' from GBK to UTF8
find . -name '*.mp3' -execdir mid3iconv -e GBK {} \;


Read a long file
less FILE_NAME


Print lines matching a pattern
grep REG_EXP FILE_NAME


Display a list of file name. The files contain a given string.
grep -lr REG_EXP PATHNAME


Display all '.txt' file
find . -name '*.txt'


Create two empty files
touch file_name_1 file_name_2


Create directory. Create parent directories as needed.
mkdir -p /tmp/a/b/c/d/e


Change working directory to the home folder
cd
Change working directory to the previous working directory
cd -


Display hidden files
ls -a


Copy directory. Preserve links, file mode, ownership, timestamps.
cp -a SOURCE_DIRECTORY DEST_DIRECTORY


Determine file type
file FILE_NAME


Output the last 6 lines
tail -n 6 FILE_NAME


Copy files via SSH
scp -rp FILE_NAME USERNAME@HOST:DEST_PATH


Rename '*.rm' files to '*.rmvb' files
rename 's/.rm$/.rmvb/' *


Change the file name to lowercase
rename 'tr/A-Z/a-z/' *


Display subdirectories in current directory
ls -d */.


Display file number in current directory
ls . | wc -w


Extract "*.gz" file
gunzip FILE_NAME.gz
Extract "*.tar.gz" file
tar zxf FILE_NAME.tar.gz
Extract "*.tar.bz2" file
tar jxf FILE_NAME.tar.bz2


Do compression
tar czf FILE_NAME.tar.gz FILE1 FILE2 FILE3
tar cjf FILE_NAME.tar.bz2 FILE1 FILE2 FILE3


Displays a calendar
cal
cal MONTH YEAR


Set the date and time via NTP
sudo ntpdate ntp.ubuntu.com


Poweroff your computer
sudo halt
sudo shutdown -h now
Poweroff your computer in 23:00
sudo shutdown -h 23:00
Poweroff your computer after 60 minutes
sudo shutdown -h +60


Reboot your computer
sudo reboot
sudo shutdown -r now


If you want some program to start up automatically, please put '.desktop' files into '~/.config/autostart'


You can configure "preferred applications" by this file "~/.local/share/applications/mimeapps.list"


Continuously monitor the memory usage
watch -d free


Display HTTP HEAD response
w3m -dump_head http://example.com


Display file content with line number
nl FILE_NAME


Eliminate Rootkit
sudo rkhunter --checkall


Change hostname
sudo hostname new_name


"Tasksel" group software packages into "task"s. You can select a "task" and then install all necessary software packages. It is easy to set up LAMP servers or cloud computing servers.
Show all tasks
tasksel --list
Display the extended description of a task
tasksel --task-desc lamp-server
List the packages which are parts of a task
tasksel --task-packages lamp-server
Install/remove a task
gksudo tasksel


Change Process priority
renice NEW_PRIORITY `pgrep NAME_OF_PROCESS`
example: renice 5 `pgrep firefox`
renice -5 `pgrep wine-server`
high <------------------> low
NEW_PRIORITY = -19, -18, -17 [...] 18, 19, 20


~/.thumbnails/ directory is a cache dir GNOME makes when you browse through your folders in nautilus.
It contains thumbnail pictures of picture files you've previously looked at.

You can get its total size by
du -bs ~/.thumbnails/

You can delete the files in the .thumbnails directory that haven't been accessed for seven days, to free disk space.
find ~/.thumbnails/ -type f -atime +7 -exec rm {} \;


Capture screen after 10 seconds
gnome-screenshot -d 10
Capture current window after 10 seconds
gnome-screenshot -wd 10


Start GConf editor:
Press Alt+F2, type 'gconf-editor'.

Set apt source
sudo software-properties-gtk
sudo software-properties-kde

Display the packages which are not installed but have remained residual config
dpkg -l | awk '/^rc/ {print $2}'


Add a PPA repository:
sudo add-apt-repository ppa:PPA-REPOSITORY-NAME


Display a list of files. The files are installed from a given package.
dpkg -L PACKAGE_NAME


Display a list of packages. The packages installed a given file.
dpkg -S FILE_NAME


Display a list of packages. The name of packages matches given regex pattern.
apt-cache search REG_EXPRESSION


Display a list of packages. The packages provide a given file.
apt-file search FILE_NAME


Display a list of packages. The given package depends on the list of packages.
apt-cache depends PACKAGE_NAME


Display a list of packages. These packages depend on the given package.
apt-cache rdepends PACKAGE_NAME


Prompt for a disk to be inserted and then add the disc to the source list.
sudo apt-cdrom add


Install the newest versions of all packages currently installed on the system.
sudo apt-get upgrade


Delete residual package configuration files.
dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P


Automatically install necessary files for './configure ; make ; make install'
sudo auto-apt run ./configure


Save the list of packages currently installed on your system.
dpkg --get-selections | grep -v deinstall > SOME_FILE
Then use the file to restore packages.
dpkg --set-selections < SOME_FILE ; sudo dselect


After running "sudo apt-get install", "*.deb" files are stored in "/var/cache/apt/archives"
You can clean this directory by:
sudo apt-get clean


Display URL for a given package
apt-get -qq --print-uris install PACKAGE_NAME


Display some statistics about the apt cache
apt-cache stats


Display all package name
apt-cache pkgnames


Display some information of a given package
apt-cache show PACKAGE_NAME