ducky.loni.org
You should see a black window with a blinking cursor after the line:
username
type in your logon id and press return, then enter your password.
You will then see the following:
The authenticity of host 'ducky.loni.org (208.100.72.13)' can't be established. RSA key fingerprint is 2d:37:c3:97:f4:bc:5f:2c:8e:f2:6f:1a:27:d2:07:fb. Are you sure you want to continue connecting (yes/no)?
You will type the full word "yes" out and press return.
Then you will see the following:
Warning: Permanently added 'ducky.loni.org,208.100.72.13' (RSA) to the list of known hosts.
Now you should be ready to start.
Return to top of page
cd
"cd" by itself brings you back to your home directory. "cd name" takes you to the directory in the currently directory named "name".pwd
Will print on the next line: /home/userid. This will indicate where you are in your account.ls
This commands gives a column list of the contents of the working directory (folder). The switches "-a" and "-l" or "-al" work the same on AIX, RHL, Fedorea, Digital Unix and Solaris.rm filename
rm -rf directory_name
This command will delete a directory even if it still contains other directories and/or files.rmdir directory_name
This command will delete a directory IF and only if it is empty.Return to top of page
cat test.txt
more test.txt
head text.txt
head -3 test.txt
tail test.txt
tail -3 test.txt
Return to top of page
ls t?st.txt
ls ?
ls p*
ls t*t
ls t[aeo]st.txt
ls t[a-z]st.txt
Return to top of page
Vi stands for visual editor.
Command mode:
This is the mode that vi comes up in. If the file doesn't exist then you will see a screen with tilde's "~". If the file does exist you will see the first page of text in the file. Lets create a new file - use your name followed by .txt. So my file would be named "kathy.txt".
vi kathy.txt
Vi basic movement commands. You must be in command mode to move around to get into command mode press the escape key
Because this is a new file there is nowhere inside of the file to go. So the cursor can't move around. We have to go to text mode and create text so that we have something to move around in.
Now that we know the basic commands lets finish adding text to this file:
Copy the text off the web page
Go into the file, and insert a word on the first line after the third word Save the file Get into text mode and go to the third line. Insert a new line after the third line and type "All good boys do fine." Get into command mode, to to the 8th character on the first line and replace it with a "+". To replace it put the cursor on the 8th character, type a lower case "r" then type the plus sign. Return to top of page Type:
Type: Typed: Return to top of page
Examples of permissions:
ls -l
Return to top of page ls -l chmod a-w your-name.txt; ls -l Now, lets change the permissions so that the group has no access and other has all access modes. First type: ls -l chmod g-rwx kathy.txt; ls -l chmod o+rwx kathy.txt
So to change a file or directory's permissions so that it looked like the first one:
ange a file so ther permission looks like the second one:
However, if you do this you can't serve any web pages that you have created because the web server doesn't have access to move through the directories to get to "public_html". The recommanded setting for your home directory, from many tutorials and textbooks, is: chmod 711 ~. This will allow the user full access and all others can pass through the home directory.
Return to top of page
grep bash$ /etc/passwd
ps uax | grep $USER M
find . -name "*.xml" find . -name "*.xml" | grep $USER Return to top of page
now try:
ps uax | awk '/ktraxler/'
ps aux | awk '/ktraxler/' {print $1, $2, $4}'
awk can do math also:
ps uax | awk '/ktraxler/ {x += $4} END {print "total memory: " x } ' Return to top of page
To find available shells in your system type: Cat types out the contents of a file as you saw above. The file "shells" in the "/etc" directory holds all available shells in the system. To find your current shell type: The command "echo" echos or types what follows it. The "$" sign says echo the contents of the following system variable. The "SHELL" is a system variable set up in your init file or by using the "export" command. To find out where your shell and other basic information is stored: To get back to your home directory type: class=action> Here is what it will look like on "Tezpur": Return to top of page Return to top of page
Use the following commands to add text to a file:
Vi Text mode:
Vi basic insert text commands:
hit the 'i' key for insert mode
Paste the text into the file
hit the escape key
Type :wq
the "w" tells vi to write the file to disk (save the file)
the "q" tells vi to quit
If you don't type the "q" vi saves the file and lets you continue
Getting Help from the System
The basic way to get help on the system:
man cp
whatis cp
apropos copy
File System Access/Security
When you execute the command "ls -l" (list the contents of the directory in long form) you will see something that looks like this:
[ktraxler@is linux_II]$ ls -l
total 80
-rwxr-xr-x 1 ktraxler internalusers 48928 Jan 28 2005 linux.html
-rwxr-xr-x 1 ktraxler internalusers 15650 Aug 2 10:58 linuxII.html
-rwxr-xr-x 1 ktraxler internalusers 15795 Aug 2 09:54 linuxII.html.bak
The group of characters to the left are the access rights or permissions of each file, directory or link. The first character tells whether this is a file, directory or link. The values would be:
The remaining symbols have context in groups of three giving the permissions of access for different groups. These permissions allow the reading, writing and execution (or pass through) for a person or group.
In each group of three you will have the following permissions:
To read a file you must have read access on the file itself and you must have executable access to the directory it is in (so you can get into it) and to any directories that are ancestors of this directory (come before).
To see this on your account type:
-rwx------ a file that only the owner can access. The owner can read, write or execute the file. -rwxr--r-- a file that everyone can read using vi, more, cat, etc. But only the owner can change the contents or delete it. drwxr-x--- a file that the owner and the owner's group can access. The owner can read, write or execute but the group can only read and execute.
Changing File Access
You have to be very careful with this type of action, if you change permissions on the wrong files you can change the operation of your computer!Only the owner of a file or directory can use the command to change the file access. The command to change this is "chmod", changing mode. The syntax of the command is: chmod ugoa+[-]rwx file-name. The plus adds a permission for an either the owner, group, or other. The minus removes that permission.
Now, look at the permissions on the file your-name.txt. Then type:
(The semi-colon allows you to type multiple commands on one line. The commands are then executed in the order typed.)
You have just changed the access on file your-name.txt so that the owner, the group and others may write to that file, if they have permission to get into the directory that contains it.
Then type:
This changes the permissions for the file, "your-name.txt" so that the group has no permissions. Now you need to change the permissions so that all other users has every access permission:
ls -l
There is another way to set permissions and that is by adding the numeric values assigned to the permissions for each group. I am told this is the way a REAL UNIX/Linux user changes permissions! The permissions have the values of:
So, for example the file permissions used in the examples above become:
-rwx------ 700 -rwxr--r-- 744 drwxr-x--- 750
To change a file so ther permission looks like the second one:
Your home directy is the place on the Unix/Linux server that you log into and your information is stored. This is represented by a tilde, "~". You can run the chmod command on your home directoy. The safest setting is: chmod 700 ~.
Your home directy is the place on the Unix/Linux server that you log into and your information is stored. This is represented by a tilde, "~". You can run the chmod command on your home directoy. The safest setting is: chmod 700 ~.
Grep
The grep command is useful for finding strings of characters in text files. It is short for "Get Regular Expression and Print". To find all users using the bash shell on this machine:
"ps" gives information about a selection of the active processes. By default it selects all process with the same effective user ID as the current user. Adding the options "uax" is a BSD syntax for viewing every process on the system with the resources you are using. Then you pipe it through grep "| grep" with for strings that match the regular expression defined by $USER (me in this case).
Grep Tutorials:
Awk
Awk is another text processing tool that will make your hunt for data a lot easier. It is actually a programming language designed for text manipulation but is widely used as an on the spot fool for administration.
Take the example on process from grep:ps uax | grep $USER
The *nix Shell
The shell is your workspace in the terminal. It is a command language interpreter that executes commands read from the standard input device or from a file.
Shell Name
Developed by
Where
Remark
BSH (Bourne-Again SHell)
Brian Fox and Chet Ramey
Free Software Foundation
Most common shell in Linux
CSH (C SHell)
Bill Joy
University of California (For BSD)
The C shell'ssyntax and usage are very similar to the C programming language.
KSH (Korn SHell)
David Korn
AT & T Bell Labs
TCHS
See the man page. Type $ Man tcsh
TCSH is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).
cat /etc/shells
echo $SHELL
cd
Now, to list all files including the hidden ones type:
ls -al

