Frequently Asked Questions - Unix-Linux



MySQL Database Account

MySQL is the general purpose database available for student use. Each user is allowed one database. This database is automatically created after requested by a user and is named the same as your cse username. Users can create as many tables as they want but we ask that they keep all databases to a reasonable size.

Requesting a MySQL Account and Database
Any user with a CSE account can request access to the MySQL server running on cse.unl.edu. To do so, log in to the CSE Account Management Utility (AMU) page at cse.unl.edu/account with your CSE account credentials. Once you log in, click the Account Settings link on the left page. From there, check the box for MySQL Account and then click Save. You should then receive an email message with your MySQL account credentials.

Connecting to MySQL Database
To connect to a MySQL database from the command-line, type 'mysql -p' and hit enter. The password you will be prompted for will be your MySQL password, which is different from your CSE password.

Resetting MySQL Password
To reset the MySQL password go to cse.unl.edu/account. Log in using your cse credentials and click the 'Reset MySQL Password' link. A new randomly generated password will be sent to you via email.

Changing MySQL Password from CLI
From the MySQL prompt, type 'set password=password('####');' and hit enter. '####' denotes the password you wish to set it to.

Back to top ↑



How to Format Your Thesis Using LaTeX

The Office of Graduate Studies dictates the style and format for a thesis at the University of Nebraska-Lincoln. Information about these standards can be found on their website for current students at http://www.unl.edu/gradstudies/current/, and specifically in a publication titled "Guidebook For Preparation and Submission of a Thesis". 
 

The Department of Mathematics maintains a LaTex class file that helps format your thesis to Nebraska's guidelines. This template may be helpful to Computer Science and Engineering students as well. Look for the "NU Thesis LaTeX Class File" under the Resources section of this page: http://www.math.unl.edu/graduate/

Back to top ↑



Compilers and Interpreters available on cse.unl.edu

Compilers

gcc GNU CcCompiler
g++ GNU C++ compiler
javac Java compiler
gfortran GNU Fortran compiler
clisp Common Lisp
alisp Allegro Common Lisp

Interpreters

perl Perl command line scripting language
php Command line and web scripting language
ruby Command line and web scripting language
pyton Command line scripting language

Back to top ↑



A simple unix text editor - pico

To use pico, type "pico filename" where filename is the file you with to create or edit. Once in pico, you will see a list of pico commands you can use, shown on the bottom of the screen. The '^' symbols means <CTRL>. To view the pico help screen the command shown on the bottom of the screen is "^G" which means <CTRL>-G.

Back to top ↑



Basic Unix Commands

Note on systax used in document:
items in [] are optional
items in {} can be repeated 0 or more times.
fn = filename (possible with wildcards)
dir = directory name

File System:

cat fn {fn}
concatenate, can be used to display a file.
more fn {fn}
displays file(s) one screenful, at a time. At MORE prompt enter: space bar - for next screenful <cr> - for next line, q - to quit more command.
cp fn1 fn2
copy file - fn1 to fn2, fn1 remains.
mv fn1 fn2
move (rename) file - fn1 to fn2, fn1 no longer exists.
rm fn
remove (delete) file.
lpr -Pprinter_name fn
print a file, printer_name = ps16 or ps17.
ls [fn]
list files in current directory option filename is usually used to display files matching wildcards. (ie. ls *.s will list all assembly language source files.)
ls -lgRa
Recursive listing of all files within all subdirectories. Longest, most descriptive format.
cd [dir]
change working directory, ``home directory" if not specified. cd .. will backup one level in the directory structure.
pwd
print working directory path.
mkdir dir
make a new directory, giving it the name dir (within the current directory)
rmdir dir
remove (delete) the directory named dir (the directory must be empty)
file fn
Tries to determine what kind of information is in a file by consulting the file system index and by reading the file itself.
du
Prints a summary of total space occupied by all files in a hierarchy.
sort fn
Sorts ASCII files line-by-line.
chmod
Change file permissions. See the man pages for a complete description of settings. Use this command to determine whether files can be readable by other people.
find . -name filename
In it's most simple form find will display all files in this and any subdirectories which name matches filename. See the man page for find for a complete description of this command. Find can be use to find files matching name patters, dates, owners, sizes, etc. and to perform action on matched files.
gzip fn
Use this to compress files not needed immediately to conserve disk space. A ``.gz" will be appended to the filename.
gzip -d
Uncompresses files with ``.Z" at end of filename.
head {-n} fn
Prints first n lines of a text file. If no number is specified, the default is 10.
tail {-n} fn
Prints last n lines of a text file. If no number is specified, the default is 10.
tail {-n} fn
Prints last n lines of a text file. If no number is specified, the default is 10.
grep string fn
Print occurrences of string in file


Remote Connection:

ssh remote_host
Launch a secure shell to the remote host specified.


Communication:

finger
list users currently on the system.
who
list users currently on the system.
w
what, similar to who but includes what they are doing.
pine
Email message utility.
pine username
will send Email to username.
talk username
allows two users to have an interactive conversation over the computer.
write username
allows a user to put a message on another users screen.
mesg n
Makes it so other users cannot interrupt you with talk requests, and write messages.


