Thursday, August 03, 2006

Linux/Unix basic commands

cp
cp myfile yourfile
cp -i /data/myfile .

Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file.

cp -r srcdir destdir

copy recursively (-r option), a directory and all it contents can be copied to another directory.

df, du

Show the amount of disk space used on each mounted filesystem.

ls -al

List all files in the current working directory in long listing format showing permissions, ownership, size, and time and date stamp

mv -i myfile yourfile --- mv -i /data/myfile .

Move the file from "myfile" to "yourfile". This effectively changes the name of "myfile" to "yourfile". Move the file from "myfile" from the directory "/data" to the current working directory.

rm -rf dictionaryname

delete a dictionary -f means force, -r means recurse, 'rmdir' only remove empty directories

cat a.cpp | more (less, head, tail) --- more a.cpp

Viewing text files

  • find, locate
  • grep 678-256 * -- ( or a.cpp)

ps

Process status

top

list the CPU intensive progrmas currently runnning, similar with 'tasklist' in windows

whereis matlab

reprot all known instance of a command

wc a.cpp

Print line counts, byte, word of the file ( -w, -c, -l)

tar -zcvf filename.tar.gz directory
tar -zxvf filename.tar.gz

Compresses in tarball the directory and all sub-dir into filename.tar.gz, Decompress
z is to handle files that were compressed using gzip.
x is to extract.
c is to create
v is to be verbose about what is going on(similar with '-l' in ls -l) .
f is to force overwriting if it was already extracted.
Details in following link.(update: 3/24/08)
http://www.computerhope.com/unix/utar.htm

No comments:

Post a Comment