Other Useful Commands
Some of the other commands that you might find useful are:
quota shows you your quotas on the machine in column format with headers usage: quota -v dr reports the space left on the file system usage: dr du outputs the number of kilobyes used by each subdirectory, use in home directory usage: du gzip Compresses a file usage: gzip filename gunzip Uncompress a file usage: gunzip filename file classifies the named files according to the type of data they contain usage: file * date gives you the system date usage: date
Environment Variables
What are they?
The shell's environment is that umbrella of persistent knowledge under which the shell operates. This information is stored as "environmental variables", which are global variables that may be used at any point by the shell -- either internally or when explicitly required by the user. Other variables can be customized by the user using a specific set of files contained in their HOME directory. (Thanks to Brett Estrade for this paragraph.)
Your global environment consists of environment varibles such as:
echo $PATH
echo $PWD
echo $HOME
echo $USER
env | more
printenv GLOBUS_PATH
Change the values
Here is a place for a warning:
Do NOT change environment variables unless you understand completely what you are doing.
Suppose I setup my machine and didn't install JAVA because I'm a C and Fortran person. Now I have installed JAVA and need to make sure I can get to it.
Now, before we start changing things we have to know which shell "family" we are in. There are two major families of shell:
To create or modify a global environment you must use either "export" in the bash shells or "setenv" in the csh environment.
Bourne shell: To add a new place to look in your PATH variable:
export PATH=/admin/bin:PATH
C-shell:setenv PATH "/admin/bin:PATH
The difference here is only the syntax of the command due to the differing shells.Return to top of page
Bash users may create the following files in their home directory:
~/.bash_logout
Return to top of page
chmod u+x myscript
. You will then need to execute your script: ./myscript
> The "hello world" program in bash shell script:
vi kathy1
#
#
#This is my first shell script!
#
clear
echo "Hello World - this is my first shell script!"
#
./kathy1
This script doesn't execute because we didn't change the permissions. So change those.< br> Now execute the script as above.Lets create another script:
vi ginfo
#
#
# Script to print user information who currently login , current date & time
#
clear
echo "Hello $USER"
echo "Today is \c ";date
echo "Number of user login : \c" ; who | wc -l
echo "Calendar"
cal
exit 0
Now, set the permissions as before, then execute the script just like before.
A good starting guide is: Vivek
G. Gite's Shell Scripting Tutorial
Return to top of page
Remember that shell scripting is simply solving a problem with a series of Linux/UNIX system commands.
Practical application: I once worked on a package which would automatically create bunch of makefiles all having bad linking options.
To solve this one we need to:
grep bash$ /etc/passwd
The "$" sign is used to find lines ending with the characters "bash". You have to know the format of the file you want but with the /etc/passwd file the line ends with the shell.
This command says:
"ps" gives information about a selection of the active processes. By default it selects all process with the same effective user ID as the current user. Adding the options "uax" is a BSD syntax for viewing every process on the system with the resources you are using. Then you pipe it through grep "| grep" with for strings that match the regular expression defined by $USER (me in this case).
ps uax | grep $USER
ps uax | grep $USER
now try:ps uax | awk '/ktraxler/'

