Difference between revisions of "Shell Access"

From XMission Wiki
Jump to: navigation, search
(new page)
(No difference)

Revision as of 17:10, 28 July 2007

How do I activate my shell account?

To activate your shell account, simply contact accounting or technical support.

Why isn't shell access on by default?

Having shell access enabled by default on all accounts presents a security risk. A shell account gives the user a direct window into our system. By minimizing the number of active shell accounts, we minimize the risk of compromising our system.


Can I choose my shell type?

Yes. You can choose from bash, tcsh, sh, zsh, csh, and ksh. We recommend using either bash or csh, at first, since they're the most user-friendly.


What is SSH and how do I use it?

SSH is a secure shell. Using it is differs, depending on the operating system. Mac OS X is probably the easiest. Nothing special has to be installed. Simply open a terminal window and ssh username@shell.xmission.com. Accept the key and enter your password. For most Windows operating systems, an SSH client must be used. There are many SSH clients on the market and a few are "freeware". PuTTY is a recommended free SSH client for Windows. Some places to look for additional SSH software would be Download.com and Tucows.com.


What are my telnet software options?

There are dozens of telnet/terminal applications available. Though applications are installed by default for Windows (Telnet) and Mac OS X (Terminal), you may choose to download a telnet program with more features. Some places to look for this software would be Download.com and Tucows.com.


Why don't my screen and text work properly?

There are two typical problems that occur during a telnet session. The first and most common problem is incorrect terminal emulation. The second problem occurs after a screen has been messed up by viewing a binary file.

The most commonly used terminal emulation is vt100, though vt220 is supported and recommended. To change the terminal emulation of your telnet application, view the preferences and choose either vt100 or vt220. However, even after specifying the terminal emulation for your telnet application, you may still have problems correctly displaying columns and rows. For this, you'll need to define the default size of your window in your run commands (explained below]). When trying to fix a screen after viewing a binary file, run fixvt at a command prompt.


What are some common commands I'll need to know when using the UNIX shell?

The most common commands you'll need to know are cd (changes your directory), pwd (shows your current directory path), and ls (lists the contents of the current directory). For a more complete list of common commands, please see our Common Commands page.


Why do I get "command not found" when using a command I'm sure should work?

It's possible that you don't have the paths to the command directories defined correctly in your run commands. For instructions on defining the correct paths, see below.

How do I edit my shell run commands (rc) file?

Your shell run commands are found in a file named .cshrc (for c shell), .bashrc (for borne shell), .kshrc (for korn shell), etc. This file will be located in your home directory (/home/users/u/username). It contains commands that are run when you first log on to set your paths, environment variables, and aliases. Before changing ANY rc file, it's recommended you make a back-up copy.

To set or edit your paths, edit your run commands file with a text editor (pico, vi, ed, etc.). Your paths will be defined after the command set path =. The default paths should be /bin /usr/local/bin /usr/bin. If you'd like to add a path, simply add it to the end, separated by a space. (e.g.: /home/users/u/username/morecommands/) If you'd like to edit what information is displayed in your prompt, edit the set prompt= variable. A useful way to define your prompt is to have it display your current directory. To do this, remove the default set prompt= and enter this in its place:


alias cd 'cd \!* ; set prompt="'hostname':'pwd'> "' To edit your environment variables, first type env at a command prompt to show your current variables. If you'd like to change any of these, enter the definition after a new "setenv" line. The proper syntax, as you'll see in the default settings, is:


setenv VARIABLE_NAME path/or/command:/2nd/path/or/command/ Adding an alias is fairly simple. If you'd like a certain command to be run when you type something in at the command prompt, you'd enter that here. The proper syntax is:


alias aliasedcommand 'realcommand -options' This is also where you define your terminal emulation settings. setenv TERM vt100 (sets terminal type) /bin/stty rows 24 (sets number of rows) /bin/stty cols 80 (sets number of columns) /bin/stty erase ^H (sets backspace command)


What are all these files in my home directory, and what are they for?

If you do a complete list, showing hidden files, of your home directory, you will notice that there are several files already there. The files are listed and explained in the table below. Some of these files will not be there by default, but only appear if the application that uses them is run.

Types

rc run commands/preferences (usually, but not always)

Files

.cshrc shell run commands(for csh or tcsh) .gopherrc gopher preferences .login shell preferences (read after run commands at login) .newsrc news preferences .nn Network News Reader preferences .pinerc Pine preferences (pine is primarily used for email) .tin Threaded Internetwork News preferences

Directories

bin can contain scripts or binary executables ftp your personal directory for file transfer mail Email is stored here (used by pine and others) news articles are saved here by default public_html your web pages


How can I alter the information shown in my prompt?

