Home Page of Alberto Lepe Garza
About Computers
About Computers

About LinuxAbout Linux

How to's:

This is a list of quick how-to's that I personally consider them very useful:

How to benchmark a web site:
# install apache2-utils (apache ab tool)
# then:
ab -n 1000 -c 100 http://server/index.php
-n = number of conections
-c = multiple connections at once
How to create ISO (images) from a directory
mkisofs -o /tmp/cd.iso /tmp/directory/

How to mount an ISO file

mount -o loop /path/to/file.iso /path/to/mount/point
mount -t iso9660 myimage.iso /mnt/cdrom -o loo
How to create a swap file (in order to use files instead the default swap partition)
dd if=/dev/zero of=/data/swapfile.1 bs=1024 count=65536   (65 MB)
mkswap /data/swapfile.1

# Add the next filet to /etc/fstab: (Automatic)
/data/swapfile.1 none swap pri=5,defaults 0 0

# To start it manually:
swapon /data_c2/swapfile.1

# To stop it manually:
swapoff /data_c2/swapfile.1
How to create a .tar.gz or .tar.bz2 from a directory
# tar.gz   :
tar cpvzf this_is_a.tar.gz this_dir/
# tar.bz2 :
tar cpvyf this_is_a.tar.bz2 this_dir/
# or
tar cpvjf this_is_a.tar.bz2 /this_dir
How to enable HDD dma (improve HDD performance!)
# READ MANUAL FIRST!
# man hdpram

hdparm -d1 -X udma2 -u1 -k1 -c1 /dev/hda
How to enable PageUp command history (very useful!)
# Uncomment on /etc/inputrc
"e[5~": history-search-backward
"e[6~": history-search-forward
How to format with ext3 FS
cfdisk /dev/hda
- type:83
mkfs.ext3 -m 0 -T largefiles -L disc1 /dev/hda1
(m 0 is to prevent SuperUser extra space, optional)
(-T largefiles = 1MB , largefiles4 = 4MB)
How to recover lost files in ext3 FS
# Only TXT files can be recovered:
umount partition

# Dump all strings: (takes longer and generate large files)
strings /dev/hda2 > big_text_file

# other faster option (-50 means copy only 50 lines before/after)
grep --binary-files=text -50 "textToSearch" /dev/hda2 > output
How to setup fsck at startup
# -c counts -iNUM[d/w/m] device
tune2fs -c 50 -i 1m /dev/hdb1

# Skip fsck at next boot:
tune2fs -c 0 -i 0 /dev/sda3
How to install a .deb package
sudo dpkg -i .deb
How to install a font
# In Slackware:
fc-cache -vf
/usr/X11R6/bin/mkfontdir
/usr/X11R6/bin/mkfontscale

# In Ubuntu... (bitmap fonts)
cp *.pcf /usr/share/fonts/X11/misc/ o /usr/share/X11/fonts/misc
cp *.bdf /usr/share/fonts/X11/Type1/

mkfontdir (in each directory)
xset fp rehash
sudo fc-cache -vf
sudo dpkg-reconfigure fontconfig-config (and say "YES" to bitmap fonts)

# If you want to show the X fonts installed
xfontsel

How to Enable Japanese IME (Ubuntu)
1. sudo apt-get install uim anthy scim-gtk2-immodule scim-uim

2. /etc/X11/Xsession.d/
create: 78japanese_ime

export XMODIFIERS="@im=SCIM"
export GTK_IM_MODULE="scim"
export XIM_PROGRAM="scim -d"
export QT_IM_MODULE="scim"

3. sudo dpkg-reconfigure locales

4. Add for autostart (optional)
How to modify the runlevel in startup scripts
rcconf
bum
How to print System calls
strace -f -e open /usr/bin/mpg123 -q test.mp
How to control processes (very useful)
command & (to send to background)

command (...running...)
[CTRL+Z] = stop
bg 1 (send process to back) (also bg %1)
ps (list processes) // also check pstree
jobs (for checking id#)
fg 1 (send to forward)
[CTRL+C] = kill

kill %1 = kill that process

nice (to run in other priority)
renice (to resetup it)

screen (start new session)
screen -R (restore last session)
How to run your current installation of Windows (raw installation)
inside VMware in Linux (the easiest way it worked for me)

1. Follow the "normal" steps to add a raw OS over a physical partition.
2. If both are in the same disk then mount all drive and let GRUB to manage boot. (skip to 6)
3. If are in separate disks, fixboot and fixmbr from windows recovery console with only that disk mounted inside vmware
.
4. Adjust BIOS to boot with Linux disk.
5. Adjust GRUB to reflect changes.
6. Boot normally to Windows and create a new hardware profile.
7. Install bootcamp_registryfix.zip or mergeIDE to fix registry to work under virtual environment.
8. Restart and start Linux and VMware, install VMWare Tools.
Enjoy!
How to rename a file that starts with "--" (confusion with --argument)
# Add ./ at the beginning
mv ./-stuff differentstuff
How to scan ports
nmap -sS localhost
How to show bin dependecies
ldd /usr/bin/aplay
How to show kernel version
uname -r
How to search for an specific string within some files modified after certain date
touch -d "08 april 2008 00:00:00" find_date
find . -newer find_date -name "*.php" -exec grep -q "print_r" '{}' \; -print > result
How to add a startup script in Ubuntu
sudo cp myscript.sh /etc/init.d/ (copy your script)
sudo chmod +x /etc/init.d/myscript.sh (set execution permit)
update-rc.d myscript.sh defaults (add it to start-up)
update-rc.d -f myscript.sh remove (to remove)


I hope they were useful for you :)

Site Map - CopyLeft 2008 - Powered by Yayahuic Framework - Made by Alberto Lepe G.
Check http header Validate webpage Validate style sheet Check accessibility