Tuesday, September 30, 2008

Basic Commands in UNIX

Here's a short list of basic commands in UNIX. I have copied the list originally from another page which I cannot remember and I did some editing to it.


* ls --- lists your files
* ls -l --- lists your files in 'long format'
* ls -a --- lists all files
* more filename --- shows the first part of a file. Hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.
* emacs filename --- is an editor that lets you create and edit a file.
* mv filename1 filename2 --- moves a file
* cp filename1 filename2 --- copies a file
* rm filename --- removes a file.
* diff filename1 filename2 --- compares files, and shows where they differ
* wc filename --- tells you how many lines, words, and characters there are in a file
* chmod options filename --- lets you change the read, write, and execute permissions on your files. For example, chmod 777 file

File Compression
* gzip filename --- compresses files, so that they take up much less space.
* gunzip filename --- uncompresses files compressed by gzip.


* mkdir dirname --- make a new directory
* cd dirname --- change directory.
* pwd --- tells you where you currently are.

Finding things

* grep string filename(s) --- looks for the string in the files. This can be useful a lot of purposes, e.g. finding the right file among many.

About your (electronic) self

* whoami --- returns your username.
* passwd --- lets you change your password.
* ps -u yourusername --- lists your processes.

No comments: