Command

warning: Creating default object from empty value in /home/www/virtual/phaisarn.com/sun/htdocs/modules/taxonomy/taxonomy.pages.inc on line 33.

Releasing And Renewing Your IP Address In Ubuntu

sudo ifconfig eth0 down (shuts down the eth0 interface, releases the IP)

sudo ifconfig eth0 up (enables the eth0 interface, renews the IP)

sudo /etc/init.d/networking restart

Ref: http://www.pcmech.com/article/releasing-and-renewing-your-ip-address-in-ubuntu/

Time command

$ time ls
real    0m0.005s
user    0m0.004s
sys    0m0.000s

        * The elapsed (real) time between invocation of utility and its
termination.

* The User CPU time, equivalent to the sum of the tms_utime and
tms_cutime fields returned by the times() function defined in the
System Interfaces volume of IEEE Std 1003.1-2001 for the process in
which utility is executed.

Basic Commands

คำสั่งต่างๆที่จำเป็น เช่น
df -h ดูการใช้พื้นที่ Harddisk
du -sh folder_name ดูการใช้พื้นที่ของแต่ละ folder
 
ที่มา: UsingTheTerminal, Basic Commands

Mount

แสดงรายระเอียดการ mount ที่เป็นอยู่
mount
ทำการ mount
mount /src /des

Zip บน Ubuntu

คำสั่ง Unzip บน Ubuntu
unzip <filename>.zip
ที่มา: FileCompression

การให้สิทธิใน MySQL

การให้สิทธิใน MySQL ใช้คำสั่ง Grant เช่น
grant all on *.* to jack@localhost identified by 'xxxx';
เป็นการให้สิทธิทั้งหมดแก่ user jack@localhost
แต่ถ้าต้องการให้สิทธิบางส่วนเช่น ให้สิทธิเฉพาะฐานข้อมูลที่กำหนดให้ใช้ึคำสั่ง
grant all on mydb.* to jack@localhost identified by 'xxxx';
ที่มา: GRANT Syntax

Run a system command automatically at startup

กำหนดคำสั่งที่จะเรียกใช้ (ในที่นี้คือ /home/user/command) ไว้ใน crontab ดังนี้

sudo crontab -e
@reboot /home/user/command

หรือจะพิมพ์คำสั่งไว้ใน text ไฟล์ แล้วใช้คำสั่ง crontab textfile ก็ได้
ที่มา: help.ubuntu.com/6.10/ubuntu/desktopguide/C/ch10s04.html

MySQL: คำสั่ง Backup Database และ Table

คำสั่ง Backup Database

  • $ mysqldump -u user_name -p db_name > file_name

คำสั่ง Backup Table

  • $ mysqldump -u user_name -p db_name table_name > file_name

ที่มา: dev.mysql.com

การใช้งานคำสั่ง tar บน linux

ตัวอย่างไฟล์งานชื่อ test

วิธีรวมเป็นไฟล์เดียว
tar -cvf test.tar test
ผลลัพธ์จะได้ไฟล์ test.tar

วิธี zip
gzip test.tar
ผลลัพธ์จะได้ไฟล์ test.tar.gz

วิธี unzip
tar -zxvf test.tar.gz
ผลลัพธ์จะได้ไฟล์ test

อ้างอิง expert2you.com

สร้างฐานข้อมูลด้วย command line

ฐานข้อมูลสามารถสร้างได้ด้วยการพิมพ์คำสั่งทาง command line ดังนี้

sudo mysqladmin -u username -p create databasename

Syndicate content