How To‎ > ‎


How to download the content from a URL?

wget -t 45 -o log &
(make 45 attempts and write log to log)
Now if you want to download a list of files from some location than 
wget -t 45 -o log*.bz2 & 
will not work so you need to do:
wget -o log  -r -l1 --no-parent -A.bz2 &
to download all your files to your local drive.

How to extract bz2 file?

bunzip2 file-name.bz2

How to extract tgz file?

It depends on the tar file. ".tgz" "_tar.gz" means it is tarred and gzipped.

in that case:

tar -zxvf file_tar.gz

If it is just ".tar" "_tar" it isn't zipped, so take the z off.

"tar -xvf file_tar"

tar and gziP:
tar czvf myfile.tgz myfile

"gtar xzvf file.tar.gz" or "gunzip -c file.tar.gz |tar xvf -"

How to extract zip file?

unzip -d thedir

How to protect file from being deleted?

chmod a-w filename

How to do For loops in bash?

for file in *.txt; do echo $file; done
will print all files with extension .txt to console

Links that I found useful:

Tomcat wouldn't start but throws Connection refused...exception?

ps axf | grep [j]ava.endorsed.dir
ps ax | grep [j]ava.endorsed.dir
on Mac)

this will show the PID which you then need to kill:

 kill -9 PID

read details here

Get processes which are running

ps auxgwwww | less

Find out which program is running on a port

sudo lsof -i :80

List all users on a linux server

Cat /etc/passwd |grep "/home" |cut -d: -f1

How to open TextEdit from Command Line?

open -a TextEdit nameOfTheFile.txt

How to download multiple files from a URL using a wildcard?

An example downloading FIBO ontologies:

wget -r -l3 --no-parent -A.rdf

Read more here.

How to switch between different versions of Java on Mac OS X?

1) Install all of them e.g. 1.6, 1.7, and 1.8.

2) Add to your ~/.bash_profile

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
setjdk() {
  export JAVA_HOME=$(/usr/libexec/java_home -v $1)

Now you can:

$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
$ setjdk 1.6
$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
$ setjdk 1.8
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

How to write output of a system.err.println to a file in bash?

To write the output of the System.err.println to the file do the following:
 > outputfilename.log 2>&1

Which process is running on a port?

For example, to find out what's running on port 9000, run this command:
$ lsof -i :9000

List existing conda environements

conda info --envs