Linux use notes

-----------------------------
Based on Fedora 10 version:
-----------------------------

1. User can add boot programs through:
    Just add in file /etc/rc.local.

2. Mute telnet alart sound (teminal of Linux).
    Just set the Bell sub-option in Putty.
    Mute alart sound in Linux teminal(Ubuntu 10.4)?
         Set in System->preferences->sound.

3. Install samba UI.
       # yum install system-config-samba
    Note: if you could not use after above install and configure, need check three points:
        a. whether block by linux firewall;
        b. whether block by SELinux;
        c. whether disabled in "services".

4. Network connection doesn't controlled by "NetworkManager Applet"?
    System -> Administration -> Network Device Control -> select controlled by NetworkManager.


-----------------------------
Based on Ubuntu 10.04 version:
-----------------------------

[offline deb package download: http://packages.ubuntu.com/]

1.How to do if apt-get could not find some packages which should exist in general?
      a. $ sudo apt-get update.
       b. If after step a, still could not find it, do change package source.
        Edit file /etc/apt/source.list.

2. How to change java and javac version?
     $ update-alternatives --config java
    $ update-alternatives --config javac

3. How to change gcc version[take 4.1 and 4.4 for example]?
    a. # cd /usr/bin && rm gcc g++ cpp;
    b. # ln -s g++-4.4 g++ && ln -s gcc-4.4 gcc && ln -s cpp-4.4 cpp
    c. # rm x86_64-linux-gnu-g++ x86_64-linux-gnu-gcc x86_64-linux-gnu-cpp
    d. # ln -s g++-4.4 x86_64-linux-gnu-g++
       # ln -s gcc-4.4 x86_64-linux-gnu-gcc
       # ln -s cpp-4.4 x86_64-linux-gnu-cpp
    Note: change result with `gcc --version`
    [ref: http://ubuntuforums.org/showthread.php?t=29449]

4. How to active root account?
    $ sudo passwd root

5. $ ping -c 2 www.baidu.com, report ping: unknown host www.baidu.com issues.
    If can ping local IP, check the route setting by `route`.
    Add gateway through command, fx: `route add default gw 192.168.1.1 eth1.
    Don't completely trust GUI network manager tool, CLI is better to maintain.
    [Below is method for configuring network in eth1 device, to static IP 192.168.1.100 and gateway 192.168.1.1]
    file: /etc/network/interfaces
    content:
        auto eth1
        iface eth1 inet static   ### if through DHCP service, change 'static' to 'dhcp' and no need below lines.
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.1.225
        gateway 192.168.1.1     
    file: /etc/resolv.conf
    content:
        nameserver xxx.xxx.xxx.xxx    ### DNS service for Domain to IP parser.
        nameserver xxx.xxx.xxx.xxx
        domain
        search
    
    src:
        http://www.liberiangeek.net/2010/08/disable-network-manager-ubuntu-10-04-lucid-lynx-configure-network-interface-traditionally/
        http://rute.2038bug.com/node28.html.gz#SECTION002840000000000000000

6. How to enable vsftpd service?
    a. $ sudo apt-get install vsftpd
    b. edit /etc/vsftpd.conf and un-comment of "local_umask=022" [or do nothing]
    c. service vsftpd restart.
    d. browse in Windows using FileZilla client or Firefox [ftp://$your_IP/].
    src: http://ubuntuforums.org/showthread.php?t=518293
          http://filezilla-project.org/ [FileZilla Server could not execute in Win7? ]

7. Chinese support in vi, and Chinese input method support in Ubuntu?
    a. $sudo apt-get install language-support-zh        ### chinese charset support
      b. System -> Preferences -> Ibus Preferences, and choose one chinese input method.  ### chinese input method

8. How to install vncserver and use it?
     a. Download vnc4server and xinetd.
           $ sudo apt-get install vnc4server xinetd
     b. $ vncserver :3 -geometry 1920x1080   ###host machine resolution
    c. Open the ~/.vnc/xstartup file for editing.  Add "gnome-session &" at end of file.
    d. Do `vncserver -kill :3` and `vncserver :3 -geometry 1920x1080` again. Enjoy it.

9. How to install git?
     $ sudo apt-get install git-core


-----------------------------
Based on Fedora 8 version:
-----------------------------

1. No common command like 'ifconfig' in shell prompt line?
    Root cause is the standard search path not include /sbin and /usr/sbin. Try to include them in /etc/profile. As belows:
     export PATH=.:/sbin:/usr/sbin:$PATH
 
2. Install packages in Fedora?
     yum install "package name"
     yum upgrade "package name"
     rpm -qa | grep “samba”
 
3. Install Samba UI configuring program?
     a. yum install system-config-samba.
    b. set samba service is trusted services in firewall.
    c. set samba_enable_home_dirs and samba_export_all_ro in SELinux configure option.
 
4. VMware host connect with target, without network line.
      a. set vmvare network connect mode to NAT in right-bottom network icon, default is bridged mode;
      b. in host machine, try (cmd -> ipconfig /all). Check VMNET8's IP address, suppose it is 192.168.111.2;
      c. in target machine, set IP address to the same network range in step b, like 192.168.111.3, and set Gateway and DNS
          to vmware NAT gateway ip in menu(if not sure, try DHCP first, and check info from network manager);
      d. restart target machine, host can ping the target ip now.
      Note: 1. No need to set host physical address, since it is not related to it.
          2. If host machine is connect by external network, then target can ping host machine IP, like 172.16.200.22.
                    And target can also connect to Internet.
          3. For target connect Internet network, I use bridge connect mode and DHCP is ok too.
      ref: http://hi.baidu.com/msingle/blog/item/d8a730ed4f6ab6dfb31cb15c.html
 
5. Enable telnet server?
      1. query system whether has telnet and  telnet-server, if not have, install them.
      # rpm -qa telnet
      # rpm -qa telnet-server
      # yum install telnet
      # yum install telnet-server
    2. change system's default config for telnet in /etc/xinetd.d/telnet file.
        change option diable yes => disable = no in this file.
       3. restart telnet service.
        # /sbin/service xinetd restart
        or
        #/etc/init.d/xinetd restart
    Note: telnet use no-crypt transport method, not safe enough, should use ssh instead.

6. How to install vmware-tools?
     1. query system whether has kernel and kernel-devel.
         # rpm -qa kernel
         # rpm -qa kernel-devel
       2. if not install them.
          # yum install kernel kernel-devel
       3. cd vmware-tool dir and install it.
    Note: may print out many error, dont care them, just continue. But windows share no effect. :(  

7. How to forbit linux beep sound?   
    Go preferences -> hardware -> sound -> system beep -> enable system beep, and not select it.
     
8. Set network from command line?
   IP: ifconfig eth0 192.168.81.8 netmask 255.255.255.0
   Gateway: route add default gw 192.168.81.1
   DNS: /etc/resolv.conf
   For taking effect at system booting time, add them in /etc/rc5.d/S99local file. See: /etc/initab about run level.

9. Mysql install and use?
     # yum install mysql*
      # /sbin/service/mysqld restart
       # mysql -u root -p
 
10. VMWare error: Could not open virtual machine, this virtual machine appears to be in use?
    For resolving the issue, deleted all of the .lck files and directories in the guest’s directory.


-----------------------------
Based on Ubuntu 8.04 version:
-----------------------------

1. How to install vncserver?
     a. Download vnc4server and xinetd.
       $ sudo apt-get install vnc4server xinetd
      b. Open file ~/.vnc/xstartup for editing. Change it as below and save.
          Uncomment the lines that start with unset and exec. Comment out the lines that start with xsetroot, vncconfig, xterm, and twm.
          The final file should look like:
              #!/bin/sh
              # Uncomment the following two lines for normal desktop:
              unset SESSION_MANAGER
              exec /etc/X11/xinit/xinitrc
              [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
              [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
              #xsetroot -solid grey
       c. Change the permissions on the /etc/X11/xinit/xinitrc file to make it executable.
          $ sudo chmod 755 /etc/X11/xinit/xinitrc
    d. Start the vnc4server.
          $ vnc4server --help
          $ vnc4server :3 -geometry 1280x1024 (or 1440x1050)
    Note: VNC viewer for Windows comes from http://www.realvnc.com/products/free/4.1/download.html.
    
2. How to install vim?
    a. install vim full version
         $ sudo apt-get install vim-full
       b. change default editor of system
        $ sudo update-alternatives --config editor
       c. grammar colour display
          method 1. :syntax on  ### inside vi environment.
          method 2. $ vi ~/.vimrc, and add line "syntax on" at last line,(or if not exist, create this file.)

3. How to install gcc?
       $ sudo apt-get install build-essential

4. How to install telnet server?
       a. $ sudo apt-get install xinetd telnetd
       b. $ /etc/init.d/xinetd  start | stop | restart

5. How to install ssh server?
       a. $ sudo apt-get install openssh-server openssh-client
       b. $ /etc/init.d/ssh  start | stop | restart

6. How to install Chinese input method support?
      a. $ sudo apt-get install language-support-zh
       b. $ sudo vi /etc/environment
          add one line at the end of file:
          LC_CTYPE="zh_CN.UTF-8"    

7. How to add config item in menu for samba service?
       $ sudo apt-get install system-config-samba       
    
8. When install or boot Ubuntu, got warning info "8254 timer not connected to IO-APIC." and system halt?    
    Edit /boot/grub/menu.lst, add "acpi=off noapic apm=off" to the end of line like below:
     "kernel          /boot/vmlinuz-2.6.24-27-generic root=UUID=3465afb1-ec80-42af-bade-0563bd3c2a71 ro quiet splash"
    
9. Ubuntu - configure error: No termcap library found?
       $ sudo apt-get install libncurses5-dev

10. How to install NFS server?
    a. $ sudo apt-get install nfs-kernel-server nfs-common portmap
    b. Edit /etc/exports file like below:
        /tftpboot 192.168.1.0/24(rw,no_root_squash,sync,no_subtree_check) /* only support ip address from 0 to 24, can use * stands for every ip).
       See "man exports" for detail info.
       Note: if without no_root_squash flag, will appear permission problem when uses commands in target side.
    c. After each time exports file changes, need to do following for taking effect:
       $sudo exportfs -ra
       $sudo /etc/init.d/portmap restart
       $sudo /etc/init.d/nfs-kernel-server restart
    Note: according to https://help.ubuntu.com/community/SettingUpNFSHowTo.
          If you find mount remote machine could not work, problem probable comes from here!

11. How to install TFTP service?
       a. $ sudo apt-get install xinetd tftpd tftp
    b. Create /etc/xinetd.d/tftp and put this entry:
       service tftp
       {
         protocol        = udp
         port            = 69
         socket_type     = dgram
         wait            = yes
         user            = nobody
         server          = -s /usr/sbin/in.tftpd
         server_args     = /tftpboot
         disable         = no
       }
    c. Make /tftpboot directory
       $ sudo mkdir /tftpboot
       $ sudo chmod -R 777 /tftpboot
       $ sudo chown -R nobody /tftpboot
    d. Start tftpd through xinetd
       $ sudo /etc/init.d/xinetd start
    e. Testing.
        i. Check whether tftp service is running in back:
          $ netstat -a | grep tftp
         ii. Tranfering file hda.txt from 192.168.1.100 (Client using tftp) to 192.168.1.100 (Server 192.168.1.100).
            Get an example file to transfer (eg. hda.txt)
            $ touch /tftpboot/hda.txt
             $ chmod 777 /tftpboot/hda.txt
             $ tftp 192.168.1.100
             tftp> put hda.txt
              Sent 722 bytes in 0.0 seconds
             tftp> quit
        Note:
               a. from http://www.davidsudjiman.info/2006/03/27/installing-and-setting-tftpd-in-ubuntu/.
              b. For use tftp in Fedora10, config file needs to be:
                service tftp
                   {
                  protocol        = udp
                 port            = 69
                  socket_type     = dgram
                  wait            = yes
                 user            = root
                  server          = -s /usr/sbin/in.tftpd
                  server_args     = -u root -c -s /tftpboot
                  disable         = no
                   }
              c. For use tftp in Ubuntu10.04.02, config file needs to be:
                   service tftp
                   {
                  protocol        = udp
                  port            = 69
                  socket_type     = dgram
                  wait            = yes
                    user            = nobody
                  server          =  /usr/sbin/in.tftpd
                   server_args     = -s /tftpboot
                  disable         = no
                   }
               Otherwise, always show Transfer timed out. And /var/log/messages report:cannot set groups for user nobody .
           Need deep research. (so confusing, but no guide about how to creat tftp config? I should start look for alternative.)

12. Mount failed, log:
        rpcbind: server localhost not responding, timed out
        RPC: failed to contact local rpcbind server (errno 5).
        lockd_up: makesock failed, error=-5
       Add "-o nolock" when use mount command. Note: I find only target board need this, host no need.    
    
13. Ubuntu have no man page for general function like strcat, calloc etc?
        $ sudo apt-get install manpages-dev
        $ sudo apt-get install manpages-posix-dev (include pthread_create etc.)
    
14. Ubuntu without dos2unix command?
        $ sudo apt-get install sysutils        
        For processing bunch of files, use following format:
        $ find . -type f -exec dos2unix {} /; /* see man find for detail info. */
    
15. How to set system time?
    To set the date/time for May 19th, 2007, 6:00pm (and 0 seconds), you would type:
        $ date 051918002007.00
    
16. Error: ./clutter_only.sh: 5: source: not found?    
       Change #!/bin/sh to #!/bin/bash.
    
17. How to telnet target and run target command in host side?
    Write a script as below content:
    echo " "
    echo "Telnet:Execute UI file now"
    (sleep 1
     echo "cd /clutter && ./main" #replace with your commands here.
     sleep 100
     echo "exit"
    ) | telnet 192.168.1.12    
    
18. How to setup svn server?
    a. check whether system already installed dependances;    
       $ dpkg -l | grep apache
    b. if not, install them;
       $ sudo apt-get install apache2 subversion libapache2-svn
    c. create the subversion repository;
       $ sudo svnadmin create /home/sea/svn/myproject
       $ chmod -R 777 /home/sea/svn/myproject   
    d. edit the configuration file for the subversion webdav module;
       $ sudo gedit /etc/apache2/mods-enabled/dav_svn.conf
       change file like follows:
       <Location /svn>
       DAV svn
       SVNParentPath /home/sea/svn #Note: support multi-repos.
       AuthType Basic
       AuthName "Subversion Repository"
       AuthUserFile /etc/apache2/dav_svn.passwd
       Require valid-user
    e. create a user on the repository use;
       $ sudo htpasswd -cm /etc/apache2/dav_svn.passwd <username> #Note: you should only use the -c option the FIRST time that you create a user. See manual.
    f. modify file /etc/apache2/httpd.conf;
       add line:  ServerName your-server-name
    g. Restart apache, and now can access svn through http://your-server-name/ + Location item + project_name=> http://your-server-name/svn/myproject.
       $ sudo /etc/init.d/apache2 restart  #Note: for create other project repos: use step c method.   
    h. import a project source-code.
       # svn import locate_project_sourcecode file:////home/sea/svn/myproject/trunk  #trunk, branches, tags are created in advance with TortoiseSVN client.

       Note: TortoiseSVN: http://tortoisesvn.net/downloads
        ref: https://help.ubuntu.com/community/Subversion
              http://www.howtogeek.com/howto/ubuntu/install-subversion-with-web-access-on-ubuntu/    

    Additional: how to backup your svn repository, and for use in another machine?
            $ svnadmin dump /path/to/reponame > $save_file_name;  // src machine
            $ svnadmin load /path/to/new_reponame $save_file_name // target machine
            $ chmod -R 777 /path/to/new_reponame
    
        ref: http://wiki.archlinux.org/index.php/Subversion_backup_and_restore
             http://stackoverflow.com/questions/33055/what-is-the-best-way-to-backup-subversion-repositories
                https://wiki.archlinux.org/index.php/Subversion_backup_and_restore
    
19. How to install git?
    a. $ sudo apt-get install git git-core
    b. $ git clone source_link ###Fx, `git clone git://git.clutter-project.org/clutter`
    
20. How to install libtool etc?
    $ sudo apt-get install libtool
    
21. How to install glib?
    $ sudo apt-get install libglib2.0-dev
    
22. How to use diff and patch pair?
    a. got patch data file from two folders/files:  
        $ diff -Nur folder_name.org/ folder_name/ > folder_name-20100326.patch
    b. put patch to a source tree:  
        $ cd folder_name.org/ && patch -p1<../folder_name-20100326.patch
    Note:  patch default with option '-p0' (setting -p0 gives the entire file name unmodified), `man patch` for more info.



NOTE: Content is from work experience and Internet search, will keep update time to time. Very appreciate for your input.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章