-
My Windows recipes:
(back to top)
- To get some basic information about network settings:
- ipconfig /all => to get netcard configuration info.
- ping www.yahoo.com => to check if www.yahoo.com is connectable from your computer.
- tracert www.yahoo.com => to check which part of the internet connection between your computer and www.yahoo.com is broken.
- When you can not get the sound out in
WinXP, try the two methods one by one:
- Start => Control panel =>
Sound, voice and audio => sound and audio devices => (in the
"volumn" tab, make sure that "mute" is not
ticked) => properties => (make sure that none of the control
are set to mute or set zero volumn)
-
Start => Run => (input by hand the command) dxdiag => (in the pop-up DirectX
diagnostic panel) chose Sound tab => test DirectSound => (if
the test is successful) => chck if you have sound now, if not
=> chose Music tab => test different listed music ports.
- display remote client in Cygwin X:
- Enter Cygwin, type 'startx' to start X
- In the pop-up Xterm, type 'ssh -Y user@remote.server.ip'
- then, in the remote server, you can start X service.
- My Linux recipes:
(back to top)
- Linux system programming (inlude shell scripts): see http://learn.akae.cn/media/pt03.html
- ----------system rescue-------------
(from http://www.centos.org/docs/2/rhl-cg-en-7.2/rescuemode.html)
- Fail to boot linux from you harddisk, try to log in with rescue mode:
- have a boot diskette or RedHat Linux installation CD-ROM #1 or network boot disk or PCMCIA boot disk in hand;
- type boot rescue
- type Continue to mount your file system
- If successful, you will be logged in in a single user mode;
- Your file system is mounted at /mnt/sysimage;
- type <Ctl>+<Alt>+<F1> and <Ctl>+<Alt>+<F2> to shift between the two provided vertual consoles VC1 and VC2 when you need.
- Then you can do anything you want to repair the system. Many commands are available now.
- If you need root authority to do some repair, e.g, to run rpm, then
- type chroot /mnt/sysimage
- type exit after you finish the tasks as root user.
- or type Skip to log in without mounting any file system (e.g., if your file system is corrupt)
- you can manually mount any partitions:
- type fdisk -l to check your partitions
- then, mkdir /foo
- type eg.: mount -t ext3 /dev/hda5 /foo to mount the partition hda5 to the position /foo
- You can directly log in in single-user mode (useful when your ssytem can boot but can not finish login):
- For GRUB users:
- type 'p' and enter your GRUB password (if password is set);
- select the kernel that you want to boot and type e to edit the boot options;
- go to the end of the boot prompt line and add a single word 'single', type <Enter> to finish edit;
- go back to GRUB screen and type 'b' to boot into the single-user mode.
- For LILO users:
- Exit the graphic LILO interface by <Ctl>+<x>;
- boot: linux single
- For linux installation disk boot:
- linux single root=/dev/hdXX initrd=
- You can also login with emergency mode, which is useful when your init file is corrupted:
- Exit the graphic LILO interface by <Ctl>+<x>;
- boot: linux emergency
- Then you will get a readonly system and can mount your file system by hand to rescue files
- When you can not log into your linux but are dropped into a readonly root shell (emergency mode), you can remount your disk into 'rw' for maintainence by: mount -o remount rw
- ----------set environments-------------
- Boot multiple OS with GRUB or LILO: edit the configuration file /boot/grub/grub.conf or /etc/lilo.conf.
- Add a path:
- First use this command to check your current PATH: echo $PATH
- Then, set PATH=$PATH:/home/jhhe to add a new path '/home/jhhe' to the list.
- Or you can add such commands in your .bashrc or .bash_profiles to automatically get it set when you open a new terminal.
- ----------check info-------------
- Check system info: top (like the TaskManager in MS Windows) (see introduction here in chinese.)
-
Check Linux version: cat /etc/issue (Some
kernal files with attached version numbers can be also found under the
directory /boot.)
-
Check CPU info: cat /proc/cupinfo
-
Check display card info: /sbin/lspci |grep VGA
-
Check hardware info: hwbrowser (for
superuser only)
-
----------hardware related-------------
-
Mount USB: (1) login as superuser; (2)
make a directory: #>mkdir /mnt/usb; (3) type #>mount -t vfat /dev/sda1 /mnt/usb.
-
Mount devices or filesystems automatically:
add in the file /etc/fstab a line like: "/dev/hda5
/mnt/dosd vfat defaults
0 0 ", then you will mount your disk
"/dev/hda5" to a directory "/mnt/dosd" after you
restart your X. Add "codepage=936" in the end of the line
enable display of Chinese characters.
-
----------network related-------------
- To change IP address, netmask, gateway, hostname:
- take effect instantly:
- # ifconfig eth0 192.168.0.20
netmask 255.255.255.0
-
# route add default gw
192.168.0.254
-
# edit file: /etc/resolv.conf
-
# hostname fc2
- take effect after reloading network:
- edit file /etc/sysconfig/network-scripts/ifcfg-eth0
to add IPADDR, NETMASK, AND GATEWAY.
-
edit file /etc/resolv.conf to add
nameservers: nameserver ###.###.###.###.
-
edit file /etc/sysconfig/network
to modify hostname.
- ----------display related-------------
- To display graphics from a remote server:
-
step 1: add remote server in your xhost list on your local
computer by running: xhost +
remote_server_IP
-
step 2: ssh to remote server with
option "-X"and run
graphic application remotely. Without "-X", the remote server will complain that it doesn't
have the permission to run remote applications on your local
computer. Warning, the option "-X" can only be used to
safe servers due to securaty problem.
-
(step 3:) in rare case when ssh fail to set the environment
variable DISPLAY on the remote server when logging in, you may try
to set it by hand by issuing on the remote server: setenv DISPLAY local_computer_IP:0.0 in bash
or export DISPLAY=local_computer_IP:0.0. (Usually we don't need this step!!)
-
----------software related-------------
-
To make plots and simple mass computations: gnuplot (install with yum), pyxplot (download separately), plplot (install with yum), pgplot (download separately).
- To install, remove, update software packages:
<yum [install, localinstall, remove,
erase, clean, update, provides, list, search, info] "package
name"> or <rpm [-ivh, -Uvh,
-]>
-
Mount fs with Chinese support: mount -t vfat -o iocharset=cp936 /dev/hda5
/mnt/dosd
-
To configure redhat Linux: run commond
"redhat-config-*". E.g., run
redhat-config-network to configure networks.
- To install ifort (Intel (R) Fortran
Compiler):
-
Go to Intel
download page for free non-commercial edition and follow the
instructions there to give your email information to get serial number, then download the tarball file;
-
login as root, unzip the tarball file
by: tar -zxvf l_cprof_p_11.0.069.tgz
(for an example)
-
cd into the unzipped file system until you go to .../bin/ to find and execute the instal file: ./install.sh
-
if the install program remind you that you still don't have the
library file libstdc++.so.5, install it using: yum
install libstdc++.so.5 in another terminal, with the
install program still running
-
then chose option 1 to allow default install. You need to input
the serial number which was sent to you by email.
-
edit .bash_profile to add one line: . /opt/intel/Compiler/11.0/069/bin/ifortvars.sh
-
then run: source .bash_profile
-
now you can edit a simple fortran program first.f90 like this:
- program first
print *, "Hello World!"
print *, sin(123.4)
end program first
- then compile it by ifort first.f90 -o first
run it by ./first. If the installation
is successful, you will see
- Hello World!
-0.7693915
- To install g95, a free fortran compiler:
-
go to g95 download
page to download the binary file for your linux system (usually you will need the first file for Linux x86, unless you are using a 64bit
version of Linux.)
-
gunzip the file into a directory
where you plan to install g95 (actually it is usable once you have
unzip it anywhere :)
-
make a soft link: ln -s /bin/g95
.../g95/g95-install/bin/*g95*
-
you can test it now by doing: g95 first.f90
-o first, then run the executable ./first.
That's it! :))
- Some tricks for emacs
/ xemacs
- how to kill duplicated lines in emacs:
- vi ~/.emacs
- add following lines in the end of the file .emacs
(defun uniq-lines (beg end)
"Unique lines in region.
Called from a program, there are two arguments:
BEG and END (region to sort)."
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(while (not (eobp))
(kill-line 1)
(yank)
(let ((next-line (point)))
(while
(re-search-forward
(format "^%s" (regexp-quote (car kill-ring))) nil t)
(replace-match "" nil nil))
(goto-char next-line))))))
- open a file with emacs
- select the lines for which to kill duplicated lines;
- type <Alt>+x, then key in "unqi-lines" after <Alt>+x in the minibuffer, then type <RET> .
- That is it.
|