Help:

man command
manual, returns the manual for the given command from the UNIX on-line manual. If you cannot find a man page for a command, there may be one in a directory that isn't in your MANPATH. Your MANPATH is setup in the .login file and a command's man page is usually in a man directory off the same parent directory as the command. For example, if the command is located in /usr/local/bin, its man page is probably in /usr/local/man.
man -k keyword
display manual headings containing the word keyword.


Miscellaneous:

alias name def
Assigns ``def'' to the alias ``name''. Usually found in the .cshrc file. For example ``alias dir ls -la''.
clear
Clears screen.
history
List history of commands used.
!!
re-execute the last command entered.
!x
re-execute the last command that started with the given letter, eg !c will re-execute the last command that began with the letter c.
jobs -l
list all currently stopped or background jobs with job numbers and process ID's.
kill [-signal] %jobnumber
kill the given job number. Use the "jobs" command to show running jobs. You might need to kill a job to logout if you have accidentally put a job into the background or stopped a job. Use -TERM or -KILL singlas to force quite jobs.

kill PID
kill the given Process. refer the "ps" command to find running processes. Use -TERM or -KILL singlas to force quite jobs.
ps -fa
list all your current processes. See the man page for a full description.
<control>C
kill the current process - the one in the  foreground
<control>Z
suspend foreground process.
bg
put a suspended job in the background.
fg
put a suspended or background job in the foreground.
date
display time and date.

To find out about more commands, click  here.

Back to top ↑



Linux SMB Printing

Note: Printing only works when you are on a Nebraska network.

  1. step 1Open System Settings
  2. step 2Open Printers:
  3. step 3Click on Add:
  4. step 4Expand Network Printer and select "Windows Printer via SAMBA":
  5. Enter csnt and the name of the printer that you want to add such as "Avery-ps15" and select "Set authentication details now" and enter cs.unl.edu\username (where username is your cse user name), enter your cse password in the Password: field and click Forward:
    step 5
  6. Select Generic (recommended) and click Forward on the next window:
    step 6
  7. Select PostScript in the Models column of the next window and select Generic PostScript Printer Foomatic/Postscript [en] (Recommended) column:
    step 7
  8. Enter a short name for the printer, such as "ps15", and a "Human-readable" name for the printer such as "Avery-ps15" and then click Apply. The short name can be used later for command-line printing and the "Human-readable" name will show up in print applications that use the system's GUI.
    step 8
  9. You can click Cancel on the popup window or click Print Test Page. The test page will be deducted from your print quota if you choose to print it.
    step 9

Linux Mint uses very much the same procedure except instead of being called "System Settings" the system configuration application is called "Control Center". Other Linux distributions are similar.

If you want to take advantage of more advanced printer features, such as duplexing or stapling, you can use a printer-specific driver for the printer models as seen at the bottom of Printing from Mac via SMB 10.8+ section of this FAQ

Back to top ↑



Editing a File on Unix with vi - Basic Commands.

What is  vi?

The default editor that comes with the UNIX operating system is called  vi ( visual editor). [Alternate editors for UNIX environments include  pico and  emacs, a product of GNU.]

The UNIX  vi editor is a full screen editor and has two modes of operation:

  1. Command mode commands which cause action to be taken on the file, and
  2. Insert mode in which entered text is inserted into the file.

In the command mode, every character typed is a command that does something to the text file being edited; a character typed in the command mode may even cause the  vi editor to enter the insert mode. In the insert mode, every character typed is added to the text in the file; pressing the  <Esc> ( Escape) key turns off the Insert mode.

While there are a number of  vi commands, just a handful of these is usually sufficient for beginning  vi users. To assist such users, this Web page contains a sampling of basic  vi commands. The most basic and useful commands are marked with an asterisk ( * or star) in the tables below. With practice, these commands should become automatic.

NOTE: Both UNIX and  vi are  case-sensitive. Be sure not to use a capital letter in place of a lowercase letter; the results will not be what you expect.

To Get Into and Out Of  vi

To Start  vi

To use  vi on a file, type in  vi filename. If the file named  filename exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you may enter text.

* vi filename edit  filename starting at line 1
  vi -r filename recover  filename that was being edited when system crashed

To Exit  vi

Usually the new or modified file is saved when you leave  vi. However, it is also possible to quit  vi without saving the file.

Note: The cursor moves to bottom of screen whenever a colon ( :) is typed. This type of command is completed by hitting the  <Return> (or  <Enter>) key.

Basic Command Command Description
here :x <Return> quit  vi, writing out modified file to file named in original invocation
  :wq <Return> quit  vi, writing out modified file to file named in original invocation
  :q <Return> quit (or exit)  vi
 *  :q! <Return> quit  vi even though latest changes have not been saved for this  vi call

Moving the Cursor