Notice that awk prints out fields with the ':' as the separator. So if we know what a command outputs, and we want only a few certain fields from that output we can start with field #1 and go over.
This is just another way to write this command and get the same information.
ps aux | awk '/ktraxler/ {print $1, $2, $4}'
Now that we can see what awk and grep can do lets go back to solving our problem. The steps were:
To count the lines giving us the number of unique files with that string in it we do "wc -l".
The script will look like this:
#open a new file for the shell script
vi exer1.bash
#use grep to find every file in the /etc/re0.d directory that has the string "bash" in it:
grep -i bash /etc/rc0.d/* | awk -F ':' '{print $1}' | sort -u | wc -l
#the '|' bar means pipe the output of the last command into the next one as input
#the grep command above pipes its output (a series of lines with the path) into awk
#the awk command tells it ot use the ":" that the grep uses to separate the fields to tell what field we are at #
#awk prints the first field and pipes it into the sort command
#the "sort -u" command sorts the output uniquely and removes all duplicates
#the "wc -l" counts the lines and tells us how many files there are in that directory and its sub-directories#
The image of using this series as an single command instead of a file is:
vi exer1.bash
grep -i bash /etc/rc0.d/* | awk -F ':' '{print $1}' | sort -u | wc -l
Return to top of page
Mail to: Kathryn R. Traxler