If you use tcsh, changing the prompt is as simple as entering the command:

set prompt="options"

However, with other shells, you will need to edit the set prompt= line in your shell run commands file (shown above).


What program can I use to read email from a shell?

Probably the most popular options are mutt (recommended) and pine, but elm, mail/rmail, and emacs are also available. At a command prompt, run the command mutt, pine, or elm and the mail client will open, also creating either a /mail (pine and elm) or /Mail (mutt) directory. Using mail/rmail or emacs isn't quite as intuitive. It's recommended that you read the manual before using. (Type man mail or man emacs at a command prompt.)


What program can I use to read news (Usenet) from a shell?

The newsreaders available on shell are slrn, tin, nn, pine, nmh, trn, and emacs. The most popular ones would be slrn, tin, nn, and pine. We recommend slrn, since it's the only one that still has development. For more information on how to use any of these programs, type "man" followed by the program name at the command prompt (e.g.: man tin).


How do I kill a process?

Before you kill a processes, you have to have its processes ID. You get this by typing "ps" at the command prompt. Once you've determined which one of your processes is the one you want to kill, type kill -9 PID (where PID is the actual processes ID) at the command prompt.


Is there a way to transfer files to and from my XMission account other than FTP?

Although FTP is the recommended way to transfer files to and from your XMission account, it's not the only way. It's possible to transfer files directly from your shell by using ZModem. Please refer to the ZModem manual for more information.


How do I compress and decompress files?

The method you'll use to decompress a file is determined by looking at the file extension. The instructions below show how to decompress the file in the current directory. For further information, see the manual for each program (tar, bzip, unzip, gzip, uncompress).

file.tar tar xvf file.tar

file.Z uncompress file.Z

file.gz gzip -d file.gz

file.zip unzip file.zip

file.bz2 bzip2 -d file.bz2

If there is a combination of formats, such as file.tar.gz, you can either pipe one command to the other (e.g. gzip -d file.tar.gz | tar xvf), or see if the option is supported by tar (man tar>. Using the command tar xvfz file.tar.gz will handle both the gzip compression and the tar compression. When piping a .Z file, however, be sure to use zcat file.Z (the equivalent of uncompress -c file.Z, which writes to standard output the files that were compressed). A similar rule applies to bzip2, where you should use bzcat file.bz2 (equal to bzip2 -dc file.bz2) when piping the output to another command.


What are some basics on setting permissions with "chmod"?

First, an understanding of file/directory ownership is needed. Each file or directory has a user (also the owner) and a group. The owner of your files should always be your XMission username. The groups you'll need to know are www (which gives the web server access to the files) and users (which gives any of XMission's users, from shell, access to the files). There's also the category, others, that includes any user or group.

Permissions are based on those three categories: owner, group, and others. When you do a long listing of the file (ls -l filename), the permissions will be displayed to the left. The format is shown as such:

-rw-r--r-- 1 acctname group 1949 Sep 19 2000 file.html

The first space defines weather the file is a simple file (shown with a hyphen) or a directory (shown with a d). The next three spaces represent the permissions (highlighted in red) for the owner, the next three are for the group, and the last three are for others. The letters represent what kind of permissions are allowed.

r = Read (view and make copies)

w = Write (make changes to or delete)

x = Execute (run program/script) When using "chmod" to change permissions, you will need to specify the category by using one or a combination of the following letters:

u = User (Owner)

g = Group

o = Others

a = All (same as using "ugo") To change the permissions, execute "chmod" with the following parameters:

chmod who+/-/=permission file

The plus (+) adds the following permission, the minus (-) removes it, and the (=) adds it, discarding any previous permissions. Some examples:

chmod g+r file.html (adds read access for group)

chmod go-r file.html (removes read access from group and others)

chmod a=x file.html (replaces existing permissions with read access for all)

chmod g+rx file.html (adds read and execute access for group) There is another way to change permissions without having to write out chmod who+/-/=permission file every time. This method uses a 3-digit octal number. Determining the octal number is fairly easy after some practice. To start, refer to the chart below.


Symbol Octal ---0--x1-w-2-wx3r--4r-x5rw-6rwx7</td> For example, if you'd like to set the permissions on file.html to be -rw-r--r-- you would determine the octal number like this (skip the first space in the set): rw- = 6, r-- = 4, r-- = 4. The octal number is 644.

To execute the command, type:

chmod 644 file.html

Changing ownership and the group of a file would normally be done with "chown" and "chgrp". However, because these commands are restricted to the user and group being specified, you're unable to use them on XMission (because you're only one user and you're only a member of one group). However, if you'd like a file to belong to the group www, you can either create it in or upload it to your public_html directory. This will set the group, by default, to www.