Affichage des articles dont le libellé est Mac OS. Afficher tous les articles
Affichage des articles dont le libellé est Mac OS. Afficher tous les articles

jeudi 17 juillet 2014

Upload file to remote server using SCP

chenwang@~/Downloads$scp BuildingCocoaApps.pdf wcg1sgh@sgh023118:/home/wcg1sgh/Desktop/
Ubuntu 12.04.4 LTS
wcg1sgh@sgh023118's password:
BuildingCocoaApps.pdf                         100%  653KB 652.9KB/s   00:00

chenwang@~/Downloads$

mardi 15 juillet 2014

Environment variables

First of all, we have different places to setup environment variable. All the following files are applicable to both Ubuntu and Mac OS:
  • ~/.profile:
    use this for variables you want to set in all programs launched from the terminal (note that, unlike on Linux, all shells opened in Terminal.app are login shells).
  • ~/.bashrc:
    this is invoked for shells which are not login shells. Use this for aliases and other things which need to be redefined in subshells, not for environment variables that are inherited.

  • /etc/profile:
    this is loaded before ~/.profile, but is otherwise equivalent. Use it when you want the variable to apply to terminal programs launched by all users on the machine (assuming they use bash).

Ubuntu System

/etc/profile.d/:
All the script in this directory will be automatically executed. For more details, you can check the file /etc/profile


vim /etc/profile

then, you will see:

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi



Mac OS X

  • ~/.MacOSX/environment.plist: this is read by login window on login. It applies to all applications, including GUI ones, except those launched by Spotlight in 10.5 (not 10.6). It requires you to logout and login again for changes to take effect. This file is no longer supported as of OS X 10.8. 
  • your user's launchd instance: this applies to all programs launched by the user, GUI and CLI (command line interface). You can apply changes at any time by using the setenv command in launchctl. In theory, you should be able to put setenv commands in ~/.launchd.conf, and launchd would read them automatically when the user logs in, but in practice support for this file was never implemented. Instead, you can use another mechanism to execute a script at login, and have that script call launchctl to set up the launchd environment.
  • /etc/launchd.conf: this is read by launchd when the system starts up and when a user logs in. They affect every single process on the system, because launchd is the root process. To apply changes to the running root launchd you can pipe the commands into sudo launchctl.








a

Set the colour in terminal of Mac OS X

set the colour for normal users.
1: Go to the home directory, and create the following file:

    vim .bash_profile

2: Insert the following content into the file:

    export TERM="xterm-color"

    PS1='\[\e[00;32m\]\u\[\e[0m\]@\[\e[00;32m\]\w\[\e[0m\]\$'

The definition of each colour can be referred to the previous article.

3: save the file. Make it validated.

    source .bash_profile
-------------------------------------
set the colour for root.
1: login as a root.

    sudo -i

and then, enter the password.

2: create the following file:

    vim .profile

3: Enter the following content into the file (can be the same as normal users):

    export TERM="xterm-color"

    PS1='\[\e[00;31m\]\u\[\e[0m\]@\[\e[00;31m\]\w\[\e[0m\]\$'

4: save the file and make it validated immediately.

    source .profile
-------------------------------------
THEN, THE WORLD BECOMES COLOURFUL! :-)

jeudi 10 juillet 2014

