Rough Guide to Unix command line.

Similar to other operating systems it is possible to get common tasks done using graphical interfaces, however for some tasks it may be more approriate to use the command line.

If you are using the command line in unix for the first time it might be useful to know some of the commands to allow you to do some simple tasks like browsing the filesystem, copying, deleting and moving files.

There are a large number of small specialised programs available in unix, sometimes you can find a program that does exactly what you want. This comes with increased familiarity, the first step is to learn what some of the basic command are.

Most common commands - lesson 1

These are probably the most common commands for doing the most basic tasks in your system... start a terminal (xterm, gterm, gnome-terminal, etc) and experiment with these commands.

ls   list contents of current directory
cd    change directory
pwd   print working directory (reports current directory)
more  show contents of a text file on screen
exit  exit the current session
rm    remove (dangerous)
mv    move (slightly less dangerous)
cp    copy (less dangerous - you get to keep at least one file)
rmdir remove directory (only if empty)
mkdir make directory
man   gives documentation for commands (e.g. man man)
ps    process snapshot - list of jobs running on your computer

Example usage: try typing these commands (press enter after each one).

ls
man ls
ls --help
ls .
ls /
ls -a
ls -at
ls -l
ls -latc
ls --all
cd /
cd ~
more .bashrc
cp .bashrc .bashrc_backup
man rm
rm .bashrc_backup
mkdir trash
rmdir trash
ps
ps -aux

In the above example .bashrc is a file which is normally hidden. Different shells are available, in most cases today you will be using the `bash' shell, programs sometimes need to store options for each users preferences. For the bash shell these can be in .bashrc and .bash_profile which the program looks at each time it is started.

Note there were two different forms for some options, such as ls -a is similar to ls --all, but this is different to ls -all.

More commands - lesson 2

As you saw in the manual pages (e.g. man cp) the above commands can be modified using arguments

ls -1    lists contents of directory using a line for each result
ls -t    lists results in order of modification time
ls -l    gives more details
ls -lh   more details with files sizes in a Human readable form
ps aux   very verbose list of jobs running
cp -R dir1 dir2    copy directory 1 and contents to directory2

Some other useful commands

whoami  tells you information about youself
who     says who is logged into the machine
find    lists all files
vi	very light-weight ubiquiteous text editor (use :q! to exit)(maybe need esc first)
less    another program for looking at text files
cat     a program that dumps the contents of a file to the terminal
emacs   heavy-weight text editor (should be ctrl-X ctrl-c to exit)
pico    simple light-weight text editor
head    show the top 10 lines of a file
tail    show the bottom 10 lines of a file
top     lists the jobs using most system resources (q to exit)
lsof    lists files which are being accessed on your system

Links

Of course other people have already written guides to learning unix for the first time, this one seems a good reference:Learn Unix in 10 minutes.