Category Archives: Linux Command Line

Linux – Cut Lines

Very useful when you pipe it, for example, for easily reading a file containing very long quries cat queries.sql | cut -b -10

Posted in Linux Command Line | Tagged | Leave a comment

MySQL – Importing Many SQL Dump Files in a Database

ls *.sql | awk ‘{printf(“mysql -u [username] -p[password] [databasename] < %s\n”, $1) | “/bin/sh” }’

Posted in Linux Command Line, MySQL | Leave a comment

Add An Entry In Fstab to Mount a Common Data Partition

Add this row into your /etc/fstab: /dev/hda6 /mnt/data auto rw,uid=1000,utf8 0 0

Posted in Linux, Linux Command Line | Tagged , | Leave a comment

Linux – How To Split a Big File Into Several Small Files

split –bytes=1m /path/to/large/file /path/to/output/file/prefix You can change the output file size by changing the –bytes=1m to your preference. You can use b, k, or m. b represent bytes, k represent kilobytes, m represent megabytes. To restore the original file: cat … Continue reading

Posted in Linux Command Line | Tagged | Leave a comment

Rsync – Deploy And Increment Backup

It’s good for deploy as well. It can be used locally (like this: rsync -aHvzO –progress staging/ www/). Very useful to move big amount of data over the Internet because of its incremental feature. By default it uses SSH for … Continue reading

Posted in Linux Command Line, System Administration | Leave a comment

Linux Command Line – Bash Scripting – Some tricks

wc – print newline, word, and byte counts for each file (program for count statistics from a file) dt = $(date) ls -l > files.txt 2>error.txt Redirects standard error to a file ls -l > files.txt 2>&1 Redirects standard error … Continue reading

Posted in Linux Command Line | Leave a comment

Linux Bash – Find Out Info About Your CPU

less /proc/cpuinfo uname -a x86_64 GNU/Linux indicates I have 64bit kernel running. If you use see i386/i486/i586/i686 it is a 32 bit kernel. grep flags /proc/cpuinfo * lm means Long mode – 64 bit CPU * Real mode 16 bit … Continue reading

Posted in Linux Command Line | Leave a comment

Linux Bash – Change The Prompt

To print your current prompt: echo $PS1 To set a new prompt: PS1=”[\u@\h \w]\$” That’s very useful as it display the absolute working directory path If you want to keep this change append the previous line to this file (using … Continue reading

Posted in Linux Command Line | Leave a comment

Linux Bash – Colour the Name of Directory and Files

alias ls=’ls –color’ If you want to make this changes permanent, append the line to the file: /home/username/.bashrc

Posted in Linux Command Line | Leave a comment

Linux – Download Automatically an Entire Website

wget -k –wait=20 –limit-rate=20K –no-parent -r -p -U Mozilla http://www.symfony-project.org/api/1_1/ -k -> make the links work in the local version (very very very cool) –wait=20 –limit-rate=20K -> make our requests not too fast and band consuming…that to be fair and … Continue reading

Posted in Linux Command Line | Leave a comment