Linux/UNIX/Mac OS X:
$ which java
Windows XP
for %i in (java.exe) do @echo. %~$PATH:i
Windows since 2003
where java
Monday, March 17, 2014
Tuesday, February 4, 2014
bash
Comment = '#'
Shell = '$'
Output = '>'
## Print Working Directory
$ pwd
## Change Directory: to /directory
$ cd /directory
# Examples:
>/directory
# Change Directory, from: /directory to /
$ cd ..
>/
# Change Directory: previous directory
$ cd -
# Change Directory: go to home
$ cd
# Or
$ cd ~
>~
## Display output one screen at a time
$ less file
$ more file
## Concatenate and print (display) the content of file(s)
$ cat file1
# Or
$ cat file1 file2
# Examples:
$ cat File1.txt File2.txt > union.txt
$ sort -u File1.txt File2.txt > unique_union.txt
# Put the contents of a file into a variable
$ my_variable=`cat File3.txt`
## Create a test file
$ echo "test" > test.txt
## Filename and Directory Completion
$ cd /opt/I[TAB]
> cd /opt/IBM
$ cd /opt/IBM[TAB][TAB]
>IBM/ IBMinvscout/
## List of Variablenames
$ $[TAB][TAB]
## Variablename Completion
$B[TAB]
>$BASH
## Print variable's value
$ echo $BASH_VERSION
> 4.2.45(1)-release
## Username's list
$ cd ~[TAB][TAB]
## Hostname's list
$ ssh @[TAB][TAB]
## Run a command script in the current shell
$ ./download-logs.sh
## Search the user's $path for a program file
$ which ssh
>/usr/bin/ssh
## Copy one or more files to another location
$ cp f1 f2
## Move or rename files or directories
$ mv old_name new_name
## TAR + GZIP
$ tar -czvf archive.tgz files/
## Create a symbolic link to a file or a directory
$ ln -s [OriginalSourceFile] [NewLinkFile]
## Change access permissions
# http://ss64.com/bash/chmod.html
$ chmod access file
# Examples:
$ chmod u+x script.sh
$ chmod a-x file
$ chmod go+rw file
# Read by owner
$ chmod 400 file
# Allow everyone to read, write, and execute file
$ chmod 777 file
## Change file owner and group
$ chown [user] [filename]
# Examples:
# Owner => root
$ chown root file
# Group => admin
$ chown :admin file
# Owner => root AND Group => admin
$ chown root:admin file
## Change group ownership
$ chgrp [group] [filename]
# Examples:
$ chgrp oracle /usr/database
## Change file timestamps
$ touch filename
# Exemples:
$ touch -d "2 hours ago" filename
$ find DIRECTORY -exec touch -d "2 hours ago" {} +
$ find /opt/phantomjs/tomcat/apache-tomcat-6.0.37/logs/ -type f -mtime +30 -exec rm -f {} \;
## Find a specific file
$ find . -type f -name log4j*
# Examples:
# Fin a file and change the modification date
$ find DIRECTORY -exec touch -d "2 hours ago" {} +
## Reload shell configurations
$ source ~/.profile
# Or
$ source ~/.bashrc
## Exceute last command starting by 'command'
$ !command
## Remote connection with SSH
$ ssh user@hostname
>password
## Copy a remote file
# Push:
$ scp location user@othermachine.com:destination
# Pull:
$ scp user@othermachine.com:location destination
# The '-r' parameter is used to copy an entire directory, or you may use * to match on multiple files/directories.
## Find a command from the history
$ history | grep command
## Maven
$ mvn clean package
## SVN
#Checkout
$ svn co https://sasvnd1.int.videotron.com/svn/...
# Update
$ svn up
## Delete a file
$ rm file
# Delete many files starting with the letter f
$ rm f*
# Delete a directory
$ rm -r directory
## Debug Apache/IHS configurations
httpd.exe -e debug -k start
# Restart Apache/IHS with new configurations
$ httpd.exe -k restart
## head & tail
# Print the first lines of a file (default: 10 lines)
$ head -100 file.log
# Print the last lines of a file (default: 10 lines)
$ tail -100 file.log
# Extract lines 40-50 from a file, first using head to get the first 50 lines then tail to get the last 10:
$ head -50 file.log | tail -10
## Load bash as default shell
$ vi .profile
# Add:
bash
## Add an alias in the bash
$ vi ~/.bashrc
# Add
alias ALIAS_NAME='command'
# Examples:
alias ll='ls -l'
alias tailf="tail -f SystemOut.log"
## Customize the shell prompt
$ export PS1="\n\u@\h \w\n$ "
# http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
## Execute many commands in an "atomic" way
$ command1;command2
# Examples:
$ alias logs="cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs;ls"
$ rm app; ln -s app_AAAAMMDD app
## Configure a "daemon"
$ crontab crontab_file
# Print the current crontab
crontab -l
# To debug the daemon, we need the mail because the deamon will tell us if a task had a problem
mail
## Open a file in edit mode (or create it with a ':wq' at the end)
vi file
## Create a shell script
$ echo "#!/bin/bash" > script.sh
$ vi script.sh
$ chmod u+x script.sh
## Process viewer
$ top
# Or
$ ps
# Examples:
$ ps -ef | grep tomcat
Shell = '$'
Output = '>'
## Print Working Directory
$ pwd
## Change Directory: to /directory
$ cd /directory
# Examples:
>/directory
# Change Directory, from: /directory to /
$ cd ..
>/
# Change Directory: previous directory
$ cd -
# Change Directory: go to home
$ cd
# Or
$ cd ~
>~
## Display output one screen at a time
$ less file
$ more file
## Concatenate and print (display) the content of file(s)
$ cat file1
# Or
$ cat file1 file2
# Examples:
$ cat File1.txt File2.txt > union.txt
$ sort -u File1.txt File2.txt > unique_union.txt
# Put the contents of a file into a variable
$ my_variable=`cat File3.txt`
## Create a test file
$ echo "test" > test.txt
## Filename and Directory Completion
$ cd /opt/I[TAB]
> cd /opt/IBM
$ cd /opt/IBM[TAB][TAB]
>IBM/ IBMinvscout/
## List of Variablenames
$ $[TAB][TAB]
## Variablename Completion
$B[TAB]
>$BASH
## Print variable's value
$ echo $BASH_VERSION
> 4.2.45(1)-release
## Username's list
$ cd ~[TAB][TAB]
## Hostname's list
$ ssh @[TAB][TAB]
## Run a command script in the current shell
$ ./download-logs.sh
## Search the user's $path for a program file
$ which ssh
>/usr/bin/ssh
## Copy one or more files to another location
$ cp f1 f2
## Move or rename files or directories
$ mv old_name new_name
## TAR + GZIP
$ tar -czvf archive.tgz files/
## Create a symbolic link to a file or a directory
$ ln -s [OriginalSourceFile] [NewLinkFile]
## Change access permissions
# http://ss64.com/bash/chmod.html
$ chmod access file
# Examples:
$ chmod u+x script.sh
$ chmod a-x file
$ chmod go+rw file
# Read by owner
$ chmod 400 file
# Allow everyone to read, write, and execute file
$ chmod 777 file
## Change file owner and group
$ chown [user] [filename]
# Examples:
# Owner => root
$ chown root file
# Group => admin
$ chown :admin file
# Owner => root AND Group => admin
$ chown root:admin file
## Change group ownership
$ chgrp [group] [filename]
# Examples:
$ chgrp oracle /usr/database
## Change file timestamps
$ touch filename
# Exemples:
$ touch -d "2 hours ago" filename
$ find DIRECTORY -exec touch -d "2 hours ago" {} +
$ find /opt/phantomjs/tomcat/apache-tomcat-6.0.37/logs/ -type f -mtime +30 -exec rm -f {} \;
## Find a specific file
$ find . -type f -name log4j*
# Examples:
# Fin a file and change the modification date
$ find DIRECTORY -exec touch -d "2 hours ago" {} +
## Reload shell configurations
$ source ~/.profile
# Or
$ source ~/.bashrc
## Exceute last command starting by 'command'
$ !command
## Remote connection with SSH
$ ssh user@hostname
>password
## Copy a remote file
# Push:
$ scp location user@othermachine.com:destination
# Pull:
$ scp user@othermachine.com:location destination
# The '-r' parameter is used to copy an entire directory, or you may use * to match on multiple files/directories.
## Find a command from the history
$ history | grep command
## Maven
$ mvn clean package
## SVN
#Checkout
$ svn co https://sasvnd1.int.videotron.com/svn/...
# Update
$ svn up
## Delete a file
$ rm file
# Delete many files starting with the letter f
$ rm f*
# Delete a directory
$ rm -r directory
## Debug Apache/IHS configurations
httpd.exe -e debug -k start
# Restart Apache/IHS with new configurations
$ httpd.exe -k restart
## head & tail
# Print the first lines of a file (default: 10 lines)
$ head -100 file.log
# Print the last lines of a file (default: 10 lines)
$ tail -100 file.log
# Extract lines 40-50 from a file, first using head to get the first 50 lines then tail to get the last 10:
$ head -50 file.log | tail -10
## Load bash as default shell
$ vi .profile
# Add:
bash
## Add an alias in the bash
$ vi ~/.bashrc
# Add
alias ALIAS_NAME='command'
# Examples:
alias ll='ls -l'
alias tailf="tail -f SystemOut.log"
## Customize the shell prompt
$ export PS1="\n\u@\h \w\n$ "
# http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
## Execute many commands in an "atomic" way
$ command1;command2
# Examples:
$ alias logs="cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs;ls"
$ rm app; ln -s app_AAAAMMDD app
## Configure a "daemon"
$ crontab crontab_file
# Print the current crontab
crontab -l
# To debug the daemon, we need the mail because the deamon will tell us if a task had a problem
## Open a file in edit mode (or create it with a ':wq' at the end)
vi file
## Create a shell script
$ echo "#!/bin/bash" > script.sh
$ vi script.sh
$ chmod u+x script.sh
## Process viewer
$ top
# Or
$ ps
# Examples:
$ ps -ef | grep tomcat
See also:
http://ss64.com/bash/
Configure crontab (UNIX/Linux)
If you are about to modify a crontab, it's better to keep a backup:
In command line:
> crontab -l > /home/usr/crontab_[Modification date : YYYY_MM_DD_hh_mm]_bk
To modify the crontab, you first need to create a copy of the actual configuration:
> crontab -l > /home/usr/crontab_current.txt
# .------------------- minute (0 - 59)
# | .--------------- hour (0 - 23)
# | | .----------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan, feb, mar, apr ...
# | | | | .--- day of week (0 - 6, Sunday = 0) OR sun, mon, tue, wed, thu, fri, sat
# | | | | |
# * * * * * command to be executed
# Operators : * = all
# , = and
# - = to
#
# Everyday of the week: 3:40, 7:40, 12:40, 16:40 and 22:40
40 3,7,12,16,22 * * * /application/script/run_refresh.sh param1 param2 > /dev/null
When the modification is over,
> crontab /home/usr/crontab_current.txt
If you are modifying the file in Windows, don't forget to convert the EOL:
> dos2unix /home/usr/crontab_current.txt /home/usr/crontab_current.txt
If you want to periodicaly delete log files, you can add this to the crontab:
> find /opt/logs -name "*.log" -type f -mtime +1 -delete
Commit Monitor - Install (Windows)
Commit Monitor is doing monitoring on the SVN server, so you can be notified when others are committing new modifications.
http://stefanstools.sourceforge.net/CommitMonitor.html
Cntlm - Install (Windows)
Cntlm is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy
- Downdload from the official website : cntlm.sourceforge.net
- Unzip to the destination folder, we will call it CNTLM_HOME, ex.: C:\dev\Cntlm
- Create an environment variable (if you don't know how, click here)Name: CNTLM_HOME
Value: C:\dev\Cntlm (it's only an example, choose your destination's folder) - Add to the PATH this new variable CNTLM_HOME (if you don't know how, click here)
- Take a backup of the original configuration file %CNTLM_HOME%\cntlm.ini => cntlm.ini.default
- Remplace the content of the file in %CNTLM_HOME%\cntlm.ini by...# Cntlm Authentication Proxy ConfigurationUsername testuserDomain corp-uk# List of parent proxies to use. More proxies can be defined# one per line in format <proxy_ip>:<proxy_port>Proxy proxy-name:8080# List addresses you do not want to pass to parent proxies# * and ? wildcards can be usedNoProxy localhost, 127.0.0.*, 10.*, 192.168.*# Specify the port cntlm will listen on# You can bind cntlm to specific interface by specifying# the appropriate IP address also in format <local_ip>:<local_port># Cntlm listens on 127.0.0.1:3128 by defaultListen 3128Auth NTLMv2PassNTLMv2
- Replace by your own personal informations:Username testuserDomain corp-ukProxy proxy-name:8080
- In commande line type this command and enter your password :>cntlm -I -M http://test.com -c C:\dev\Cntlm\cntlm.ini[PASSWORD]Password:Config profile 1/4... OK (HTTP code: 200)----------------------------[ Profile 0 ]------Auth NTLMv2PassNTLMv2 AA1A11AAA11AAAA1AA11A1AAAA11A11A------------------------------------------------Notice: If you get an HTTP code 302, it's fine too.
- Copy the value of PassNTLMv2 from the output AA1A11AAA11AAAA1AA11A1AAAA11A11A to the file cntlm.ini, on the same line as PassNTLMv2
- In commande line:> cntlm -f -c C:\dev\Cntlm\cntlm.inicntlm: PID 15264: Cntlm ready, staying in the foreground
Node.js configure proxy (HTTP/HTTPS)
For example, if you are behind a corporate proxy , you can configure the credentials to pass through: In command line:
>npm config set proxy http://[username]:[passwprd]@ proxy-name:8080
>npm config set https-proxy http://[username]:[passwprd]@ proxy-name:8080
>npm config set registry "http://registry.npmjs.org/"
>npm config set proxy http://[username]:[passwprd]@
>npm config set https-proxy http://[username]:[passwprd]@
>npm config set registry "http://registry.npmjs.org/"
Adding a folder to the PATH (Windows)
The PATH variable in Windows is the list of the folders you can have directly access to their files in command line. They are separated by a semicolon (;) and actually you can have to PATH variables, one for the user and an other for the system, but in the end they are merged.
The path "C:\dev\Java\jdk1.7.0_51\bin" is now declared in the PATH.
- Press [Windows] + [Pause] keys
- Click on the "Advanced" tab
- Click on the "Environment Variables" button
- Choose the scope's level : "User variables for xyz" or "System variables" and select the PATH variable
- Click on "Edit" button
- In the value's field, go to the end of the current value and add a semicolon if there's not already one, then add the path to the folder you want to add, ex.: "%SystemRoot%\system32;C:\dev\Java\jdk1.7.0_51\bin". If you want to use an other environment variable's value, simply specify the name of the value surrounded by the percent character (%), ex.: "%SystemRoot%\system32;%JAVA_HOME%\bin" would have the same result if the JAVA_HOME variable contain the value "C:\dev\Java\jdk1.7.0_51".
- Click on the "OK" button
- Click on the "OK" button
- Click on the "OK" button
The path "C:\dev\Java\jdk1.7.0_51\bin" is now declared in the PATH.
Subscribe to:
Posts (Atom)