Tutorial: Unix Commands and Submit
U Drive and Putty
- Mount U drive
- U drive is identical to rucs home directory
- Personal machines:
- ThisPC/Computer/Map network drive
-
\\userdir\users\yourRUuserid
- If not logged in with RU userid: Select Connect using different credentials
- You may need to enter your userid as RADFORD\userid
- See OneStop for detailed instructions
- N.B. Your old H drive is at userdir\username
- Run putty and login to rucs
- Download
PuTTY and run executable
- Host name: rucs.radford.edu
- Home directory on rucs is your U: drive
Shell
- A program that provides access to OS services and resources
- Provides a command line interface to OS
- Common unix shells: bash, csh, ...
- Common windows shells: cmd, powershell, bash
- Putty (and mac terminal window) give access to a shell
- Putty (and terminal window) runs on your local machine, and shell
runs on the remote machine (ie rucs)
- What a shell does:
- Run Commands:
- Read command line
- Find command(s)
- Execute command
- Maintain Environment Variables: eg $PATH.
- Shell Startup:
- Automatically execute commands read from a startup file
- Example: .profile, .cshrc, in home directory
- Name of startup file varies depending on shell
- Command execution
- Built-in: ls, cd, pwd, rm - run by shell program
- Can start other programs, from PATH: eg gnatmake
- Can start other programs, from local directory: eg ./homework_one
- ./ not needed if . is on $PATH
- What is .? A special name for the current directory
Basic Commands
Absolute and Relative Paths
- A directory is equivalent to a folder
- Some directories have special names:
- ~ - your home directory
- . - the current directory
- .. - the parent of the current directory
- The current directory is the directory that commands refer, unless another
directory is given
Special Directories
- A directory is equivalent to a folder
- Some directories have special names:
- ~ - your home directory
- . - the current directory
- .. - the parent of the current directory
- The current directory is the directory that commands refer, unless another
directory is given
Basic Commands
- pwd, ls, cd, absolute and relative paths, . and .. (current and parent dirs)
pwd # print working directory
ls /usr/local/gnat # list files at this directory
# absolute paths start with /
cd /usr/local/gnat # change to that directory
pwd # yup, we're there
cd bin # change to child directory bin
pwd
ls # look at current directory
ls . # look at current directory
ls .. # look at parent directory.
cd ../lib # change to sibling directory bin. Relative path
pwd
cd .. # change to parent directory
pwd
cd ./bin # change to child of current directory
pwd
./gnatls # run gnatls from current directory
More on ls
- ls -l: type (d=dir), permissions, links, owner, group, size,
date, time, name
- Permissions: Read/Write/Execute for User/Group/Others
- -- for options that are words
cd /usr/local/bin
ls # list files
ls -l # long format
ls -a # all files (include hidden files)
ls -F # mark directories with / and executables with *
ls --color # color
ls -alF --color # Multiple options
ls lib # files in directory lib
ls -d lib # directory lib itself
~ (home directory), - (previous directory),
pwd
ls ~ # list files in home directory
cd ~ # Change to home dir
cd - # change to previous dir
cd # Change to home dir
cd - # change to previous dir
pwd
mkdir (Make a directory), ls -d
cd ~ # Start in home dir
mkdir 320 # create new child dir
ls -d 320 # dir 320 should exist
ls 320 # 320 should be empty
mkdir 320/h1 # create a child of 320
ls 320 # 320 no longer emtpy
ls -d 320 # view 320 as a directory
cd 320 # go to child
pwd
ls
ls -a # what are . and ..?
cd h1
pwd
Create, compile, run, and cat int1.adb
- Create
int1.adb
on laptop and save in 320/h1
with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;
procedure int1 is
i: Integer;
begin
get(i);
put(i);
new_line;
end int1;
cat (View), compile and run on rucs:
cd ~/320/h1
ls
cat int1.adb
gnatmake int1
./int1
Edit int1.adb and introduce a few errors for practice, then fix them
- Use vim or nano [running pico also runs nano] for an editor
cp, mv (copy and move - destination is a dir)
cd ~/320/h1 # start in home
ls
cp int1.adb int2.adb # copy int1.adb to new file int2.adb
ls
mv int2.adb .. # move int2.adb to parent dir
ls # it's gone from here
ls .. # it's in the parent
mv ../int2.adb . # move it back to here
ls # yup, it's here
mv (rename - destination is a file, not a dir), rm (remove)
ls
mv int2.adb int3.adb # change name of int2
ls
rm int3.adb
ls
* (Wildcard)
cp int1.adb int2.adb
gnatmake int1 # create some .o and .ali files
gnatmake int2
ls
ls int1* # all int1
ls int2.* # all int1.
ls *
rm *.o # all .o
rm *.ali # all .ali
rmdir (remove directory - which must be empty)
cd ~/320
mkdir tmp
cp h1/int1.adb tmp
rmdir tmp # not empty
rm tmp/int1.adb # empty it
rmdir tmp # now it works
ls # yup, it's gone
submit command
cd h1
submit itec320-01 int1.adb # submit it
submit itec320-01 -ls # check it
Other Commands
- cls
- alias
- head, tail
- which
- less, more
- | (ie pipe)
- wc
- grep
- diff
- find
- man
- od -x
configuration
- What shell am I running: ps
- tcsh vi command line editing: bindkey -v
- bash vi command line editing: set -o vi
Redirection: Standard input and output
cmd windows vs unix
- ls vs dir
- cat vs type
- mv vs rename
- rm vs delete
exit
WinSCP
- Another way to get files to rucs is to use winscp
-
For personal machines,
download and install WinSCP
- Macs and linux machines - can use scp from command lien