Determine 32bit or 64bit of your mac OS


  • 1
    Launch Terminal app (see Applications/Utilities)
  • Determine if You're running the 32 Bit or 64 Bit Kernel in Mac oSX Step 2.jpg
    2
    At prompt, type the following: "uname -a" (without the quotes) (note the blank space between "uname" and "-a" strings.
  • Determine if You're running the 32 Bit or 64 Bit Kernel in Mac oSX Step 3.jpg
    3
    The terminal will display two lines of text. At the end of the 2nd line, you'll find something like either
    • RELEASE_I386 i386 ; the latest "i386" means that you're running 32bits kernel
    • RELEASE_X86_64 x86_64 ; the latest "x86_64" means that you're running 64bits kernel

  • Original Link: http://www.wikihow.com/Determine-if-You're-running-the-32-Bit-or-64-Bit-Kernel-in-Mac-oSX

    lundi 3 décembre 2012

    latex floatflt.sty not found in mac



    mkdir -p /usr/share/texmf-texlive/tex/latex/floatflt
    cd /usr/share/texmf-texlive/tex/latex/floatflt
    rm -f floatflt.* float*.tex
    wget http://mirror.ctan.org/macros/latex/contrib/floatflt/floatflt.ins
    wget http://mirror.ctan.org/macros/latex/contrib/floatflt/floatflt.dtx
    latex floatflt.ins
    texhash /usr/share/texmf-texlive
    PS: using mac, the folder is ~/Library/texmf/tex/latex, then go to that directory, and run the command wget ...
    Ref: Incidentally, if you want to add files to TEX Live for one particular user, install them in a similar tree ~/Library/texmf where ~/Library
     is the Library folder in that user’s home directory. The folder texmf 
    and other folders for the tree will have to be created. For instance, 
    TEX will find any file in ~/Library/texmf/tex or a subfolder of this location, LATEX will find any file in ~/Library/texmf/tex/latex or a subfolder of this location, and BibTEX will find any .bib file in ~/Library/texmf/bibtex/bib or a subfolder of this location, and any .bst file in ~/Library/texmf/bibtex/bst or a subfolder of this location. It is not necessary to use texhash when adding files to this local tree.    

    jeudi 1 novembre 2012

    MAC 下屏蔽某些网站

    为了使我在工作的时候不去某些网站浪费时间,在苹果电脑上可以使用以下方法屏蔽某些域名,使之转向与自己的电脑。

    1: 使用命令:
     sudo vim /private/etc/hosts


    2: 显示如下:
      1 ##
      2 # Host Database
      3 #
      4 # localhost is used to configure the loopback interface
      5 # when the system is booting.  Do not change this entry.
      6 ##
      7 127.0.0.1   localhost
      8 255.255.255.255 broadcasthost
      9 ::1             localhost
     10 fe80::1%lo0 localhost


    3: 在文件后添加若干行(11-13行),每行对应一个域名,文件如下:
      1 ##
      2 # Host Database
      3 #
      4 # localhost is used to configure the loopback interface
      5 # when the system is booting.  Do not change this entry.
      6 ##
      7 127.0.0.1   localhost
      8 255.255.255.255 broadcasthost
      9 ::1             localhost
     10 fe80::1%lo0 localhost
     11 127.0.0.1   www.weibo.com/
     12 127.0.0.1   www.renren.com/
     13 127.0.0.1   sports.sina.com.cn/


    4: 退出编辑器:wq

    如果是linux 机器,修改/etc/hosts 文件应该可以达到想通的效果。

    jeudi 20 septembre 2012

    文件权限

    ls -l: 查看文件权限

    e.g.


    chenwang@~/Applications/apache-ode-war-1.3.5/bin$ ls -l
    total 32
    -rw-r--r--@ 1 chenwang  staff  3005 Jul 22  2011 bpelc
    -rwxr-xr-x@ 1 chenwang  staff  2097 Jul 22  2011 bpelc.bat
    -rw-r--r--@ 1 chenwang  staff  3017 Jul 22  2011 sendsoap
    -rwxr-xr-x@ 1 chenwang  staff  2109 Jul 22  2011 sendsoap.bat


    chmod:修改文件权限

    e.g. 修改sendsoap script 权限,使得获取执行权限


    chenwang@~/Applications/apache-ode-war-1.3.5/bin$ chmod 777 sendsoap
    chenwang@~/Applications/apache-ode-war-1.3.5/bin$ ls -l
    total 32
    -rw-r--r--@ 1 chenwang  staff  3005 Jul 22  2011 bpelc
    -rwxr-xr-x@ 1 chenwang  staff  2097 Jul 22  2011 bpelc.bat
    -rwxrwxrwx@ 1 chenwang  staff  3017 Jul 22  2011 sendsoap
    -rwxr-xr-x@ 1 chenwang  staff  2109 Jul 22  2011 sendsoap.bat

    【转】chmod 命令使用


    在Unix和Linux的各种操作系统下,每个文件(文件夹也被看作是文件)都按读、写、运行设定权限。
    例如我用ls -l命令列文件表时,得到如下输出:
    -rw-r--r-- 1 apple users 2254 2006-05-20 13:47 tt.htm
    从 第二个字符起rw-是说用户apple有读、写权,没有运行权,接着的r--表示用户组users只有读权限,没有运行权,最后的r--指其他人 (others)只有读权限,没有写权和运行权。这是系统默认设置,我可以改写tt.htm,同组的人和其他人只有权读,没人有权运行,因为只是一个 html文件,不必运行。这在Novell的directory services之前很先进。
    读、写、运行三项权限可以用数字表示,就是r=4,w=2,x=1。所以,上面的例子中的rw-r--r--用数字表示成644。
    反过来说777就是rwxrwxrwx,意思是该登录用户(可以用命令id查看)、他所在的组和其他人都有最高权限。
    再多说一句。我用chmod o-r tt.htm命令改权限,o-r是others的权限中减掉读。结果是
    -rw-r----- 1 bu users 2254 2006-05-20 13:47 tt.htm
    如果用命令chmod 777 tt.htm,结果是
    -rwxrwxrwx 1 bu users 2254 2006-05-20 13:47 tt.htm
    任何人都有读、写、运行三项权限。
    ---------------------------------------------
    指令名称 : chmod

      使用权限 : 所有使用者
      使用方式 : chmod [-cfvR] [--help] [--version] mode file...
      说明 : Linux/Unix 的档案存取权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所存取。

      参数格式 :

      mode : 权限设定字串,格式如下 : [ugoa...][[+-=][rwxX]...][,...],其中

      u : 表示该档案的拥有者,g 表示与该档案的拥有者属于同一个群体(group)者,o 表示其他以外的人,a 表示这三者皆是。
      + :  表示增加权限、- 表示取消权限、= 表示唯一设定权限。
       r : 表示可读取,w 表示可写入,x 表示可执行,X 表示只有当该档案是个子目录或者该档案已经被设定过为可执行。 -c : 若该档案权限确实已经更改,才显示其更改动作
      -f : 若该档案权限无法被更改也不要显示错误讯息
      -v : 显示权限变更的详细资料
      -R : 对目前目录下的所有档案与子目录进行相同的权限变更(即以递回的方式逐个变更)
      --help : 显示辅助说明

      --version : 显示版本

      范例 :将档案 file1.txt 设为所有人皆可读取 :
      chmod ugo+r file1.txt

      将档案 file1.txt 设为所有人皆可读取 :
      chmod a+r file1.txt

      将档案 file1.txt 与 file2.txt 设为该档案拥有者,与其所属同一个群体者可写入,但其他以外的人则不可写入 :
      chmod ug+w,o-w file1.txt file2.txt

      将 ex1.py 设定为只有该档案拥有者可以执行 :
      chmod u+x ex1.py

      将目前目录下的所有档案与子目录皆设为任何人可读取 :
      chmod -R a+r *

      此外chmod也可以用数字来表示权限如 chmod 777 file

      语法为:chmod abc file

      其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。

      r=4,w=2,x=1

      若要rwx属性则4+2+1=7;
      若要rw-属性则4+2=6;
      若要r-x属性则4+1=7。

      范例:
      chmod a=rwx file 和chmod 777 file效果相同

      chmod ug=rwx,o=x file和chmod 771 file效果相同

      若用chmod 4755 filename可使此程式具有root的权限


    dimanche 16 septembre 2012

    【转】如何在Mac下显示Finder中的所有文件


    如何在Mac下显示Finder中的所有文件

    
    
    defaults write com.apple.Finder AppleShowAllFiles YES
    
    
    然后重启Finder,方法是按住Option键,单击Dock上的Finder图标不放,大概2秒后将在Finder图标上出现一个菜单,单击Relaunch,Finder即重启。
    
    
    defaults write com.apple.Finder AppleShowAllFiles NO

    mercredi 3 août 2011

    install pgp on Mac OS X

    1: Begin by downloading and verifying the GnuPG archives from
    <http://www.gnupg.org/>.  Here's what to type:
    
    curl -O ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.11.tar.gz
    curl -O ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.11.tar.gz.sig
    
    
    2: To verify:
    
    gpg --verify gnupg-1.4.11.tar.gz.sig
    
    or, if you don't have an older copy of GnuPG or another OpenPGP program
    (NEVER verify the version of GnuPG you download with itself), use the SHA-1
    checksums found on the GnuPG Web site and compare with the checksum from:
    
    openssl sha1 gnupg-1.4.11.tar.gz
    
    
    3: Next, untar GnuPG:
    
    tar -xzf gnupg-1.4.11.tar.gz
    
    And move into the GnuPG directory:
    
    cd gnupg-1.4.11
    
    
    4: Now you need to set up GnuPG to build on your system.  You do this by
    running configure:
    
    ./configure
    

    5: Once you have everything configured, it's time to compile GnuPG by running:
    
    make
    
    
    6: If all tests pass, the only thing left to do is type:
    
    sudo make install
    
    
    Reference: http://macgpg.sourceforge.net/docs/howto-build-gpg-osx.txt.asc

    [FW] Installing GLPK on a Mac


    So you want copy-paste instructions to install GLPK on your Macbook? Here are the steps:


    1. Download the latest version of GLPK fromhttp://www.gnu.org/software/glpk/#downloading
    2. Optional: Follow the instructions to verify the download (you might need to get GNU Privacy Guard or gpg for this. You can get it at http://gnupg.org);
      The GLPK distribution tarball can be found on http://ftp.gnu.org/gnu/glpk/ [via http] and ftp://ftp.gnu.org/gnu/glpk/ [via FTP]. It can also be found on one of our FTP mirrors; please use a mirror if possible.
      To make sure that the GLPK distribution tarball you have downloaded is intact you need to download the corresponding .sig file and run a command like this:
      gpg --verify glpk-4.32.tar.gz.sig

      If that command fails because you do not have the required public key, run the following command to import it:
      gpg --keyserver keys.gnupg.net --recv-keys 5981E818

      and then re-run the previous command.
      (if gpg is not installed, refer to: http://hichenwang.blogspot.com/2011/08/install-pgp-on-mac-os-x.html)
    3. Say it’s downloaded to your “Downloads” directory, go there and execute the following commands (using the terminal)
      1.cd ~/Downloads
      2.tar -xzf glpk-4.43.tar.gz
      3../configure --prefix=/usr/local # see note [1]
      4.make
      5.sudo make install
    4. At this point, you should have GLPK installed. Verify it:
      1.which glpsol
      2./usr/local/bin/glpsol
    5. … and try help:
      1.glpsol --help
    Now that you are all set-up, read up this excellent introduction using GLPK:http://www.ibm.com/developerworks/linux/library/l-glpk1
    Notes:
    [1]: HiveLogic article on why using /usr/local is better
    [2] If you want MySQL support (or something “extra”) check out the INSTALL file in the package