Baisc Commands

Logging On and Off

To log on the sytem, you need to have an account with user name and password. There is a super user named root which controls the sytem. Root is capable of adding new accounts, changing passwords, terminating processes and rebooting the system (and mixed up the whole system too :-).

login:

Enter your username (in lowercase letters) and press Return. You will then be prompted for a passoword:

Password:
Enter your password and press Return.
%
$
#

You should see either one of the above shell (csh/tcsh/bash/ksh) prompts when login from a console that does not start up with X window systems. Note: Typically a # prompt indicates that you login as a super user which is discouraged to do so, unless you need to do system work. If you login from a GUI (X window systems), you get a task bar. You can invoke a console session, and you will see the above shell prompt.

To logout from a workstation, enter exit from a session. When X is running, you may use the 'start' button for logoff.
To change your password, enter: passwd which will ask you to enter your old and new passwords. You may wnat to backup the password files before making any changes:

Listing Files/Directories

ls -l (or ls -F, or ls -al)

  drwx------   2 klai     adm          1024 Jan  6 08:01 mail
  drwxr-xr-x   2 klai     root         1024 Sep  9 07:01 mlt
  drwx------   2 klai     adm          1024 Aug 16  1999 nsmail
  -rw-r--r--   1 klai     users        1921 Nov 15 08:25 .cshrc

  -rwx------   1 klai     users        1921 Nov 15 08:25 bin/myCmd
r: read
w: write
x: executable

  • chmod 700 myDir
  • chmod 755 install; ./install
  • chmod 600 mySecret
  • Note: run man chmod and
    man ls
    for details regarding file modes.

    Displaying the Contents of a File

    These commands are for text file only. (e.g. cat myFile) If you accidentally cat a non-text file (like a binary file), you will get a lot of garbage and your terminal may hang. If you're not sure what the type of a file is, use the "file"

    Subcommands in less:

    	SPACEBAR	Moves forward one screenful
    	Return		Moves forward one line
    	b		Moves back one page
    	/word Return	Search forward for word
    	q or CTRL-c	Quit
    	h		Help
    

    The less command is a UNIX filter;   many other UNIX commands filter their output through less. Instead of processing the output directly, it is sent through less which gives you more control. In UNIX terms, we say that we "pipe   the output through less".   When you enter a command and its output is too large to fit on one screen, you can cancel the output by typing CTRL-c   and re-enter it as follows:

    %  command  |  less
    or
    %  !!  |  less     
    Note: !! stands for repeat previous line under csh/tcsh/bash environment.

    Handling Files

    UNIX doesn't verify the deletion, it just deletes the file and prompts for the next command. You can specify more than one file to be deleted on the command line by separating the filenames with blanks. You can also, with caution, use wildcards   (* ? [ ])   to delete groups of files. The most catastrophic mistake you could probably make would be to enter rm * which would delete all of the non-hidden files in your current directory. Please note that there are no "undelete" utilities available in UNIX, so once you have deleted something, it's gone(pretty much).

    A -i parameter, as in rm -i filename, provides for a verification prompt before deleting multiple files. Type "n" or "y" in response.

    %  ls
    foo bar
    %  rm -i  *
    rm: remove foo? y
    rm: remove bar? n
    %  ls
    bar
    Many users set an alias for rm to rm -i for safety. See Customizing Your Environment for more information on customizing your environment. Additionally, the noclobber variable can help to protect your files from accidential deletions (See C Shell Variables and Things to Avoid).          

    The cp command   is used to create a duplicate copy of an existing file. The form of the cp command is:

    %  cp  oldFile  newFile

    UNIX makes a copy of oldFile and calls it newFile. If newFile already exists, it is overwritten. Again, UNIX does not verify the copy by default. See Figure 3.4 for an example of the cp command. You can, however, use the -i option to avoid accidentally destroying files.

    The mv command   is used to move or rename a file. The form of the mv command is:

    %  mv  oldname  newname

    UNIX renames oldname to newname, effectively moving it from one file to another. If new_name already exists, it is overwritten. UNIX does not verify that it has moved the file. As with the rm and cp commands, you can use the -i option. See Figure 3.4 for an example of the mv command.  

    	%  ls
    	dog.dat     hello.dvi   hello.tex   sub2 
    	hello.aux   hello.log   oscar       verona.txt
    
    	%  cp oscar zzz.dat
    	%  ls
    	dog.dat     hello.log   oscar       verona.txt
    	hello.aux   hello.tex   sub2        zzz.dat
    	hello.dvi
    
    	%  mv sub2 view.sub
    	%  ls
    	dog.dat     hello.log   oscar       view.sub
    	hello.aux   hello.tex   verona.txt  zzz.dat
    
    Note: Both cp and mv allow you to overwrite existing files. To overwrite means that the contents of the previous existing file are gone forever. It is very easy to overwrite an existing file if you are not being careful. Both commands have a -i option that will "inquire" whether you are sure you want to overwrite a file.

    The ln command   is used to create a link (like alias) of a file. The form of the ln command is:

    %  ln -s  thisFile  aliasFile

    Note: when you remove the alias, the old file(directory) is intact.
    To see if a file is an alias, use this command:ls -d aliasDir

    Miscellaneous

    Editors

  • Emacs/ Xemacs/ Mule is an extensible, customizable, self-documenting real-time display editor. Many command require pressing multiple keys including < ctl >, and < Alt >. This is why many Unix guys always swap < Caps Lock > key with < ctl > via xmodmap. For a quick start, refer to this Brief Guide to Emacs Editor.
    Emacs includes ELisp (Emacs Lisp) which is a programming language for artificial intelligence. ELisp makes emacs to be extensible and customizable anyway you want; which makes it to be the most powerful editor in the world. Note: Mule is capable of handling many different languages including Asian languages such as Taiwanese.
    Emacs is also great for SGML/XML in a Structured manner. You need to download/install PSGML


    Users Guide
    Tips for new Linux users Linux Guide