Unlike many of the PC and MacIntosh editors,  the mouse does not move the cursor within the  vi editor screen (or window). You must use the the key commands listed below. On some UNIX platforms, the arrow keys may be used as well; however, since  vi was designed with the Qwerty keyboard (containing no arrow keys) in mind, the arrow keys sometimes produce strange effects in  vi and should be avoided.

If you go back and forth between a PC environment and a UNIX environment, you may find that this dissimilarity in methods for cursor movement is the most frustrating difference between the two.

In the table below, the symbol  ^ before a letter means that the  <Ctrl> key should be held down while the letter key is pressed.

Basic Command Command Description
* j  or  <Return>   [ or down-arrow] move cursor down one line
* k [ or up-arrow] move cursor up one line
* h  or  <Backspace>   [ or left-arrow] move cursor left one character
* l  or  <Space>   [ or right-arrow] move cursor right one character
* 0 (zero) move cursor to start of current line (the one with the cursor)
* $ move cursor to end of current line
  w move cursor to beginning of next word
  b move cursor back to beginning of preceding word
  :0 <Return>  or 1G move cursor to first line in file
  :n <Return>  or nG move cursor to line  n
  :$ <Return>  or G move cursor to last line in file

Screen Manipulation

The following commands allow the  vi editor screen (or window) to move up or down several lines and to be refreshed.

Basic Command Command Description
  ^f move forward one screen
  ^b move backward one screen
  ^d move down (forward) one half screen
  ^u move up (back) one half screen
  ^l redraws the screen
  ^r redraws the screen, removing deleted lines

Adding, Changing, and Deleting Text

Unlike PC editors, you cannot replace or delete text by highlighting it with the mouse. Instead use the commands in the following tables.

Perhaps the most important command is the one that allows you to back up and  undo your last action. Unfortunately, this command acts like a toggle, undoing and redoing your most recent action. You cannot go back more than one step.

* u UNDO WHATEVER YOU JUST DID; a simple toggle

The main purpose of an editor is to create, add, or modify text for a file.

Inserting or Adding Text

The following commands allow you to insert and add text. Each of these commands puts the  vi editor into insert mode; thus, the  <Esc> key must be pressed to terminate the entry of text and to put the  vi editor back into command mode.

Basic Command Command Description
* i insert text before cursor, until  <Esc> hit
  I insert text at beginning of current line, until  <Esc> hit
* a append text after cursor, until  <Esc> hit
  A append text to end of current line, until  <Esc> hit
* o open and put text in a new line below current line, until  <Esc> hit
* O open and put text in a new line above current line, until  <Esc> hit

Changing Text

The following commands allow you to modify text.

Basic Command Command Description
* r replace single character under cursor (no  <Esc> needed)
  R replace characters, starting with current cursor position, until  <Esc> hit
  cw change the current word with new text, starting with the character under cursor, until  <Esc> hit
  cNw change  N words beginning with character under cursor, until  <Esc> hit;   e.g.,  c5w changes 5 words
  C change (replace) the characters in the current line, until  <Esc> hit
  cc change (replace) the entire current line, stopping when  <Esc> is hit
  Ncc  or  cNc change (replace) the next N lines, starting with the current line, stopping when  <Esc> is hit

Deleting Text

The following commands allow you to delete text.

Basic Command Command Description
* x delete single character under cursor
  Nx delete N characters, starting with character under cursor
  dw delete the single word beginning with character under cursor
  dNw delete  N words beginning with character under cursor;   e.g.,  d5w deletes 5 words
  D delete the remainder of the line, starting with current cursor position
* dd delete entire current line
  Ndd  or  dNd delete  N lines, beginning with the current line;   e.g.,  5dd deletes 5 lines

Cutting and Pasting Text

The following commands allow you to copy and paste text.

Basic Command Command Description
  yy copy (yank, cut) the current line into the buffer
  Nyy  or  yNy copy (yank, cut) the next N lines, including the current line, into the buffer
  p put (paste) the line(s) in the buffer into the text after the current line

Other Commands

Searching Text

A common occurrence in text editing is to replace one word or phase by another. To locate instances of particular sets of characters (or strings), use the following commands.

Basic Command Command Description
  /string search forward for occurrence of  string in text
  ?string search backward for occurrence of  string in text
  n move to next occurrence of search string
  N move to next occurrence of search string in opposite direction

Determining Line Numbers

Being able to determine the line number of the current line or the total number of lines in the file being edited is sometimes useful.

Basic Command Command Description
  :.= returns line number of current line at bottom of screen
  := returns the total number of lines at bottom of screen
  ^g provides the current line number, along with the total number of lines, In the file at the bottom of the screen

Saving and Reading Files

These commands permit you to input and output files other than the named file with which you are currently working.

Basic Command Command Description
  :r filename <Return> read file named  filename and insert after current line (the line with cursor)
  :w <Return> write current contents to file named in original  vi call
  :w newfile <Return> write current contents to a new file named  newfile
  :12,35w smallfile <Return> write the contents of the lines numbered 12 through 35 to a new file named  smallfile
  :w! prevfile <Return> write current contents over a pre-existing file named  prevfile

Back to top ↑