2007-Dec-25 - How to ... (Linux version)
1. How to add a user on Unix platform:
# useradd {user_name}
# more /etc/passwd --> Here {user_name} should has been added.
# passwd {user_name} --> Here set a password for {user_name}
2. How to set DNS in Linux:
Modify file /etc/resolv.conf
3. How to modify locale in Linux:
1) To check current locale, run command: locale
2) localedef -f GB2312 -i zh_CN zh_CN.gb2312
--> /usr/lib/locale should has been added "zh_CN.gb2312"
/usr/lib/gconv/gconv-modules includes "alias GB2312-1980// EUC-CN//"
3) export LC_ALL=zh_CN.gb2312
4) To verify, run command: date
--> It should display Chinese.
5) To automatically enter Chinese locale in the next boot, add the following two lines in file /root/.bashrc:
export LANG=zh_CN.gb2312
export LC_ALL=zh_CN.gb2312
4. How to change the default booting Operating System:
1) Open /boot/grub/grub.conf (menu.lst)
2) Modify "default #..."
5. How to set IP - hostname list in Linux:
/etc/hosts:
{ip} {host_name(FQDN/long name)} [short name]
6. How to change the listening port of Postfix:
1) /etc/postfix/master.cf:
Change
smtp inet n - n - - smtpd
to
mysmtp inet n - n - - smtpd
2) /etc/services:
Add
mysmtp {port_number}/tcp mail
3) Restart postfix:
/etc/init.d/postfix restart
7. How to config IP in Linux:
/etc/sysconfig/network/ifcfg-eth-...:
Configure IPADDR and BOOTPROTO
8. How to add perl modules:
Precondition: Perl & modules installed.
# /usr/local/ActivePerl-5.8/bin/ppm
rep off 1 --> To turn of the default modules. Optional.
rep off 1
rep add {module_name} "{module_path}"
search *
install n --> n is the No. of the module that you want to install.(eg. install 1, 2, 7)
9. How to have a quick test on handle leak:
# ps -ef | grep processname --> Check the process ID that needs to test handle leak.
# cd /proc/{PID}/fd/
# ll --> Check socket number
Compare with the current connection number to see whether there's handle leak.
10. How to compile and run a C program:
# gcc -o output_filename program_name.c --> compile
# ./output_filename --> run
11. How to enable core dump:
# ulimit -c unlimited
Note: run "ulimit -c" to check whether it's enabled. If it returns "0", it is disabled; If it returns "unlimited" or some other number (the core dump file size), it is enabled.
12. How to calculate the total number of files under a folder:
# ll | wc -l
13. How to check cpu info:
# cat /proc/cpuinfo
14. How to configure Xdm on Linux for remote Xwindows access?
1) Modify /etc/X11/xdm/xdm-config: "DisplayManager.requestPort: 0"---> "!DisplayManager.requestPort: 0" 2) Modify Xaccess: "#* #any host can get a login window" -->"* #any host can get a login window" 3) Modify Xservers: ":0 local /usr/X11R6/bin/X" -->"#:0 local /usr/X11R6/bin/X" 4) run 'xdm' 5) then you can use Xmanager or X-Win32 to connect it.
Note: If on Suse, to configure Xdm for ROOT remote login:
1) Modify /etc/pam.d/login:
"auth required pam_securetty.so" --> "# auth ..."
2) Modify /etc/sysconfig/displaymanager:
DISPLAYMANAGER_REMOTE_ACCESS="yes"
DISPLAYMANAGER_ROOT_LOGIN_REMOTE="yes"
15. How to test code coverage:
Command: gcov
1) When compile with gcc command, add arguments fprofile-arcs and ftest-coverage
eg. #gcc -g -o output_name input.c -fprofile-arcs -ftest-coverage
2) Run output_name
3) #gcov input.c
Now input.c.gcov file is created. Use "less" command to view the gcov file. The lines following ##### were not executed in the step 2) run.
|